MnrGreg / homebridge-paradox-security-system

Homebridge iOS HomeKit Accessory plugin to control your Paradox Alarm System
Apache License 2.0
20 stars 9 forks source link

On receiving of mqtt message, perform immediate CurrentState check. #2

Open MnrGreg opened 7 years ago

MnrGreg commented 7 years ago

Currently CurrentState is only checked when opening the Home App. This means the iOS status change notification is not received immediately.

MnrGreg commented 7 years ago

Testing this plugin out with the Paradox MG5050 panel for the first time. Seems the IP150 Python script does not publish alarm state information to Paradox/C/ topic but rather only the Paradox/Events topic. Will need to change this Homebridge Plugin to monitor the Events topic in order to determine current alarm state.

Minimiller commented 7 years ago

I'm watching the development of this plugin with keen interest - thanks. The previous version has been running successfully but when I installed l.2.0 I picked up an error. Homebridge initialises and the plugin loads into Homekit but it returns "Getting Target State" and then "Not a valid Homekit State: undefined". I think the installation and dependencies etc. should be ok because nothing else has changed.

MnrGreg commented 7 years ago

Hi Minimiller, in the new version this is by design. Homebridge-Paradox will have an unresponsive status until the alarm panel and IP150 script publishes an initial state event onto the MQTT queue. Thereafter one can change state via either your panel or homekit, and both will stay in sync. If you're testing this without an IP150 module, you can simulate the initial state from the panel by publishing an event manually with: mosquitto_pub -t "Paradox/Events" -m "Event:Partition status;SubEvent:Disarm partition" In future versions I'll took at setting the state to disarmed on initial startup, so as to avoid the unresponsive state.

Thanks for testing it out. I'm glad there is some appreciation for this. I've also managed to incorporate the Paradox Events for individual Zones into the HomeKit as ContactSensor accessories. i.e. one can see which doors or windows are open. I'll clean this up and upload the code when I get a chance.

Minimiller commented 7 years ago

Hi MnrGreg. Thanks for the direction. I'm using an IP150 module with an MG5050 and am running Homebridge on a Raspberry Pi B+. I've got two plugins on the Homebridge, the Harmony Hub and your Paradox Security plugin. Both load successfully and when I activate a zone on the alarm system it does show on the Pi as an "mqtt Alarm State message received: Event:Zone open;Subevent:TV ROOM". Then I add an accessory to Homekit on my iPad and add the Homebridge including its Platform and Accessory. Once everything is loaded on Homekit the Pi returns "Not a valid Homekit State: undefined" on the terminal window. Homekit returns a "No Response" message on the alarm icon whereas the Harmony Hub accessories are working fine. Thanks again.

MnrGreg commented 7 years ago

“Event:Zone open;Subevent:TV ROOM” would be a Zone state. The Homebridge-Paradox will be looking for the overall Alarm state. i.e. your panel should produce one of the below when arming or disarming the partition.

    Paradox Stay -> "Event:Non-reportable event;SubEvent:Arm in stay mode"
    Paradox Arm -> "Event:Partition status;SubEvent:Arm partition"
    Paradox Off -> "Event:Partition status;SubEvent:Disarm partition"

Good luck.

From: Minimiller Sent: ‎Monday‎, ‎06‎ ‎February‎ ‎2017 ‎11‎:‎12‎ ‎PM To: MnrGreg/homebridge-paradox-security-system Cc: Gregory May, Author

Hi MnrGreg. Thanks for the direction. I'm using an IP150 module with an MG5050 and am running Homebridge on a Raspberry Pi B+. I've got two plugins on the Homebridge, the Harmony Hub and your Paradox Security plugin. Both load successfully and when I activate a zone on the alarm system it does show on the Pi as an "mqtt Alarm State message received: Event:Zone open;Subevent:TV ROOM". Then I add an accessory to Homekit on my iPad and add the Homebridge including its Platform and Accessory. Once everything is loaded on Homekit the Pi returns "Not a valid Homekit State: undefined" on the terminal window. Homekit returns a "No Response" message on the alarm icon whereas the Harmony Hub accessories are working fine. Thanks again.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

Minimiller commented 7 years ago

Homekit/Siri is now working. My mistake was that I was adding the alarm accessory to Apple Homekit before 'initialising' the Homebridge by Stay-Arming the MG5050.
Thanks.

micdamb commented 7 years ago

Hi Minimiller, What does it mean "'initialising' the Homebridge by Stay-Arming the MG5050"? I think I have the same problem. Can You Help Me? The problem is inside the file Config.json? Now I'm using Homebridge for Bticino Myhome Control. { "accessory": "Homebridge-Paradox", "name": "Alarm System", "mqttusername": "", "mqttpassword": "", "mqttserver": "mqtt://localhost", "controltopic": "Paradox/C/P1", "statetopic": "Paradox/Events", "stayevent": "Event:Non-reportable event;SubEvent:Arm in stay mode", "armevent": "Event:Partition status;SubEvent:Arm partition", "disarmevent": "Event:Partition status;SubEvent:Disarm partition", "triggeredevent": "" } Have you got an example? Thanks a lot.

micdamb commented 7 years ago

Hi MnrGreg, Can You help me? Minimiller said that the mistake was that that he was adding the alarm accessory to Apple Homekit before 'initialising' the Homebridge by Stay-Arming the MG5050. What does it mean? Thanks.

MnrGreg commented 7 years ago

