fdegier / homebridge-jablotron-alarm

Homebridge plugin for connecting Jablotron JA-100 alarm systems to Homekit.
The Unlicense
26 stars 6 forks source link

Auto-reversible PGM outputs #62

Closed kominak closed 2 years ago

kominak commented 2 years ago

Jablotron supports auto-reversible PGM outputs that turn back to OFF state after specified amount of time. Example: I turn ON a specified PGM output which triggers opening an entrance gate. After one second the PGM output turns itself OFF. But Home.app still shows this outlet as ON.

It would be great if this behavior can somehow be modelled in Homebridge - either by configuring it manually (thus duplicating the settings), or even better, observe the state of such PGMs automatically as they turn OFF on their own...

Or have I perhaps missed something? :)

Thanks for the great work!

fdegier commented 2 years ago

Hey, good question. I have one PG switch that I use, if the system resets the switch it does reflect in homekit as well. It does take 30 - 60 seconds though. Do you see similar behavior?

kominak commented 2 years ago

Yes, same behavior here - after half a minute or so the state is updated to OFF. So maybe it's a matter of making the fetch (pull) sooner or the timer configurable in certain cases...

fdegier commented 2 years ago

Ok good to hear that it at least functions but not as fast as you are used to when using the native system.

To give a bit more background / context:. In order to make this plugin work there are 2 options:

  1. Hardwire it the alarm system (requires an additional ~100 euro module and some tinkering)
  2. Use the API from the app

Option 1 is inaccessible for a lot of people so I have chosen to go for route 2 as everyone who has a Jablotron system can use this, the downside however is that we need to poll the Jablotron API compared to having a realtime feed. By default the poll interval is 60 seconds, you can off course lower this, but this comes at the risk of increased traffic on Jablotron and perhaps they will implement mitigations.

If you need realtime support then we either need to implement it as an option or you should use another Jablotron plugin, I remember a project that used USB connection. I had also reviewed a bus approach but it was cumbersome and not as rich as the current solution.

kominak commented 2 years ago

Thanks for the explanation. I wonder how much info does the API provide about the PGMs: for instance the duration of the ON state, etc. - in cases such as mine the configuration tool could pre-fill the custom timeout after making a change (switching the PGM), and such a timeout could fire another (explicit) poll on top of the usual regular polling... Just thinking aloud.

But since I realized the state is updated within a minute, I'm quite okay with the current solution. I just wanted to know what's going on - and now I do :) Thanks!

fdegier commented 2 years ago

I haven't looked into details about the PGM, only the state. The API is quite limited but it does provide the most important bits, e.g. state.

What you are describing is possible, it does add quite a bit of complexity though. Personally if you are fine with the 60 second delay, I would prefer to keep it as is for maintainability. If you are willing to make a contribution I'm always happy to discuss and review.

fdegier commented 2 years ago

I tinkered around with the API the last couple of days and didn't find any additional information about the PGM's. Closing this issue for now.