diff --git a/custom_components/eltako/binary_sensor.py b/custom_components/eltako/binary_sensor.py index 2b3df36..fec83ff 100644 --- a/custom_components/eltako/binary_sensor.py +++ b/custom_components/eltako/binary_sensor.py @@ -52,9 +52,12 @@ async def async_setup_entry( entities.append(GatewayConnectionState(platform, gateway)) # dev_id validation not possible because there can be bus sensors as well as decentralized sensors. - new_entities = config_helpers.filter_for_new_entities(er.async_get(hass), entities) - log_entities_to_be_added(new_entities, platform) - async_add_entities(new_entities) + log_entities_to_be_added(entities, platform) + try: + async_add_entities(entities) + except ValueError as e: + if str(e) != "Config entry has already been setup!": + raise e class AbstractBinarySensor(EltakoEntity, RestoreEntity, BinarySensorEntity): diff --git a/custom_components/eltako/button.py b/custom_components/eltako/button.py index 9fff67d..dc58d3a 100644 --- a/custom_components/eltako/button.py +++ b/custom_components/eltako/button.py @@ -65,9 +65,12 @@ async def async_setup_entry( entities.append(GatewayReconnectButton(platform, gateway)) validate_actuators_dev_and_sender_id(entities) - new_entities = config_helpers.filter_for_new_entities(er.async_get(hass), entities) - log_entities_to_be_added(new_entities, platform) - async_add_entities(new_entities) + log_entities_to_be_added(entities, platform) + try: + async_add_entities(entities) + except ValueError as e: + if str(e) != "Config entry has already been setup!": + raise e diff --git a/custom_components/eltako/climate.py b/custom_components/eltako/climate.py index c214e13..1f83f98 100644 --- a/custom_components/eltako/climate.py +++ b/custom_components/eltako/climate.py @@ -79,9 +79,12 @@ async def async_setup_entry( continue validate_actuators_dev_and_sender_id(entities) - new_entities = config_helpers.filter_for_new_entities(er.async_get(hass), entities) - log_entities_to_be_added(new_entities, platform) - async_add_entities(new_entities) + log_entities_to_be_added(entities, platform) + try: + async_add_entities(entities) + except ValueError as e: + if str(e) != "Config entry has already been setup!": + raise e def validate_ids_of_climate(entities:list[EltakoEntity]): diff --git a/custom_components/eltako/cover.py b/custom_components/eltako/cover.py index 8b0a51b..5bd789b 100644 --- a/custom_components/eltako/cover.py +++ b/custom_components/eltako/cover.py @@ -52,9 +52,12 @@ async def async_setup_entry( validate_actuators_dev_and_sender_id(entities) - new_entities = config_helpers.filter_for_new_entities(er.async_get(hass), entities) - log_entities_to_be_added(new_entities, platform) - async_add_entities(new_entities) + log_entities_to_be_added(entities, platform) + try: + async_add_entities(entities) + except ValueError as e: + if str(e) != "Config entry has already been setup!": + raise e class EltakoCover(EltakoEntity, CoverEntity, RestoreEntity): """Representation of an Eltako cover device.""" diff --git a/custom_components/eltako/datetime.py b/custom_components/eltako/datetime.py index a3da5e0..04b95a5 100644 --- a/custom_components/eltako/datetime.py +++ b/custom_components/eltako/datetime.py @@ -37,9 +37,12 @@ async def async_setup_entry( entities.append(GatewayLastReceivedMessage(platform, gateway)) validate_actuators_dev_and_sender_id(entities) - new_entities = config_helpers.filter_for_new_entities(er.async_get(hass), entities) - log_entities_to_be_added(new_entities, platform) - async_add_entities(new_entities) + log_entities_to_be_added(entities, platform) + try: + async_add_entities(entities) + except ValueError as e: + if str(e) != "Config entry has already been setup!": + raise e diff --git a/custom_components/eltako/light.py b/custom_components/eltako/light.py index 302ce87..92e2e3f 100644 --- a/custom_components/eltako/light.py +++ b/custom_components/eltako/light.py @@ -54,9 +54,12 @@ async def async_setup_entry( LOGGER.critical(e, exc_info=True) validate_actuators_dev_and_sender_id(entities) - new_entities = config_helpers.filter_for_new_entities(er.async_get(hass), entities) - log_entities_to_be_added(new_entities, platform) - async_add_entities(new_entities) + log_entities_to_be_added(entities, platform) + try: + async_add_entities(entities) + except ValueError as e: + if str(e) != "Config entry has already been setup!": + raise e class AbstractLightEntity(EltakoEntity, LightEntity, RestoreEntity): diff --git a/custom_components/eltako/sensor.py b/custom_components/eltako/sensor.py index 49e1ebf..5a405ea 100644 --- a/custom_components/eltako/sensor.py +++ b/custom_components/eltako/sensor.py @@ -415,9 +415,12 @@ def convert_event(event): entities.append(GatewayReceivedMessagesInActiveSession(platform, gateway)) validate_actuators_dev_and_sender_id(entities) - new_entities = config_helpers.filter_for_new_entities(er.async_get(hass), entities) - log_entities_to_be_added(new_entities, platform) - async_add_entities(new_entities) + log_entities_to_be_added(entities, platform) + try: + async_add_entities(entities) + except ValueError as e: + if str(e) != "Config entry has already been setup!": + raise e class EltakoSensor(EltakoEntity, RestoreEntity, SensorEntity): diff --git a/custom_components/eltako/switch.py b/custom_components/eltako/switch.py index 11fbc6a..fe05a17 100644 --- a/custom_components/eltako/switch.py +++ b/custom_components/eltako/switch.py @@ -47,9 +47,12 @@ async def async_setup_entry( validate_actuators_dev_and_sender_id(entities) - new_entities = config_helpers.filter_for_new_entities(er.async_get(hass), entities) - log_entities_to_be_added(new_entities, platform) - async_add_entities(new_entities) + log_entities_to_be_added(entities, platform) + try: + async_add_entities(entities) + except ValueError as e: + if str(e) != "Config entry has already been setup!": + raise e class EltakoSwitch(EltakoEntity, SwitchEntity, RestoreEntity):