Lua Sample Script for Temperature Sensor
Posted: Saturday 25 March 2017 17:39
Is there a sample Lua Script where i can see how to react on a temperature sensor and switch another device on?
Thx
Thx
Open source Home Automation System
https://forum.domoticz.com/
Code: Select all
--[[
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
@ activity_heating.lua
@ author : Siewert Lameijer
@ since : 1-1-2015
@ updated : 13-3-2017
@ Script to switch ON/OFF heating when someone @ home or not
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
--]]
-- Someonehome Switch
local someonehome = 'Iemand Thuis'
local nobody_home = 'Niemand Thuis'
-- Nest Various
local nest_setpoint = 'Nest - Setpoint'
local nest_setpoint_idx = 77
local setpoint_low = 17
local setpoint_high = 21
-- Various Switches
local pico_power = 'PIco RPi Powered'
--
-- **********************************************************
-- Heating On when someone @ home
-- **********************************************************
--
setpoint_current_temp = tonumber(otherdevices_svalues[nest_setpoint])
if otherdevices[someonehome] == 'On'
and otherdevices[pico_power] == 'On'
and setpoint_current_temp == setpoint_low
and timebetween("08:30:00","22:00:00")
then
timer_body = 'Someone at home, turning ON heating'
timer_body0 = 'Current Setpoint: '..setpoint_current_temp..''
timer_body1 = 'New Setpoint: '..setpoint_high..''
commandArray["OpenURL"]="http://"..domoticz.ip..":"..domoticz.port.."/json.htm?type=command¶m=udevice&idx="..nest_setpoint_idx.."&nvalue=0&svalue="..setpoint_high..""
end
if otherdevices[nobody_home] == 'On' and otherdevices[pico_power] == 'On' and setpoint_current_temp ~= setpoint_low then
timer_body = 'Nobody at home, turning OFF heating'
timer_body0 = 'Current Setpoint: '..setpoint_current_temp..''
timer_body1 = 'New Setpoint: '..setpoint_low..''
commandArray["OpenURL"]="http://"..domoticz.ip..":"..domoticz.port.."/json.htm?type=command¶m=udevice&idx="..nest_setpoint_idx.."&nvalue=0&svalue="..setpoint_low..""
end