codetwice / homebridge-http-securitysystem

Homebridge plugin that creates a SecuritySystem device which uses configurable HTTP calls to set and get its state.
BSD 2-Clause "Simplified" License
29 stars 17 forks source link

Weird behaviour, several requests are send #23

Open greensouth opened 5 years ago

greensouth commented 5 years ago

I don't know if its an issue on my side, I have an iSmartAlarm system, which only communicates using IFTTT, webhooks and stuff like that.

I've realised that when I send a command (i.e. ARM) to the IFTTT URL which sets the alarm mode, I can hear the alarm system beep a couple or times, instead of one, that makes me think that it's receiving the same command several times.

I don't know if has something to do with the plugin, but I think it's flooding the alarm system with IFTTT commands, making it fail and rebooting my alarm system. Something really weird. It's possible that several command are being send when setting any mode?

I have a PHP script which is launched when IFTTT detects a mode change, and retrieves the Homekit status value (0 to 4) which is read by "readCurrentState". I use it to sync the current status. When every mode is set from the plugin, I activate it using an IFTTT rule, and send a message to a PHP which sets the target.

Had to disable the plugin because today when I tried to disarm with my remote control, the alarm main device was flooded, disconnected and triggered the alarm which I wasn't able to disconnect because the unit lost the connection. Imagine, what a mess unplugging everything in a rush, arrgg!

Excellent job by the way.

codetwice commented 5 years ago

I have never seen anything like this happening. Can you check the Homebridge log to see what's happening there exactly? It logs you every request it makes, you should be seeing something like this:

Oct 9 17:03:10 localhost homebridge[2104]: [10/9/2018, 5:03:10 PM] [Sunny Way security] Target state changed to 1 Oct 9 17:03:10 localhost homebridge[2104]: [10/9/2018, 5:03:10 PM] [Sunny Way security] Polling noticed undefined change to 1, notifying devices Oct 9 17:03:10 localhost homebridge[2104]: [10/9/2018, 5:03:10 PM] [Sunny Way security] Setting state to 1 Oct 9 17:03:10 localhost homebridge[2104]: [10/9/2018, 5:03:10 PM] [Sunny Way security] SetState function succeeded (http://localhost:1880/alarm/setTarget)

Just check how many times it was setting the state when you activated the security system in your Home application. There is no hidden retry or resending at all. If you see one setState but your security system is getting the command 3 times, it's most probably IFTTT sending the command 3 times.