Skip to content

Commit

Permalink
Solve Modbus reload issue (home-assistant#82253)
Browse files Browse the repository at this point in the history
fixes undefined
  • Loading branch information
janiversen authored and balloob committed Nov 20, 2022
1 parent 5ab7c8e commit 6a73406
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 0 additions & 1 deletion homeassistant/components/modbus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,4 +375,3 @@ async def async_reset_platform(hass: HomeAssistant, integration_name: str) -> No
hubs = hass.data[DOMAIN]
for name in hubs:
await hubs[name].async_close()
del hass.data[DOMAIN]
6 changes: 6 additions & 0 deletions homeassistant/components/modbus/modbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ async def async_modbus_setup(

await async_setup_reload_service(hass, DOMAIN, [DOMAIN])

if DOMAIN in hass.data and config[DOMAIN] == []:
hubs = hass.data[DOMAIN]
for name in hubs:
if not await hubs[name].async_setup():
return False

hass.data[DOMAIN] = hub_collect = {}
for conf_hub in config[DOMAIN]:
my_hub = ModbusHub(hass, conf_hub)
Expand Down

0 comments on commit 6a73406

Please sign in to comment.