Allow same IP if ports are different on modbus ()

pull/55871/head
jan iversen 2021-09-06 22:40:15 +02:00 committed by GitHub
parent 4fa9871080
commit 8d4aac618d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions
homeassistant/components/modbus

View File

@ -248,7 +248,10 @@ def duplicate_modbus_validator(config: list) -> list:
errors = []
for index, hub in enumerate(config):
name = hub.get(CONF_NAME, DEFAULT_HUB)
host = hub[CONF_PORT] if hub[CONF_TYPE] == SERIAL else hub[CONF_HOST]
if hub[CONF_TYPE] == SERIAL:
host = hub[CONF_PORT]
else:
host = f"{hub[CONF_HOST]}_{hub[CONF_PORT]}"
if host in hosts:
err = f"Modbus {name}  contains duplicate host/port {host}, not loaded!"
_LOGGER.warning(err)