template for managing unresponsive data source on the web
oncleben31 opened this issue · 3 comments
Is your feature request related to a problem? Please describe.
Most of the component are searching data on Internet. Suggesting in the blueprint a best practice to manage when the data source is unresponsive to avoid WARNINGS or ERROR could help the newcomer in plugin development.
Describe the solution you'd like
Open to best practices.
Additional context
N/A
Can you elaborate?
If the service is not responsive the data is not updated, and an error should be thrown.
By using the current example, that will happen.
In the Integration Quality Scale we can read for silver level:
Handles internet unavailable. Log a warning once when unavailable, log once when reconnected.
So I imagine the best practice should be: if the remote data source is unavailable or return an unexpected answer, the python module can raise an error but the component should:
- catch it,
- set the entity to unavailable or keep the previous state only if consistent (keeping weather forecast is consistent, keeping open/close door sensor state is not according to me),
- raise a warning in HA logs
- test regularly if the remote data source issue is solved
- when solved, log it (warning or info level ?), update the entity and resume normal behavior
Does it make sense ?
DataUpdateCoordinator
Does that, which is now implemented in this project