Skip to content

Commit

Permalink
Merge pull request #790 from wrfz/main
Browse files Browse the repository at this point in the history
Fix adding Solax integration without HA restart
  • Loading branch information
wills106 authored Mar 5, 2024
2 parents 01b8146 + 767283b commit 627818d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions custom_components/solax_modbus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Register the hub."""
hass.data[DOMAIN][name] = { "hub": hub, }

# Tests on some systems have shown that establishing the Modbus connection
# Tests on some systems have shown that establishing the Modbus connection
# can occasionally lead to errors if Home Assistant is not fully loaded.
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, hub.async_init())
if hass.is_running:
await hub.async_init()
else:
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, hub.async_init())

entry.async_on_unload(entry.add_update_listener(config_entry_update_listener))
return True
Expand Down

0 comments on commit 627818d

Please sign in to comment.