integrattion tests - Do startup works

This commit is contained in:
Jean-Marc Collin
2025-01-04 11:07:41 +00:00
parent 0b5d937968
commit 6d0ebbaaab
3 changed files with 33 additions and 12 deletions

View File

@@ -444,10 +444,6 @@ class BaseThermostat(ClimateEntity, RestoreEntity, Generic[T]):
)
)
# start listening for all managers
for manager in self._managers:
manager.start_listening()
self.async_on_remove(self.remove_thermostat)
# issue 428. Link to others entities will start at link
@@ -480,6 +476,10 @@ class BaseThermostat(ClimateEntity, RestoreEntity, Generic[T]):
_LOGGER.debug("%s - Calling async_startup_internal", self)
need_write_state = False
# start listening for all managers
for manager in self._managers:
manager.start_listening()
await self.get_my_previous_state()
await self.init_presets(central_configuration)
@@ -1609,7 +1609,9 @@ class BaseThermostat(ClimateEntity, RestoreEntity, Generic[T]):
return False
# Check overpowering condition
# Not necessary for switch because each switch is checking at startup
await VersatileThermostatAPI.get_vtherm_api().central_power_manager.refresh_state()
# TODO remove this
# overpowering is now centralized
# overpowering = await self._power_manager.check_overpowering()
# if overpowering == STATE_ON:

View File

@@ -208,8 +208,7 @@ class CentralFeaturePowerManager(BaseFeatureManager):
)
else:
total_affected_power += power_consumption_max
# Always set to false
# if vtherm.power_manager.is_overpowering_detected:
# Always set to false to init the state
_LOGGER.debug(
"%s - vtherm %s should not be in overpowering state",
self,

View File

@@ -47,6 +47,7 @@ class FeaturePowerManager(BaseFeatureManager):
self._overpowering_state = STATE_UNAVAILABLE
self._is_configured: bool = False
self._device_power: float = 0
self._use_power_feature: bool = False
@overrides
def post_init(self, entry_infos: ConfigData):
@@ -56,16 +57,35 @@ class FeaturePowerManager(BaseFeatureManager):
self._power_temp = entry_infos.get(CONF_PRESET_POWER)
self._device_power = entry_infos.get(CONF_DEVICE_POWER) or 0
self._use_power_feature = entry_infos.get(CONF_USE_POWER_FEATURE, False)
self._is_configured = False
if entry_infos.get(CONF_USE_POWER_FEATURE, False) and self._device_power:
self._is_configured = True
self._overpowering_state = STATE_UNKNOWN
else:
_LOGGER.info("%s - Power management is not fully configured", self)
@overrides
def start_listening(self):
"""Start listening the underlying entity. There is nothing to listen"""
central_power_configuration = (
VersatileThermostatAPI.get_vtherm_api().central_power_manager.is_configured
)
if (
self._use_power_feature
and self._device_power
and central_power_configuration
):
self._is_configured = True
self._overpowering_state = STATE_UNKNOWN
else:
if self._use_power_feature:
if not central_power_configuration:
_LOGGER.warning(
"%s - Power management is not fully configured. You have to configure the central configuration power",
self,
)
else:
_LOGGER.warning(
"%s - Power management is not fully configured. You have to configure the power feature of the VTherm",
self,
)
def add_custom_attributes(self, extra_state_attributes: dict[str, Any]):
"""Add some custom attributes"""