Long story short, check the DetailedArmMode variable as well as the ArmMode variable. ArmMode will only show you part of what you are looking for with your alarm system. DetailedArmMode will let you make sure that your system as indeed been set to the proper mode. By checking both variables, it will help you eliminate any “false positives” with your alarm system. (Disclaimer, I have a DSB system, so I am assuming the plugin that interfaces to yours has similar options.)
You will have to play with your system and find out what the different values for ArmMode and DetailedArmMode are that you need to use.
Here is an example:
I use the following code in a scene set to run every two minutes. This sets my thermostat into EnergySavingsMode when the alarm has been set to Armed mode. (You can setup code to fire when the alarm is disarmed using the proper trigger and similar code).
It knows that the alarm has been properly set by checking both ArmMode and DetailedArmMode and seeing if the both are set to “Armed”, meaning that the alarm panel is in armed mode.
PARTITION_DEV_NUM is the device number of the alarm partition device in Vera.
THERMOSTAT_DEV is the device number of your thermostat
[code]local PARTITION_DEV_NUM = 61
local THERMOSTAT_DEV = 93
local state = luup.variable_get(“urn:micasaverde-com:serviceId:AlarmPartition2”, “ArmMode”, PARTITION_DEV_NUM)
local detailed_state = luup.variable_get(“urn:micasaverde-com:serviceId:AlarmPartition2”, “DetailedArmMode”, PARTITION_DEV_NUM)
– SHOW VARIABLES FOR DEBUGGING
luup.log("ThermostatAway- "…state)
luup.log("ThermostatAway- "…detailed_state)
if (state == “Armed”) then
if (detailed_state == “Armed”) then
local status = luup.variable_get( “urn:upnp-org:serviceId:SwitchPower1”, “Status”, THERMOSTAT_DEV) or “0”
if (status == “0”) then
luup.log(“Thermostat already in Energy Saving Mode. Skipping…”)
else
luup.call_action(“urn:wdsc-hvac-org:serviceId:WDSC_HVAC1”, “RestartPolling”,{ delay=0 }, 126)
luup.log("Alarm armed in Away mode, setting Thermostat to Energy Savings Mode.")
luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="0" }, THERMOSTAT_DEV)
luup.call_action("urn:upnp-org:serviceId:IOSPush1", "SendProwlNotification",{ Event= "Thermostat Alert", Description="Thermostat switched to Energy Saving Mode", Priority=1, URL=""}, 20)
luup.call_action("urn:upnp-org:serviceId:IOSPush1", "SendProwlNotification",{ Event= "Thermostat Alert", Description="Thermostat switched to Energy Saving Mode", Priority=1, URL=""}, 41)
end
end
end[/code]