bryan-bartow / homebridge-alarm.com

Alarm.com plugin for Homebridge
ISC License
43 stars 11 forks source link

Periodically Poll to force update state #32

Open amitgandhinz opened 7 years ago

amitgandhinz commented 7 years ago

The plugin should periodically poll the alarm.com state so that changes in state are notified to the user faster.

Example implementations of Polling behavior can be found in the MyQ plugin here: https://github.com/rainlake/homebridge-platform-myq/blob/master/index.js#L312

Enhancement originally discussed here - https://github.com/bryanbartow/homebridge-alarm.com/issues/28

jdshkolnik commented 6 years ago

@amitgandhinz What are the use cases besides simply wanting to know quicker?

amitgandhinz commented 6 years ago

currently i will set the alarm via my physical control panel, and then leave the house. I won't get the home kit notification for about 15-20 minutes that the alarm system was armed, unless i pop open the home app (or via the control center screen).

I also have triggers set so that when my alarm system is set to Stay/Night mode, it can trigger my lights to turn off etc. However, due to the 15-20 min delay, those don't get activated immediately.

jdshkolnik commented 6 years ago

@amitgandhinz If opening the Home app speeds up the notification time, the issue is probably with Home and not the plugin. I've been with something similar around Homekit triggers. What happens if you leave the Home app running when you set the alarm via physical control panel?

amitgandhinz commented 6 years ago

hi @jdshkolnik , sorry i just saw your response on here. The problem is that when the Home app is open and active on the screen, the Home app will periodically (at a small interval) forces a state refresh which forces the homebridge plugin to get the current state. The updated state is then immediately reflected to Homekit. However, if the Home app is running in the background, then polling happens at random intervals based on either timers in iOS or actions happening on IOS (eg opening the control center or Home app)

Looking at plugins like Liftmaster/MyQ, the homebridge plugin periodically polls for the latest state and that state gets updated to homekit. This causes devices connected to Homekit via iCloud to receive the new state and display notifications, activate triggers, etc.

jhurliman commented 6 years ago

I have this functionality implemented in https://github.com/jhurliman/homebridge-frontpoint, although the login method only supports FrontPoint single sign-on. No logging in to alarm.com directly (yet).

jdshkolnik commented 6 years ago

How will that plugin ultimately differ from this one? @jhurliman

jhurliman commented 6 years ago

@jdshkolnik I created it because it was unclear if this plugin was going to support the FrontPoint single sign-on flow and, more importantly, I wanted to try direct API access rather than the WrapAPI approach. Ultimately I could see the functionality of the two plugins merging, but hopefully using the direct API approach which does not require any special setup, has lower latency, and is more resilient to cosmetic website changes on alarm.com.

I only mention it here because it's not clear if continuous polling of sensor/alarm state is on the roadmap for the homebridge-alarm.com plugin.

bryanbartow commented 6 years ago

I'm BACK! Not really, but I saw this pop up in my Github feed, so I thought I'd chime in. At the time I created this plugin, there was no alarm.com API (at least not a public API). If one exists now, it would obviously make sense to refactor the plugin to use it instead of WrapAPI. The reason I used WrapAPI was that using selenium (or any other headless web driver I tried) was too slow when people would try to run the plugin on Raspberry PI and other lower power devices.

joewilliamsca commented 6 years ago

Hi @jhurliman Do you have any docs, or a link to the front point API? I took a quick look at Alarm.com and I don't see any API that is publicly available.

jhurliman commented 6 years ago

The JSON API used by Alarm.com/FrontPoint is public-facing but has no documentation from what I can tell, since it appears to be built specifically to support their web frontend rather than a generic developer API. I created a standalone node lib wrapping the basic API functionality at https://github.com/jhurliman/node-frontpoint

knaackville commented 6 years ago

Just posting as another user interested in polling. For example, my alarm.com system cannot be integrated with my HomeSeer device directly (besides using email triggers, which has a decently long delay and limits its usefulness). The only thing that works well to integrate and control my security system outside of the native website/app is this plugin, but the current random polling performed by the Home app doesn't allow for consistent triggers, such as turning off lights when arming the system from the panel, or turning on lights when disarmed from the panel in the evening, etc. An option for using polling, such as used by some of the other plugins listed above like the Liftmaster2 plugin, would be great for such cases.

jdshkolnik commented 6 years ago

@jhurliman Is your alternative approach currently having any sign-in issues similar to #67?

jhurliman commented 6 years ago

No, my API wrapper and Homebridge plugin are still working

dswee999 commented 6 years ago

No matter what I try or how long I wait, the home app never updated the status of the alarm unless it is actually controlled from the Home app. If the alarm is disarmed from the keypad or Alarm.com app, the Home app continues to show that it is still armed. I waited over a day, turned phone off and back, restarted homebridge and Home just continued to show that it was armed. I do have the alarm state API bookmarked in the WrapAPI. I have a z-wave door lock attached to my alarm panel. It's status updates fairly immediately I've noticed, however the actual alarm status never updates. Does anyone know if it is something I hav set up wrong?

omarshahine commented 6 years ago

I am having the same problem. The Home app never updates and despite the alarm being in disarmed state, I get a status of "Home" and it thinks my panel is armed. I can send commands such as Off which fixed it temporarily.

jnanes commented 6 years ago

Same here on the lack of updating. The only time my status updates is when the change is made by me using the home app to manually arm/disarm or from an automation doing it. If it is done on the panel the home app never updates , ever :)

mkormendy commented 5 years ago

@jhurliman, well it appears my nodealarmdotcom interface solves the missing direct Alarm.com login we're looking for - it's based off of the work achieved in pyalarmcom.

I've published it to npm under node-alarm-dot-com late last night, but after more research I came across your module and am now excited - your entire implementation is exactly what I was hoping for - its beautiful compared to my hack-job.

I'm thinking of refactoring my project to comparatively look identical to yours but with the native Alarm.com login piece. Since yours deals with authentication through frontpoint, would you think that we fork your project into my npm/github repo with the alarm.com login bindings instead? If so, I'd like to make you a collaborator/admin on both the npm and github repos.

I'd also like to try testing Bryan's mobile site approach to see if that speeds up the responses a little bit more too.

EDIT: I have completed integrating the nodealarmdotcom interface into a fork of jhurlman's homebridge plugin. Anyone can find it here.

amitgandhinz commented 5 years ago

@mkormendy great work on the node implementation. Not sure if you can integrate it with the front point version as my understanding was that front point has a public facing api for their frontend to integrate with, but the rest of alarm.com users don't. Therefore, if you are not a front point customer, you would need to do what pyalarmcom and node-alarm-dot-com does - via web requests.

mkormendy commented 5 years ago

@amitgandhinz that's what I'm proposing:

I'm thinking of refactoring my project to comparatively look identical to yours but with the native Alarm.com login piece. Since yours deals with authentication through frontpoint, would you think that we fork your project into my npm/github repo with the alarm.com login bindings instead?

mkormendy commented 5 years ago

@amitgandhinz check out my implementation that uses node.js and most of @jhurliman's code: https://github.com/mkormendy/homebridge-node-alarm-dot-com