First or all, I am a NOVICE at programming. I am trying to modify code to support my scene but clearly need some help.
I have found out A/C running with doors wide open at times and could see the same thing happen with heat. All of my doors and windows have sensors that are tied to DSC alarm with EV-3 and the plug-in which is all working perfectly.
I would like to only run Nest when the doors and windows are closed and have been tinkering with the code below. I started with two scenes (one heat and one cool) but would prefer to have only one scene. So please check over my code and let me know what I need to do. Eventually, when I add more light controls, it would be nice to flash one of the lights in the house to alert but for now just would like to NOT throw money out the window-Literally!
Thanks for your assistance.
local SENSOR = 29 – The door/window sensor device number
local SENSOR = 30 – The door/window sensor device number
local SENSOR = 31 – The door/window sensor device number
local SENSOR = 32 – The door/window sensor device number
local SENSOR = 32 – The door/window sensor device number
local SENSOR = 33 – The door/window sensor device number
local SENSOR = 34 – The door/window sensor device numb
local THERMOSTAT = 26 – The thermostat device number
local DELAY = 300 – Seconds
local SES_SID = “urn:schemas-micasaverde-com:device:DoorSensor:1”
local SES_SID = “urn:schemas-micasaverde-com:device:DoorSensor:1”
local SES_SID = “urn:schemas-micasaverde-com:device:MotionSensor:1”
local SES_SID = “urn:schemas-micasaverde-com:device:MotionSensor:1”
local SES_SID = “urn:schemas-micasaverde-com:device:MotionSensor:1”
local SES_SID = “urn:schemas-micasaverde-com:device:MotionSensor:1”
local HVACO_SID = “urn:schemas-watou-com:device:HVAC_ZoneThermostat:1”
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