Allow duplicate names in different modbus entities (#112701)

Allow duplicate names in different entities.
This commit is contained in:
jan iversen 2024-03-08 15:10:35 +01:00 committed by GitHub
parent a033574ee2
commit ea89fa6b1e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 63 additions and 2 deletions

View file

@ -302,13 +302,14 @@ def check_config(config: dict) -> dict:
def validate_entity(
hub_name: str,
component: str,
entity: dict,
minimum_scan_interval: int,
ent_names: set,
ent_addr: set,
) -> bool:
"""Validate entity."""
name = entity[CONF_NAME]
name = f"{component}.{entity[CONF_NAME]}"
addr = f"{hub_name}{entity[CONF_ADDRESS]}"
scan_interval = entity.get(CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL)
if 0 < scan_interval < 5:
@ -369,7 +370,7 @@ def check_config(config: dict) -> dict:
if not validate_modbus(hub, hub_name_inx):
del config[hub_inx]
continue
for _component, conf_key in PLATFORMS:
for component, conf_key in PLATFORMS:
if conf_key not in hub:
continue
entity_inx = 0
@ -378,6 +379,7 @@ def check_config(config: dict) -> dict:
while entity_inx < len(entities):
if not validate_entity(
hub[CONF_NAME],
component,
entities[entity_inx],
minimum_scan_interval,
ent_names,