Compare commits
3 Commits
jmcollin78
...
7.1.4.beta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fdae24077a | ||
|
|
566e0e683c | ||
|
|
9628e9a93b |
@@ -14,6 +14,6 @@
|
||||
"quality_scale": "silver",
|
||||
"requirements": [],
|
||||
"ssdp": [],
|
||||
"version": "7.1.3",
|
||||
"version": "7.1.4",
|
||||
"zeroconf": []
|
||||
}
|
||||
@@ -195,6 +195,16 @@ class UnderlyingEntity:
|
||||
self._cancel_cycle()
|
||||
await self.turn_off()
|
||||
|
||||
async def check_overpowering(self) -> bool:
|
||||
"""Check that a underlying can be turned on, else
|
||||
activate the overpowering state of the VTherm associated.
|
||||
Returns True if the check is ok (no overpowering needed)"""
|
||||
if not await self._thermostat.power_manager.check_power_available():
|
||||
_LOGGER.debug("%s - overpowering is detected", self)
|
||||
await self._thermostat.power_manager.set_overpowering(True)
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
class UnderlyingSwitch(UnderlyingEntity):
|
||||
"""Represent a underlying switch"""
|
||||
@@ -318,6 +328,10 @@ class UnderlyingSwitch(UnderlyingEntity):
|
||||
"""Turn heater toggleable device on."""
|
||||
self._keep_alive.cancel() # Cancel early to avoid a turn_on/turn_off race condition
|
||||
_LOGGER.debug("%s - Starting underlying entity %s", self, self._entity_id)
|
||||
|
||||
if not await self.check_overpowering():
|
||||
return False
|
||||
|
||||
command = SERVICE_TURN_ON if not self.is_inversed else SERVICE_TURN_OFF
|
||||
domain = self._entity_id.split(".")[0]
|
||||
try:
|
||||
@@ -325,6 +339,7 @@ class UnderlyingSwitch(UnderlyingEntity):
|
||||
data = {ATTR_ENTITY_ID: self._entity_id}
|
||||
await self._hass.services.async_call(domain, command, data)
|
||||
self._keep_alive.set_async_action(self._keep_alive_callback)
|
||||
return True
|
||||
except Exception:
|
||||
self._keep_alive.cancel()
|
||||
raise
|
||||
@@ -414,10 +429,6 @@ class UnderlyingSwitch(UnderlyingEntity):
|
||||
await self.turn_off()
|
||||
return
|
||||
|
||||
# if await self._thermostat.power_manager.check_overpowering():
|
||||
# _LOGGER.debug("%s - End of cycle (3)", self)
|
||||
# return
|
||||
|
||||
# safety mode could have change the on_time percent
|
||||
await self._thermostat.safety_manager.refresh_state()
|
||||
time = self._on_time_sec
|
||||
@@ -432,7 +443,8 @@ class UnderlyingSwitch(UnderlyingEntity):
|
||||
time // 60,
|
||||
time % 60,
|
||||
)
|
||||
await self.turn_on()
|
||||
if not await self.turn_on():
|
||||
return
|
||||
else:
|
||||
_LOGGER.debug("%s - No action on heater cause duration is 0", self)
|
||||
self._async_cancel_cycle = self.call_later(
|
||||
@@ -557,6 +569,10 @@ class UnderlyingClimate(UnderlyingEntity):
|
||||
)
|
||||
return False
|
||||
|
||||
# When turning on a climate, check that power is available
|
||||
if hvac_mode in (HVACMode.HEAT, HVACMode.COOL) and not await self.check_overpowering():
|
||||
return False
|
||||
|
||||
data = {ATTR_ENTITY_ID: self._entity_id, "hvac_mode": hvac_mode}
|
||||
await self._hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
|
||||
@@ -11,6 +11,7 @@ The behavior of this feature is as follows:
|
||||
1. When a new measurement of the home's power consumption or the maximum allowed power is received,
|
||||
2. If the maximum power is exceeded, the central command will shed the load of all active devices starting with those closest to the setpoint. This continues until enough _VTherms_ are shed,
|
||||
3. If there is available power reserve and some _VTherms_ are shed, the central command will re-enable as many devices as possible, starting with those furthest from the setpoint (at the time they were shed).
|
||||
4. When a _VTherm_ starts, a check is performed to determine if the declared power is available. If not, the _VTherm_ is put into shed mode.
|
||||
|
||||
**WARNING:** This is **not a safety feature** but an optimization function to manage consumption at the expense of some heating degradation. Overconsumption is still possible depending on the frequency of your consumption sensor updates and the actual power used by your equipment. Always maintain a safety margin.
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ Le comportement de cette fonction est le suivant :
|
||||
1. lorsqu'une nouvelle mesure de la puissance consommée du logement ou de la puissance maximale autorisée est reçue,
|
||||
2. si la puissance max est dépassée, la commande centrale va mettre en délestage tous les équipements actifs en commençant par ceux qui sont le plus près de la consigne. Il fait ça jusqu'à ce que suffisament de _VTherm_ soient délestés,
|
||||
3. si une réserve de puissance est disponible et que des _VTherms_ sont délestés, alors la commande centrale va délester autant d'équipements que possible en commençant par les plus loin de la consigne (au moment où il a été mis en délestage),
|
||||
4. au démarrage d'un _VTherm_, une vérification est effectuée pour savoir si la puissance déclarée est disponible. Si non, le _VTherm_ est passé en délestage.
|
||||
|
||||
ATTENTION: ce fonctionnement **n'est pas une fonction de sécurité** mais plus une fonction permettant une optimisation de la consommation au prix d'une dégradation du chauffage. Des dépassements sont possibles selon la fréquence de remontée de vos capteurs de consommation, la puissance réellement utilisée par votre équipements. Vous devez donc toujours garder une marge de sécurité.
|
||||
|
||||
|
||||
@@ -398,7 +398,8 @@ async def test_bug_407(
|
||||
assert entity.target_temperature == 19
|
||||
assert mock_service_call.call_count >= 1
|
||||
|
||||
# 3. if heater is stopped (is_device_active==False) and power is over max, then overpowering should be started
|
||||
# 3. Evenif heater is stopped (is_device_active==False) and power is over max, then overpowering should be started
|
||||
# due to check before start heating
|
||||
side_effects.add_or_update_side_effect("sensor.the_power_sensor", State("sensor.the_power_sensor", 150))
|
||||
with patch(
|
||||
"homeassistant.core.ServiceRegistry.async_call"
|
||||
@@ -413,18 +414,18 @@ async def test_bug_407(
|
||||
now = now + timedelta(seconds=30)
|
||||
VersatileThermostatAPI.get_vtherm_api()._set_now(now)
|
||||
|
||||
# change preset to Boost
|
||||
# change preset to Comfort
|
||||
await entity.async_set_preset_mode(PRESET_COMFORT)
|
||||
# waits that the heater starts
|
||||
# waits the eventual heater starts
|
||||
await asyncio.sleep(0.1)
|
||||
|
||||
# simulate a refresh for central power (not necessary)
|
||||
await do_central_power_refresh(hass)
|
||||
# simulate a refresh for central power (not necessary because it is checked before start)
|
||||
# await do_central_power_refresh(hass)
|
||||
|
||||
assert entity.power_manager.is_overpowering_detected is False
|
||||
assert entity.power_manager.is_overpowering_detected is True
|
||||
assert entity.hvac_mode is HVACMode.HEAT
|
||||
assert entity.preset_mode is PRESET_COMFORT
|
||||
assert entity.power_manager.overpowering_state is STATE_OFF
|
||||
assert entity.preset_mode is PRESET_POWER
|
||||
assert entity.power_manager.overpowering_state is STATE_ON
|
||||
|
||||
|
||||
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
||||
|
||||
Reference in New Issue
Block a user