envy / knxsync

Home Assistant custom component to easily sync HA entities to KNX
3 stars 0 forks source link

Reload knxsync when knx reloads #3

Open envy opened 1 year ago

envy commented 1 year ago

There is no direct way to find out when an integration reloads. But we can register ourselves on service_registered and service_removed to figure out if the knx services still exist.

https://www.home-assistant.io/docs/configuration/events/

idea: when service is removed, switch into failed state, restart automatically and on start check if services are there and if not, go into failed state again

farmio commented 1 year ago

Have a look at https://github.com/home-assistant/core/blob/cb7fa494a432dbcf004b5ffd6e3027cef3c9ed11/homeassistant/components/knx/__init__.py#L319 This seems to be the standard way when reloading via DevTools/YAML. I'm not sure if it is the same for the config entry reload.

service_removed for knx.send should work in all cases.

Or you observe one of the Interface entity states. They should turn "unavailable" when disconnected (which should, but may not only happen on reload).