From dbf2bc698287193368116c0096893603c857288c Mon Sep 17 00:00:00 2001 From: Jean-Marc Collin Date: Wed, 20 Mar 2024 19:16:38 +0100 Subject: [PATCH] [#412] - Fixe Unisue IDs error at startup (#416) Co-authored-by: Jean-Marc Collin --- .devcontainer/configuration.yaml | 8 +-- .../versatile_thermostat/number.py | 69 ++++++++++++------- 2 files changed, 47 insertions(+), 30 deletions(-) diff --git a/.devcontainer/configuration.yaml b/.devcontainer/configuration.yaml index 0c73515..6052855 100644 --- a/.devcontainer/configuration.yaml +++ b/.devcontainer/configuration.yaml @@ -1,11 +1,11 @@ default_config: logger: - default: info + default: warning logs: - custom_components.versatile_thermostat: debug - custom_components.versatile_thermostat.underlyings: debug - custom_components.versatile_thermostat.climate: debug + # custom_components.versatile_thermostat: debug + # custom_components.versatile_thermostat.underlyings: debug + # custom_components.versatile_thermostat.climate: debug # If you need to debug uncommment the line below (doc: https://www.home-assistant.io/integrations/debugpy/) debugpy: diff --git a/custom_components/versatile_thermostat/number.py b/custom_components/versatile_thermostat/number.py index 2cb49df..5c67b74 100644 --- a/custom_components/versatile_thermostat/number.py +++ b/custom_components/versatile_thermostat/number.py @@ -98,63 +98,80 @@ async def async_setup_entry( if vt_type != CONF_THERMOSTAT_CENTRAL_CONFIG: # Creates non central temperature entities if not entry.data.get(CONF_USE_PRESETS_CENTRAL_CONFIG, False): - for preset in CONF_PRESETS_VALUES: - entities.append( - TemperatureNumber( - hass, unique_id, name, preset, False, False, entry.data - ) - ) if entry.data.get(CONF_AC_MODE, False): for preset in CONF_PRESETS_WITH_AC_VALUES: + _LOGGER.warning( + "%s - configuring Number non central, AC, non AWAY for preset %s", + name, + preset, + ) entities.append( TemperatureNumber( hass, unique_id, name, preset, True, False, entry.data ) ) + else: + for preset in CONF_PRESETS_VALUES: + _LOGGER.warning( + "%s - configuring Number non central, non AC, non AWAY for preset %s", + name, + preset, + ) + entities.append( + TemperatureNumber( + hass, unique_id, name, preset, False, False, entry.data + ) + ) if entry.data.get( CONF_USE_PRESENCE_FEATURE, False ) is True and not entry.data.get(CONF_USE_PRESENCE_CENTRAL_CONFIG, False): - for preset in CONF_PRESETS_AWAY_VALUES: - entities.append( - TemperatureNumber( - hass, unique_id, name, preset, False, True, entry.data - ) - ) - if entry.data.get(CONF_AC_MODE, False): for preset in CONF_PRESETS_AWAY_WITH_AC_VALUES: + _LOGGER.warning( + "%s - configuring Number non central, AC, AWAY for preset %s", + name, + preset, + ) entities.append( TemperatureNumber( hass, unique_id, name, preset, True, True, entry.data ) ) + else: + for preset in CONF_PRESETS_AWAY_VALUES: + _LOGGER.warning( + "%s - configuring Number non central, non AC, AWAY for preset %s", + name, + preset, + ) + entities.append( + TemperatureNumber( + hass, unique_id, name, preset, False, True, entry.data + ) + ) + # For central config only else: entities.append( ActivateBoilerThresholdNumber(hass, unique_id, name, entry.data) ) - for preset in CONF_PRESETS_VALUES: - entities.append( - CentralConfigTemperatureNumber( - hass, unique_id, name, preset, False, False, entry.data - ) - ) for preset in CONF_PRESETS_WITH_AC_VALUES: + _LOGGER.warning( + "%s - configuring Number central, AC, non AWAY for preset %s", + name, + preset, + ) entities.append( CentralConfigTemperatureNumber( hass, unique_id, name, preset, True, False, entry.data ) ) - for preset in CONF_PRESETS_AWAY_VALUES: - entities.append( - CentralConfigTemperatureNumber( - hass, unique_id, name, preset, False, True, entry.data - ) - ) - for preset in CONF_PRESETS_AWAY_WITH_AC_VALUES: + _LOGGER.warning( + "%s - configuring Number central, AC, AWAY for preset %s", name, preset + ) entities.append( CentralConfigTemperatureNumber( hass, unique_id, name, preset, True, True, entry.data