mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +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]:
|
for entry in discovery_info[CONF_BINARY_SENSORS]:
|
||||||
if CONF_HUB in entry:
|
if CONF_HUB in entry:
|
||||||
# from old config!
|
# 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:
|
if CONF_SCAN_INTERVAL not in entry:
|
||||||
entry[CONF_SCAN_INTERVAL] = DEFAULT_SCAN_INTERVAL
|
entry[CONF_SCAN_INTERVAL] = DEFAULT_SCAN_INTERVAL
|
||||||
hub: ModbusHub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]]
|
|
||||||
sensors.append(
|
sensors.append(
|
||||||
ModbusBinarySensor(
|
ModbusBinarySensor(
|
||||||
hub,
|
hub,
|
||||||
|
@ -167,10 +167,11 @@ async def async_setup_platform(
|
|||||||
|
|
||||||
if CONF_HUB in entry:
|
if CONF_HUB in entry:
|
||||||
# from old config!
|
# 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:
|
if CONF_SCAN_INTERVAL not in entry:
|
||||||
entry[CONF_SCAN_INTERVAL] = DEFAULT_SCAN_INTERVAL
|
entry[CONF_SCAN_INTERVAL] = DEFAULT_SCAN_INTERVAL
|
||||||
hub: ModbusHub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]]
|
|
||||||
sensors.append(
|
sensors.append(
|
||||||
ModbusRegisterSensor(
|
ModbusRegisterSensor(
|
||||||
hub,
|
hub,
|
||||||
|
@ -123,8 +123,9 @@ async def async_setup_platform(
|
|||||||
for entry in discovery_info[CONF_SWITCHES]:
|
for entry in discovery_info[CONF_SWITCHES]:
|
||||||
if CONF_HUB in entry:
|
if CONF_HUB in entry:
|
||||||
# from old config!
|
# from old config!
|
||||||
discovery_info[CONF_NAME] = entry[CONF_HUB]
|
hub: ModbusHub = hass.data[MODBUS_DOMAIN][entry[CONF_HUB]]
|
||||||
hub: ModbusHub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]]
|
else:
|
||||||
|
hub: ModbusHub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]]
|
||||||
if entry[CONF_INPUT_TYPE] == CALL_TYPE_COIL:
|
if entry[CONF_INPUT_TYPE] == CALL_TYPE_COIL:
|
||||||
switches.append(ModbusCoilSwitch(hub, entry))
|
switches.append(ModbusCoilSwitch(hub, entry))
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user