mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Fix modbus switch "old style" config problem (#49352)
Fix that using CONF_HUB in switch, changed the hub for all subsequent switches.
This commit is contained in:
parent
a5806b59f2
commit
8acc3f0b03
@ -89,10 +89,11 @@ async def async_setup_platform(
|
||||
for entry in discovery_info[CONF_BINARY_SENSORS]:
|
||||
if CONF_HUB in entry:
|
||||
# from old config!
|
||||
discovery_info[CONF_NAME] = entry[CONF_HUB]
|
||||
hub: ModbusHub = hass.data[MODBUS_DOMAIN][entry[CONF_HUB]]
|
||||
else:
|
||||
hub: ModbusHub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]]
|
||||
if CONF_SCAN_INTERVAL not in entry:
|
||||
entry[CONF_SCAN_INTERVAL] = DEFAULT_SCAN_INTERVAL
|
||||
hub: ModbusHub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]]
|
||||
sensors.append(
|
||||
ModbusBinarySensor(
|
||||
hub,
|
||||
|
@ -167,10 +167,11 @@ async def async_setup_platform(
|
||||
|
||||
if CONF_HUB in entry:
|
||||
# from old config!
|
||||
discovery_info[CONF_NAME] = entry[CONF_HUB]
|
||||
hub: ModbusHub = hass.data[MODBUS_DOMAIN][entry[CONF_HUB]]
|
||||
else:
|
||||
hub: ModbusHub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]]
|
||||
if CONF_SCAN_INTERVAL not in entry:
|
||||
entry[CONF_SCAN_INTERVAL] = DEFAULT_SCAN_INTERVAL
|
||||
hub: ModbusHub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]]
|
||||
sensors.append(
|
||||
ModbusRegisterSensor(
|
||||
hub,
|
||||
|
@ -123,8 +123,9 @@ async def async_setup_platform(
|
||||
for entry in discovery_info[CONF_SWITCHES]:
|
||||
if CONF_HUB in entry:
|
||||
# from old config!
|
||||
discovery_info[CONF_NAME] = entry[CONF_HUB]
|
||||
hub: ModbusHub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]]
|
||||
hub: ModbusHub = hass.data[MODBUS_DOMAIN][entry[CONF_HUB]]
|
||||
else:
|
||||
hub: ModbusHub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]]
|
||||
if entry[CONF_INPUT_TYPE] == CALL_TYPE_COIL:
|
||||
switches.append(ModbusCoilSwitch(hub, entry))
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user