Add attribute with active underlyings for easier tracking and setup (#658)

* Add attribute with active underlyings for easier tracking and setup

* Issue #645   add sonoff trvzb (#651)

* With Sonoff configuration ok

* Fix configuration

* Next (not finished)

* With 1rst implementation of VTherm TRVZB and underlying

* Work in simuated environment

* Fix Testus

* Release

* Fix release name

* Add #602 - implement a max_on_percent setting

* Calculate offset_calibration as room_temp - local_temp
Fix hvac_action calculation

* Fix hvac_action
Fix offset_calibration=room_temp - (local_temp - current_offset)

* Fix underlying target is not updated

* Issue #655 - combine motion and presence

* Fix Valve testus. Improve sending the open percent to valve

* Update custom_components/versatile_thermostat/translations/en.json

Co-authored-by: Alexander Dransfield <2844540+alexdrans@users.noreply.github.com>

* Indus step1

* Step 2 - renaming. All tests ok

* Step 2: manual tests ok

* First unit test ok

* Test multi ok

* All tests ok. Add a multi test for climate with valve regulation

* With testu for config_flow ok

* Documentation (not finished)

* Fix #661 - central boiler doesn't starts with Sonoff TRVZB

* Remove // testing

* Fix exception when there is no offset at all

* Fix class attributes and instance attributes mixing

* Documentation 2

* Documentation 3

* Documentation ++

* documentation

* Try to fix the central boiler calculation

* Fix #669

* Documentation ++

* Documentation ok for FR

* Readme FR|EN

---------

Co-authored-by: Jean-Marc Collin <jean-marc.collin-extern@renault.com>
Co-authored-by: Alexander Dransfield <2844540+alexdrans@users.noreply.github.com>

* Documentation rework

* En links

* Documentation issue #650

---------

Co-authored-by: Sebastian Noe <sebastian.schneider@boxine.de>
Co-authored-by: Jean-Marc Collin <jm.collin.78@gmail.com>
Co-authored-by: Jean-Marc Collin <jean-marc.collin-extern@renault.com>
Co-authored-by: Alexander Dransfield <2844540+alexdrans@users.noreply.github.com>
This commit is contained in:
Sebastian Noe
2024-12-21 09:36:46 +01:00
committed by GitHub
parent 02f60770e8
commit 9839ed4920

View File

@@ -653,6 +653,14 @@ class NbActiveDeviceForBoilerSensor(SensorEntity):
self._attr_unique_id = "nb_device_active_boiler" self._attr_unique_id = "nb_device_active_boiler"
self._attr_value = self._attr_native_value = None # default value self._attr_value = self._attr_native_value = None # default value
self._entities = [] self._entities = []
self._attr_active_device_names = [] # Holds the names of active devices
@property
def extra_state_attributes(self) -> dict:
"""Return additional attributes for the sensor."""
return {
"active_device_names": self._attr_active_device_names,
}
@property @property
def icon(self) -> str | None: def icon(self) -> str | None:
@@ -718,19 +726,19 @@ class NbActiveDeviceForBoilerSensor(SensorEntity):
self.calculate_nb_active_devices, self.calculate_nb_active_devices,
) )
_LOGGER.info( _LOGGER.info(
"%s - the underlyings that could controls the central boiler are %s", "%s - the underlyings that could control the central boiler are %s",
self, self,
underlying_entities_id, underlying_entities_id,
) )
self.async_on_remove(listener_cancel) self.async_on_remove(listener_cancel)
else: else:
_LOGGER.debug("%s - no VTherm could controls the central boiler", self) _LOGGER.debug("%s - no VTherm could control the central boiler", self)
await self.calculate_nb_active_devices(None) await self.calculate_nb_active_devices(None)
async def calculate_nb_active_devices(self, event: Event): async def calculate_nb_active_devices(self, event: Event):
"""Calculate the number of active VTherm that have an """Calculate the number of active VTherm that have an
influence on central boiler""" influence on the central boiler and update the list of active device names."""
# _LOGGER.debug("%s- calculate_nb_active_devices - the event is %s ", self, event) # _LOGGER.debug("%s- calculate_nb_active_devices - the event is %s ", self, event)
@@ -774,6 +782,8 @@ class NbActiveDeviceForBoilerSensor(SensorEntity):
) )
nb_active = 0 nb_active = 0
active_device_names = []
for entity in self._entities: for entity in self._entities:
nb_active += entity.nb_device_actives nb_active += entity.nb_device_actives
_LOGGER.debug( _LOGGER.debug(
@@ -782,12 +792,20 @@ class NbActiveDeviceForBoilerSensor(SensorEntity):
nb_active, nb_active,
) )
if (
entity.hvac_mode in [HVACMode.HEAT, HVACMode.AUTO]
and entity.hvac_action == HVACAction.HEATING
):
for under in entity.underlying_entities:
if under.is_device_active:
nb_active += 1
active_device_names.append(under.entity_id)
self._attr_native_value = nb_active self._attr_native_value = nb_active
_LOGGER.debug( self._attr_active_device_names = active_device_names
"%s - Number of active underlying entities is %s", self, nb_active
)
self.async_write_ha_state() self.async_write_ha_state()
def __str__(self): def __str__(self):
return f"VersatileThermostat-{self.name}" return f"VersatileThermostat-{self.name}"