Issue #698 nb device active for boiler not updating (#728)

* With tests and list of active

* Issue #698 - nb nb_device_active_for_boiler don't work for climate without hvac_action

---------

Co-authored-by: Jean-Marc Collin <jean-marc.collin-extern@renault.com>
This commit is contained in:
Jean-Marc Collin
2024-12-21 17:24:24 +01:00
committed by GitHub
parent 9839ed4920
commit ee42a235c0
6 changed files with 421 additions and 47 deletions

View File

@@ -131,7 +131,7 @@ class BaseThermostat(ClimateEntity, RestoreEntity, Generic[T]):
"max_power_sensor_entity_id",
"temperature_unit",
"is_device_active",
"nb_device_actives",
"device_actives",
"target_temperature_step",
"is_used_by_central_boiler",
"temperature_slope",
@@ -1001,14 +1001,19 @@ class BaseThermostat(ClimateEntity, RestoreEntity, Generic[T]):
return False
@property
def nb_device_actives(self) -> int:
"""Calculate the number of active devices"""
ret = 0
def device_actives(self) -> int:
"""Calculate the active devices"""
ret = []
for under in self._underlyings:
if under.is_device_active:
ret += 1
ret.append(under.entity_id)
return ret
@property
def nb_device_actives(self) -> int:
"""Calculate the number of active devices"""
return len(self.device_actives)
@property
def current_temperature(self) -> float | None:
"""Return the sensor temperature."""
@@ -2680,6 +2685,7 @@ class BaseThermostat(ClimateEntity, RestoreEntity, Generic[T]):
"timezone": str(self._current_tz),
"temperature_unit": self.temperature_unit,
"is_device_active": self.is_device_active,
"device_actives": self.device_actives,
"nb_device_actives": self.nb_device_actives,
"ema_temp": self._ema_temp,
"is_used_by_central_boiler": self.is_used_by_central_boiler,