Fix Valve testus. Improve sending the open percent to valve
This commit is contained in:
@@ -217,12 +217,9 @@ class ThermostatOverSonoffTRVZB(ThermostatOverClimate):
|
|||||||
|
|
||||||
self._valve_open_percent = new_valve_percent
|
self._valve_open_percent = new_valve_percent
|
||||||
|
|
||||||
for under in self._underlyings_sonoff_trvzb:
|
|
||||||
under.set_valve_open_percent()
|
|
||||||
|
|
||||||
self._last_calculation_timestamp = now
|
self._last_calculation_timestamp = now
|
||||||
|
|
||||||
self.update_custom_attributes()
|
super().recalculate()
|
||||||
|
|
||||||
async def _send_regulated_temperature(self, force=False):
|
async def _send_regulated_temperature(self, force=False):
|
||||||
"""Sends the regulated temperature to all underlying"""
|
"""Sends the regulated temperature to all underlying"""
|
||||||
@@ -236,7 +233,8 @@ class ThermostatOverSonoffTRVZB(ThermostatOverClimate):
|
|||||||
self._attr_min_temp,
|
self._attr_min_temp,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.recalculate()
|
for under in self._underlyings_sonoff_trvzb:
|
||||||
|
await under.set_valve_open_percent()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_over_sonoff_trvzb(self) -> bool:
|
def is_over_sonoff_trvzb(self) -> bool:
|
||||||
@@ -269,3 +267,8 @@ class ThermostatOverSonoffTRVZB(ThermostatOverClimate):
|
|||||||
"""Returns the current hvac_action by checking all hvac_action of the _underlyings_sonoff_trvzb"""
|
"""Returns the current hvac_action by checking all hvac_action of the _underlyings_sonoff_trvzb"""
|
||||||
|
|
||||||
return self.calculate_hvac_action(self._underlyings_sonoff_trvzb)
|
return self.calculate_hvac_action(self._underlyings_sonoff_trvzb)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_device_active(self) -> bool:
|
||||||
|
"""A hack to overrides the state from underlyings"""
|
||||||
|
return self.valve_open_percent > 0
|
||||||
|
|||||||
@@ -248,8 +248,9 @@ class ThermostatOverValve(BaseThermostat[UnderlyingValve]): # pylint: disable=a
|
|||||||
|
|
||||||
self._valve_open_percent = new_valve_percent
|
self._valve_open_percent = new_valve_percent
|
||||||
|
|
||||||
for under in self._underlyings:
|
# is one in start_cycle now
|
||||||
under.set_valve_open_percent()
|
# for under in self._underlyings:
|
||||||
|
# under.set_valve_open_percent()
|
||||||
|
|
||||||
self._last_calculation_timestamp = now
|
self._last_calculation_timestamp = now
|
||||||
|
|
||||||
|
|||||||
@@ -920,7 +920,7 @@ class UnderlyingValve(UnderlyingEntity):
|
|||||||
|
|
||||||
async def turn_on(self):
|
async def turn_on(self):
|
||||||
"""Nothing to do for Valve because it cannot be turned on"""
|
"""Nothing to do for Valve because it cannot be turned on"""
|
||||||
self.set_valve_open_percent()
|
await self.set_valve_open_percent()
|
||||||
|
|
||||||
async def set_hvac_mode(self, hvac_mode: HVACMode) -> bool:
|
async def set_hvac_mode(self, hvac_mode: HVACMode) -> bool:
|
||||||
"""Set the HVACmode. Returns true if something have change"""
|
"""Set the HVACmode. Returns true if something have change"""
|
||||||
@@ -958,11 +958,8 @@ class UnderlyingValve(UnderlyingEntity):
|
|||||||
force=False,
|
force=False,
|
||||||
):
|
):
|
||||||
"""We use this function to change the on_percent"""
|
"""We use this function to change the on_percent"""
|
||||||
if force:
|
# if force:
|
||||||
# self._percent_open = self.cap_sent_value(self._percent_open)
|
await self.set_valve_open_percent()
|
||||||
# await self.send_percent_open()
|
|
||||||
# avoid to send 2 times the same value at startup
|
|
||||||
self.set_valve_open_percent()
|
|
||||||
|
|
||||||
@overrides
|
@overrides
|
||||||
def cap_sent_value(self, value) -> float:
|
def cap_sent_value(self, value) -> float:
|
||||||
@@ -995,7 +992,7 @@ class UnderlyingValve(UnderlyingEntity):
|
|||||||
|
|
||||||
return new_value
|
return new_value
|
||||||
|
|
||||||
def set_valve_open_percent(self):
|
async def set_valve_open_percent(self):
|
||||||
"""Update the valve open percent"""
|
"""Update the valve open percent"""
|
||||||
caped_val = self.cap_sent_value(self._thermostat.valve_open_percent)
|
caped_val = self.cap_sent_value(self._thermostat.valve_open_percent)
|
||||||
if self._percent_open == caped_val:
|
if self._percent_open == caped_val:
|
||||||
@@ -1009,7 +1006,8 @@ class UnderlyingValve(UnderlyingEntity):
|
|||||||
"%s - Setting valve ouverture percent to %s", self, self._percent_open
|
"%s - Setting valve ouverture percent to %s", self, self._percent_open
|
||||||
)
|
)
|
||||||
# Send the change to the valve, in background
|
# Send the change to the valve, in background
|
||||||
self._hass.create_task(self.send_percent_open())
|
# self._hass.create_task(self.send_percent_open())
|
||||||
|
await self.send_percent_open()
|
||||||
|
|
||||||
def remove_entity(self):
|
def remove_entity(self):
|
||||||
"""Remove the entity after stopping its cycle"""
|
"""Remove the entity after stopping its cycle"""
|
||||||
@@ -1138,6 +1136,19 @@ class UnderlyingSonoffTRVZB(UnderlyingValve):
|
|||||||
return []
|
return []
|
||||||
return [HVACMode.OFF, HVACMode.HEAT]
|
return [HVACMode.OFF, HVACMode.HEAT]
|
||||||
|
|
||||||
|
@overrides
|
||||||
|
async def start_cycle(
|
||||||
|
self,
|
||||||
|
hvac_mode: HVACMode,
|
||||||
|
_1,
|
||||||
|
_2,
|
||||||
|
_3,
|
||||||
|
force=False,
|
||||||
|
):
|
||||||
|
"""We use this function to change the on_percent"""
|
||||||
|
# if force:
|
||||||
|
await self.set_valve_open_percent()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_device_active(self):
|
def is_device_active(self):
|
||||||
"""If the opening valve is open."""
|
"""If the opening valve is open."""
|
||||||
|
|||||||
Reference in New Issue
Block a user