Tertiush / ParadoxIP150v2

Python-based IP150 'middle-ware' that uses the IP module's software port for monitoring and control of the alarm via an MQTT Broker.
Eclipse Public License 1.0
73 stars 35 forks source link

stop polling via publish / subscribe #14

Closed arrie closed 7 years ago

arrie commented 7 years ago

So disclaimer: My first time even looking at python!

I added config sections for MQTT user/pass - i'm using rabbitMQ so need that. Also added 2 new settings to auto stop polling, as well as a delay.

Basically subscribing to the events as well, so when that message comes in, I place the "disable polling" message back on the q, only difference being that I flag it with "internal" as the payload. When the message comes back in, i look for the internal flag to do the rest of the processing. Not sure if this is more or less what you had in mind? Just thought that this would be the least intrusive change to your original implementation.

The result is that a login from another system will fail, but raises this trigger in the currently connected system. We can log out, but have to log in again from the other system. The result can be seen below. Seems to do what I expect. image

That being said, it's still not perfect:

  1. It seems that at times there is a bit of a delay on the message, causing you to raise multiple events by trying to log in from another system
  2. My IP150 is currently sitting in an endless loop, connects, does it's thing, waits for events, then randomly the log off comes through - not sure.

Just want to get your thoughts on this approach before I continue.

Tertiush commented 7 years ago

The software logoff only prevents controls from being sent, events will still work. That is why the script performs a log on before doing any controls. There's no need to do a log on everyone the software logs off. In one of the issue someone found an issue with the keep alive packet. In the alarmin app I fixed the packet the software didn't log off anymore. Perhaps try this?