I am very tired of throwing money out the window and wanted to setup a scene that will not run the heat or AC when the door or window sensors are tripped. I have the following code but it just turned off the thermostat. In this scene I had triggers for each door sensor that triggered the scene when the sensor was tripped. I am using the nest thermostat and the DCS plug-in for my DSC alarm. Any help would be appreciated.
The intention was not to turn off the thermostat but rather pause it instead of off-possibly flash a light in the future when all is figured out. I have another scene that runs when all sensors are not tripped. With some wait times built in.
local SENSOR = 29 – The door/window sensor device number
local THERMOSTAT = 26 – The thermostat device number
local DELAY = 300 – Seconds
local SES_SID = “urn:micasaverde-com:serviceId:SecuritySensor1”
local HVACO_SID = “urn:upnp-org:serviceId:HVAC_UserOperatingMode1”
luup.call_delay( “turnOffAc”, DELAY)
– Turn off the thermostat if the sensor has been tripped for at least 5 minutes.
function turnOffAc()
local tripped = luup.variable_get( SES_SID, “Tripped”, SENSOR) or “0”
local lastTrip = luup.variable_get( SES_SID, “LastTrip”, SENSOR) or os.time()
if (tripped == “1” and (os.time() - lastTrip >= DELAY)) then
local modeStatus = luup.variable_get( HVACO_SID, “ModeStatus”, THERMOSTAT) or “Off”
luup.variable_set( HVACO_SID, “LastModeStatus”, modeStatus, THERMOSTAT)
luup.call_action( HVACO_SID, “SetModeTarget”, {NewModeTarget = “Off”}, THERMOSTAT)
end
end