ParadoxAlarmInterface / pai

Paradox Magellan, Spectra and EVO, with MQTT, Signal, Pushbullet, Pushover and others
https://gitter.im/paradox-alarm-interface
Eclipse Public License 2.0
337 stars 90 forks source link

Home Assistant integration briefly stopping and reconnecting every few minutes #441

Closed drzoidberg33 closed 4 months ago

drzoidberg33 commented 4 months ago

Alarm system

MG5050 + ESP32 Serial -> IP

MG5050 Firmware: 7.21 build 0

Environment

Home Assistant Addon

Git branch

Tag 3.4.0

Question

I'm not so much sure if this is a bug or a misconfiguration in my setup somewhere, so I'll start with a question.

So basically everything is working 99% of the time just fine (πŸ‘ ) but if I look at the history of the PAI service in Home Assistant I see that it goes offline briefly numerous times at seemingly random intervals, see the state history below:

image

Raw csv entries look like this:

entity_id,state,last_changed
sensor.mg5050_pai_status,online,2024-02-28T22:00:00.000Z
sensor.mg5050_pai_status,stopped,2024-02-28T22:07:10.378Z
sensor.mg5050_pai_status,initializing,2024-02-28T22:07:10.428Z
sensor.mg5050_pai_status,connected,2024-02-28T22:07:17.775Z
sensor.mg5050_pai_status,online,2024-02-28T22:07:41.900Z
sensor.mg5050_pai_status,stopped,2024-02-28T22:34:01.854Z
sensor.mg5050_pai_status,initializing,2024-02-28T22:34:01.909Z
sensor.mg5050_pai_status,connected,2024-02-28T22:34:11.267Z
sensor.mg5050_pai_status,online,2024-02-28T22:34:39.394Z
sensor.mg5050_pai_status,stopped,2024-02-28T23:34:28.320Z
sensor.mg5050_pai_status,initializing,2024-02-28T23:34:28.370Z
sensor.mg5050_pai_status,connected,2024-02-28T23:34:37.725Z
sensor.mg5050_pai_status,online,2024-02-28T23:35:00.744Z
sensor.mg5050_pai_status,stopped,2024-02-28T23:42:27.339Z
sensor.mg5050_pai_status,initializing,2024-02-28T23:42:27.393Z
sensor.mg5050_pai_status,connected,2024-02-28T23:42:35.089Z
sensor.mg5050_pai_status,online,2024-02-28T23:42:52.181Z
sensor.mg5050_pai_status,stopped,2024-02-29T00:04:09.809Z
sensor.mg5050_pai_status,initializing,2024-02-29T00:04:09.861Z
sensor.mg5050_pai_status,connected,2024-02-29T00:04:17.168Z
sensor.mg5050_pai_status,online,2024-02-29T00:04:41.885Z
sensor.mg5050_pai_status,stopped,2024-02-29T00:35:26.323Z
sensor.mg5050_pai_status,initializing,2024-02-29T00:35:26.373Z
sensor.mg5050_pai_status,connected,2024-02-29T00:35:34.742Z
sensor.mg5050_pai_status,online,2024-02-29T00:35:55.499Z
sensor.mg5050_pai_status,stopped,2024-02-29T01:36:29.911Z

Does anyone know why this could possibly be happening and anywhere else I could look to try and get more info?

As I brought up here (https://github.com/ParadoxAlarmInterface/pai/issues/126#issuecomment-1967455083) I'm getting my logs spammed constantly with this error "PAI.paradox.lib.handlers - No handler for message 5" this is happening continuously and not just at certain intervals like other have reported, mine is logging this like every second of every day.

That might be a clue, but I'm also not sure it's related as looking at the code these messages just get ignored but maybe it's some memory pressure issue due to the amount getting logged? I'm not familiar with how the logging works though so just spitballing.

Any clues would be appreciated πŸ™‡

Logs (if required)

yozik04 commented 4 months ago

I do not remember if I made timeout configurable. Try to raise it.

drzoidberg33 commented 4 months ago

I do not remember if I made timeout configurable. Try to raise it.

Is this the timeout you're referring to? https://github.com/ParadoxAlarmInterface/pai/blob/77a372863f2321bc3dd9698d7055e785e8ff4a0f/paradox/lib/handlers.py#L93C15-L93C34

I can play around with it and see if it makes any difference.

yozik04 commented 4 months ago

https://github.com/ParadoxAlarmInterface/pai/blob/77a372863f2321bc3dd9698d7055e785e8ff4a0f/paradox/paradox.py#L367

0.5 seconds is default, I think.

drzoidberg33 commented 4 months ago

Thanks, now that I have it debugging locally I can disable those unknown event errors and see what's being logged.

I am seeing a lot of retries, e.g:

2024-03-01 10:33:29,215 - DEBUG    - MainThread - PAI.paradox.paradox - Request retry (attempt 3/5)
2024-03-01 10:33:33,218 - DEBUG    - MainThread - PAI.paradox.paradox - Request retry (attempt 4/5)

And I see if this goes over 5 then it restarts, which would explain the reconnecting issue I'm seeing in Home Assistant.

Increasing the timeout to 2 I still see retries but it doesn't seem to get to the point where it exceeds the retries, so it's not restarting anymore (from my brief time testing it).

I'll open a PR to make this timeout configurable, thanks for your help!

drzoidberg33 commented 4 months ago

Okay after some more testing I don't think changing the timeout will really help. The problem does in fact appear to be that the Olarm Pro device that I'm connecting through is what's causing the problem. If I connect directly to the MG5050 serial pins I don't get any errors.

Now I need to decide whether to ditch the Olarm or risk getting a MG5050+ board and hope it has the older firmware without the serial encryption.

Going to close this issue now, thanks for the help!

yozik04 commented 4 months ago

IP150 module works very well in my case.

drzoidberg33 commented 4 months ago

I had my MG5050+ panel installed today, after first locking it up due to too many incorrect PC password attempts I was able to get it working with the help of point 3 here: https://github.com/ParadoxAlarmInterface/pai/wiki/FAQ#authentication-failed-wrong-password

I wasn't able to see how long the code lockout lasted as I had my security company restart the panel and unlock it (it already had been over 4 hours being locked out, so my guess it would have been 24 hours).

Updated the compatibility list with notes: https://github.com/ParadoxAlarmInterface/pai/wiki/Compatibility/_compare/5d0504f63594fcbf04aef66464013bef8873e3b4...08d895b28f1ed1cd2774c072133feeffe0c42ec5

yozik04 commented 4 months ago

Thank you!

yozik04 commented 3 months ago

Thanks, now that I have it debugging locally I can disable those unknown event errors and see what's being logged.

I am seeing a lot of retries, e.g:

2024-03-01 10:33:29,215 - DEBUG    - MainThread - PAI.paradox.paradox - Request retry (attempt 3/5)
2024-03-01 10:33:33,218 - DEBUG    - MainThread - PAI.paradox.paradox - Request retry (attempt 4/5)

And I see if this goes over 5 then it restarts, which would explain the reconnecting issue I'm seeing in Home Assistant.

Increasing the timeout to 2 I still see retries but it doesn't seem to get to the point where it exceeds the retries, so it's not restarting anymore (from my brief time testing it).

I'll open a PR to make this timeout configurable, thanks for your help!

I have added IO_TIMEOUT setting.