vinteo / hass-opensprinkler

OpenSprinkler Integration for Home Assistant
MIT License
204 stars 40 forks source link

Incorrect unavailable handling #293

Closed bob-tm closed 3 weeks ago

bob-tm commented 2 months ago

Hi,

I have regular blackouts and integration do not correctly handle it.

logbook Let's look to an example 8.12.30 - blackout 8.12.44 - it's unavailable with "Timeout fetching OpenSprinkler resource status data" message. 8.13.28 - it's alive with "Fetching OpenSprinkler resource status data recovered", but it's impossible. Still zero power. log1

"Timeout fetching OpenSprinkler resource status data" it's very rare message. When I saw it - unavailable handled correctly. But when there are: "Finished fetching OpenSprinkler resource status data in 10.003 seconds (success: False)", "Cannot connect to controller", everything is showed as "online"

Second strange thing: there is 10 sec timeouts with 5 seconds SCAN_INTERVAL. Looks like it should be less than SCAN_INTERVAL. log2 Another situation with "Fetching OpenSprinkler resource status data recovered" while there is total blackout

My current dirty solution - full reload OpenSprinkler integration on each blackout.

log3 Now it's powered. Example in logs for short unavailable case. For this case I suggest count timeouts. For example if there is two continues timeouts - then change availability attribute or reset timeout counter.

bob-tm commented 1 month ago

Seems like reducing timeout from 10 sec to 3sec helps with unavailable while blackout.

functionpointer commented 4 weeks ago

My OpenSprinkler got OOM killed. The integration remained mostly available, despite numerous errors:

Aug 01 09:40:00 netberry hass[418]: 2024-08-01 09:40:00.779 ERROR (MainThread) [custom_components.opensprinkler] Cannot connect to controller
Aug 01 09:40:05 netberry hass[418]: 2024-08-01 09:40:05.917 INFO (MainThread) [backoff] Backing off _request_http(...) for 0.1s (pyopensprinkler.OpenSprinklerConnectionError: Cannot connect to controller)
Aug 01 09:40:06 netberry hass[418]: 2024-08-01 09:40:06.031 INFO (MainThread) [backoff] Backing off _request_http(...) for 0.5s (pyopensprinkler.OpenSprinklerConnectionError: Cannot connect to controller)
Aug 01 09:40:06 netberry hass[418]: 2024-08-01 09:40:06.517 ERROR (MainThread) [backoff] Giving up _request_http(...) after 3 tries (pyopensprinkler.OpenSprinklerConnectionError: Cannot connect to controller)
Aug 01 09:40:06 netberry hass[418]: 2024-08-01 09:40:06.517 ERROR (MainThread) [custom_components.opensprinkler] Cannot connect to controller
Aug 01 09:40:10 netberry hass[418]: 2024-08-01 09:40:10.940 INFO (MainThread) [backoff] Backing off _request_http(...) for 0.9s (pyopensprinkler.OpenSprinklerConnectionError: Cannot connect to controller)
Aug 01 09:40:11 netberry hass[418]: 2024-08-01 09:40:11.889 INFO (MainThread) [backoff] Backing off _request_http(...) for 0.5s (pyopensprinkler.OpenSprinklerConnectionError: Cannot connect to controller)
Aug 01 09:40:12 netberry hass[418]: 2024-08-01 09:40:12.345 ERROR (MainThread) [backoff] Giving up _request_http(...) after 3 tries (pyopensprinkler.OpenSprinklerConnectionError: Cannot connect to controller)
Aug 01 09:40:12 netberry hass[418]: 2024-08-01 09:40:12.345 ERROR (MainThread) [custom_components.opensprinkler] Cannot connect to controller
Aug 01 09:40:16 netberry hass[418]: 2024-08-01 09:40:16.917 INFO (MainThread) [backoff] Backing off _request_http(...) for 0.5s (pyopensprinkler.OpenSprinklerConnectionError: Cannot connect to controller)
Aug 01 09:40:17 netberry hass[418]: 2024-08-01 09:40:17.453 INFO (MainThread) [backoff] Backing off _request_http(...) for 1.5s (pyopensprinkler.OpenSprinklerConnectionError: Cannot connect to controller)

grafik

This is bad because it defeats my monitoring system, which notifies me when something is "unavailable" for an extended period of time. This runs the risk of my plants not getting water, because i don't notice when OpenSprinkler fails!