owning an ismartalarm that have no direct api the only way to set it setup inside openhab is ifttt
i ended up coding the following setup:
items:
//ALARM
String Alarm
sitemap
Frame label="Alarm" {
Switch item=Alarm label="Alarm" icon="alarm" mappings=["Arm"="Arm", "Disarm"="Disarm", "Home"="Home"]
}
Basically the alarm have 3 statuses that i replicated in sitemap
i also allowed the Alarm item to be exposed to IFTTT via myopenhab
i also created the 6 actions needed in ifttt (3 that set alarm status from openhab, 3 that write the status to openhab, in case the status is changed from official app or ir command)
The setup work correctly, when i change the status from the openhab app it sends the ifttt command
when i change the status from official app, openhab receive the command (via ifttt)
next i wrote this set of rules to manage the command received from ifttt
rule "Alarm control from IFTTT"
when
Item Alarm received command
then
logInfo("alarm.rules", "command received: "+receivedCommand)
if (receivedCommand.toString == 'Disarm') {
logInfo("alarm.rules", "Command Disarm, status: "+Alarm.state)
if (Alarm.state.toString != 'Disarm') {
Alarm.postUpdate(Disarm)
}
}
else if (receivedCommand.toString == 'Arm') {
logInfo("alarm.rules", "Command Arm, status: "+Alarm.state)
if (Alarm.state.toString != 'Disarm') {
Alarm.postUpdate(Arm)
}
}
else if (receivedCommand.toString == 'Home') {
logInfo("alarm.rules", "Command Home, status: "+Alarm.state)
if (Alarm.state.toString != 'Home') {
Alarm.postUpdate(Home)
}
}
end
basically, it updates the status of the switch in openhab and try not to send the command back, but i still have 2 problems:
setting the status from openhab tooks minutes, that could be ok when i arm, but make it totally useless for disarming! inside IFTTT these applet have the following txt “This Applet usually runs within an hour”
if i set the status from the official app, an ifttt applet is triggered, it talks to openhab, openhab update the switch status and trigger the action again sending it back to ifttt and the to the alarm, the alarm set it again to same status and trigger back again to openhab, but this time my rule find that the command update to the current status, so ignore it. anyway it bounce back 2 times at least… any suggestion to improve the code? i just need that the rule get the command and update switch status, without executing any command
thank you