When the HomeBridge Paradox starts up it will remain in an unresponsive/unknown state until it receives the first alarm state event on the MQTT queue. On can ensure that there is an event on the queue by starting up your MQTT server as well as the IP150 Python script and either ARMing or DISARMing your Paradox Alarm panel, before starting HomeBridge.

Alternatively, simply DISARM or ARM your Paradox Alarm, either via the Paradox IP150 module website or your Paradox alarm keypad, within a few seconds of starting HomeBridge.

The shortcoming here is that HomeBridge Paradox is not able to query the Alarm Panel state directly. It can set/change/write a new state directly but not read state. It relies on the IP150 script to monitor the Alarm Events and put them on the MQTT queue from which it will determine the states going forward.

On 15 Feb 2017, at 3:32 PM, micdamb notifications@github.com wrote:

Hi MnrGreg, Can You help me? Minimiller said that the mistake was that that he was adding the alarm accessory to Apple Homekit before 'initialising' the Homebridge by Stay-Arming the MG5050. What does it mean? Thanks.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/MnrGreg/homebridge-paradox-security-system/issues/2#issuecomment-280011167, or mute the thread https://github.com/notifications/unsubscribe-auth/AXQk00WJ6ts9jWOs1pnLbIuhOTloKYTsks5rcv5WgaJpZM4LY3lZ.

merlinmb commented 7 years ago

Thanks for an awesome implementation. Although not technically the right approach, would it not be preferable to default to a preconfigured state on startup, say Disarmed? Due to the potential for homebrew to crash and restart - mainly due to other faulty accessory/ configuration - would you prefer we post updates to the IP150 py script, for this default state?

On 15 Feb 2017, at 22:05, Gregory May notifications@github.com wrote:

When the HomeBridge Paradox starts up it will remain in an unresponsive/unknown state until it receives the first alarm state event on the MQTT queue. On can ensure that there is an event on the queue by starting up your MQTT server as well as the IP150 Python script and either ARMing or DISARMing your Paradox Alarm panel, before starting HomeBridge.

Alternatively, simply DISARM or ARM your Paradox Alarm, either via the Paradox IP150 module website or your Paradox alarm keypad, within a few seconds of starting HomeBridge.

The shortcoming here is that HomeBridge Paradox is not able to query the Alarm Panel state directly. It can set/change/write a new state directly but not read state. It relies on the IP150 script to monitor the Alarm Events and put them on the MQTT queue from which it will determine the states going forward.

On 15 Feb 2017, at 3:32 PM, micdamb notifications@github.com wrote:

Hi MnrGreg, Can You help me? Minimiller said that the mistake was that that he was adding the alarm accessory to Apple Homekit before 'initialising' the Homebridge by Stay-Arming the MG5050. What does it mean? Thanks.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/MnrGreg/homebridge-paradox-security-system/issues/2#issuecomment-280011167, or mute the thread https://github.com/notifications/unsubscribe-auth/AXQk00WJ6ts9jWOs1pnLbIuhOTloKYTsks5rcv5WgaJpZM4LY3lZ.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

micdamb commented 7 years ago

Hi MnrGreg. I cannot run the plugin paradox with homekit. Maybe I'm wrong change my files config.json. Can you help me modify it by inserting even the lines for the plugin Paradox? This is my actually file:

{ "bridge": { "name": "Homebridge2", "username": "CC:22:3D:E3:CE:31", "port": 51826, "pin": "031-45-154" },

"description": "This iwn.",

"accessories": [
],

"platforms": [
    {
     "platform": "MyHome",              
     "name": "MyHome",                  
     "host": "http://127.0.0.1:3000", 
     "serial": "1",

     "accessories":[
        {"type":"Lightbulb", "name": "Plafoniera Cucina","address": 12, "can_dim": false},
        {"type":"Lightbulb", "name": "Tavolo Soggiorno","address": 11, "can_dim": false}
      ]
    }
]

}

MnrGreg commented 7 years ago

@merlinmb the index.js has been modified to assume the current alarm state is Disarmed during start up. This will mean the HomeKit Alarm Accessory will no longer have an undefined/'no response' state when HomeBridge first starts.

MnrGreg commented 7 years ago

Use a JSON code editor. vs-code is free, supported on most platforms and very flexible.

On 16 Feb 2017, at 1:26 AM, micdamb notifications@github.com wrote:

Hi MnrGreg. I cannot run the plugin paradox with homekit. Maybe I'm wrong change my files config.json. Can you help me modify it by inserting even the lines for the plugin Paradox? This is my actually file:

{ "bridge": { "name": "Homebridge2", "username": "CC:22:3D:E3:CE:31", "port": 51826, "pin": "031-45-154" },

"description": "This iwn.",

"accessories": [ ],

"platforms": [ { "platform": "MyHome",
"name": "MyHome",
"host": "http://127.0.0.1:3000", "serial": "1",

 "accessories":[
  {"type":"Lightbulb", "name": "Plafoniera Cucina","address": 12, "can_dim": false},
  {"type":"Lightbulb", "name": "Tavolo Soggiorno","address": 11, "can_dim": false}
]

} ] }

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/MnrGreg/homebridge-paradox-security-system/issues/2#issuecomment-280175402, or mute the thread https://github.com/notifications/unsubscribe-auth/AXQk06e88k6xqDYbgeMyiHl5wLkTc4vVks5rc4m4gaJpZM4LY3lZ.