Skip to content

Commit

Permalink
Add attribute with active underlyings for easier tracking and setup (#…
Browse files Browse the repository at this point in the history
…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 <[email protected]>

* 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 <[email protected]>
Co-authored-by: Alexander Dransfield <[email protected]>

* Documentation rework

* En links

* Documentation issue #650

---------

Co-authored-by: Sebastian Noe <[email protected]>
Co-authored-by: Jean-Marc Collin <[email protected]>
Co-authored-by: Jean-Marc Collin <[email protected]>
Co-authored-by: Alexander Dransfield <[email protected]>
  • Loading branch information
5 people authored Dec 21, 2024
1 parent 02f6077 commit 9839ed4
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions custom_components/versatile_thermostat/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,14 @@ def __init__(self, hass: HomeAssistant, unique_id, name, entry_infos) -> None:
self._attr_unique_id = "nb_device_active_boiler"
self._attr_value = self._attr_native_value = None # default value
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
def icon(self) -> str | None:
Expand Down Expand Up @@ -718,19 +726,19 @@ async def listen_vtherms_entities(self):
self.calculate_nb_active_devices,
)
_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,
underlying_entities_id,
)
self.async_on_remove(listener_cancel)
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)

async def calculate_nb_active_devices(self, event: Event):
"""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)

Expand Down Expand Up @@ -774,20 +782,30 @@ async def calculate_nb_active_devices(self, event: Event):
)

nb_active = 0
active_device_names = []

for entity in self._entities:
nb_active += entity.nb_device_actives
_LOGGER.debug(
"After examining the hvac_action of %s, nb_active is %s",
entity.name,
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
_LOGGER.debug(
"%s - Number of active underlying entities is %s", self, nb_active
)
self._attr_active_device_names = active_device_names

self.async_write_ha_state()

def __str__(self):
return f"VersatileThermostat-{self.name}"

0 comments on commit 9839ed4

Please sign in to comment.