e-mcgee / paradox_platform

Paradox alarm homebridge platform
25 stars 6 forks source link

Error logging in with updated version #12

Closed thewhitestig closed 6 years ago

thewhitestig commented 6 years ago

Hi, I had been using your plugin for a while and it was a nice addition to my home automation. Thanks! And I was so happy to see there's update to make it more stable and support partition; but when I picked up the update last night, it stopped working. It seems to have trouble logging into the IP100. I have the MG5050 with IP100 as well with 2 partition, password is 8 characters long. Any help would be much appreciated...

Here's the log from startup: [1/26/2018, 5:49:20 PM] [Paradox] Initializing platform accessory 'Alarm 306'... [1/26/2018, 5:49:20 PM] [Paradox] Initializing platform accessory 'Alarm 304'... [1/26/2018, 5:49:20 PM] [Paradox] Initializing platform accessory 'Front Door'... [1/26/2018, 5:49:20 PM] [Paradox] Initializing platform accessory 'Garage Door'... [1/26/2018, 5:49:20 PM] [Paradox] Initializing platform accessory 'Patio Door'... [1/26/2018, 5:49:20 PM] [Paradox] Initializing platform accessory 'Basemnt Motion'... [1/26/2018, 5:49:20 PM] [Paradox] Initializing platform accessory 'Main Motion'... [1/26/2018, 5:49:20 PM] [Paradox] Initializing platform accessory 'Basement Windows'...

[1/26/2018, 5:49:24 PM] [Paradox] Error logging in [1/26/2018, 5:49:24 PM] [Paradox] Cannot get status - not logged in [1/26/2018, 5:49:24 PM] [Paradox] Cannot get status - not logged in [1/26/2018, 5:49:24 PM] [Paradox] Getting Status - Connected to alarm! [1/26/2018, 5:49:24 PM] [Paradox] 170 [1/26/2018, 5:49:24 PM] [Paradox] 25 [1/26/2018, 5:49:24 PM] [Paradox] 0 [1/26/2018, 5:49:24 PM] [Paradox] 1 [1/26/2018, 5:49:24 PM] [Paradox] Cannot set Alarm - not logged in [1/26/2018, 5:49:24 PM] [Paradox] Cannot set Alarm - not logged in [1/26/2018, 5:49:29 PM] [Paradox] Mute : [false] [1/26/2018, 5:49:29 PM] [Paradox] Logging in [1/26/2018, 5:49:29 PM] [Paradox] Cannot get status - not logged in [1/26/2018, 5:49:29 PM] [Paradox] Got status [1/26/2018, 5:49:29 PM] [Paradox] Results: [1/26/2018, 5:49:29 PM] [Paradox] Zone 0 off (Front Door) [1/26/2018, 5:49:29 PM] [Paradox] Zone 1 off (Garage Door) [1/26/2018, 5:49:29 PM] [Paradox] Zone 2 off (Patio Door) [1/26/2018, 5:49:29 PM] [Paradox] Zone 5 off (Basemnt Motion) [1/26/2018, 5:49:29 PM] [Paradox] Zone 6 off (Main Motion) [1/26/2018, 5:49:29 PM] [Paradox] Zone 7 off (Basement Windows) [1/26/2018, 5:49:29 PM] [Paradox] Alarmstatus :Disarmed [1/26/2018, 5:49:29 PM] [Paradox] Alarmstatus :Disarmed [1/26/2018, 5:49:29 PM] [Paradox] Log in successfull [1/26/2018, 5:49:39 PM] [Paradox] Mute : [false] [1/26/2018, 5:49:39 PM] [Paradox] Geting Status... [1/26/2018, 5:49:39 PM] [Paradox] Got status [1/26/2018, 5:49:39 PM] [Paradox] Results: [1/26/2018, 5:49:39 PM] [Paradox] Zone 0 off (Front Door) [1/26/2018, 5:49:39 PM] [Paradox] Zone 1 off (Garage Door) [1/26/2018, 5:49:39 PM] [Paradox] Zone 2 off (Patio Door) [1/26/2018, 5:49:39 PM] [Paradox] Zone 5 off (Basemnt Motion) [1/26/2018, 5:49:39 PM] [Paradox] Zone 6 off (Main Motion) [1/26/2018, 5:49:39 PM] [Paradox] Zone 7 off (Basement Windows) [1/26/2018, 5:49:39 PM] [Paradox] Alarmstatus :Disarmed [1/26/2018, 5:49:39 PM] [Paradox] Alarmstatus :Disarmed [1/26/2018, 5:49:39 PM] [Paradox] Statusses: [1/26/2018, 5:49:39 PM] [Paradox] { status: 'Disarmed' } [1/26/2018, 5:49:39 PM] [Paradox] { status: 'Disarmed' } [1/26/2018, 5:49:49 PM] [Paradox] Mute : [false] [1/26/2018, 5:49:49 PM] [Paradox] Logging in [1/26/2018, 5:49:49 PM] [Paradox] Cannot get status - not logged in [1/26/2018, 5:49:49 PM] [Paradox] Got status
e-mcgee commented 6 years ago

Hi, I had a similar issue and updated the login code slightly to try and resolve this. Try the latest version. When it fails to login you simply have to restart homebridge so that it corrects the login. However, with the latest version I hope to have it self correct when this happens. Let me know if you have further issues. I am also currently busy to try and implement a switch control that will log out of the alarm and allow 3rd party apps such as iParadox to work. This is work in progress and there will be new versions coming out.

e-mcgee commented 6 years ago

I think I found the issue. If for whatever reason the connection to the alarm fails the code closes the node.js connection to the alarm. The status loop however then picks up it is not connected and try to log in again. However since the node.js connection was teared down the login will never succeed and this the endless failed login messages you saw. If you restarted homebridge it would have corrected again. I now recreate the node.js connection before attempting to log in again and it works robustly now so you should not have these issues again. I also now added a switch control to disable login to the alarm and reenable it again. This is useful if you want to use other apps to connect to the alarm such as iParadox. Let me know if you have any more issues.

thewhitestig commented 6 years ago

Thanks for looking into it quickly! I picked up your latest change but still having the login issue, so I spent some time and compare the changes made since last summer (that's when I originally installed the plugin). I noticed that there used to be a 600ms sleep between writing and checking the buffer in _login function which is now replaced by a timeout. So as an experiment, I put that sleep(600) back in and it works! After some fine tuning, it seems like 400ms is the sweet spot for my setup and now it's working nicely with 2 partition. Arming and Disarming alarm happens pretty much instantly. Though having a sleep in _login function may not be very efficient but I think in my case it would have taken 400ms for IP100 to respond anyway. BTW, I've also tried the connect switch, that's working nicely too! Well done!

e-mcgee commented 6 years ago

Great to hear. Yes, sleep is a blocking function that creates issues if other node processes are used in conjunction with homebridge. It basically impacts the execution loop in Node that impacts all running processes Node processes, Other users have had such issues. So remember this should you run other processes such as Node-Red etc. I should perhaps in future make all the timeouts parameters in the platform so that users can tweak as they require. I will also try and improve error checking as wit this particular issue. Hope you enjoy it. Mine is working very well at the moment.

e-mcgee commented 6 years ago

Hi,

I just published a new version (254) where you can tune all the delays in your config.json file. See the wiki and sample config.json file for details.

thewhitestig commented 6 years ago

Thanks! I've just tried your latest update this weekend, setting logindelay to 400 works nicely in my setup.