Compare commits
6 Commits
2.3.0.beta2
...
2.3.0
| Author | SHA1 | Date | |
|---|---|---|---|
| e63213d22a | |||
| fb7ee1bdac | |||
| ca86b310c4 | |||
| 23074e6f46 | |||
| 718315c4fe | |||
| 46278ca9a3 |
@@ -129,6 +129,26 @@ template:
|
|||||||
{% if energy == 'unavailable' or energy is none%}unavailable{% else %}
|
{% if energy == 'unavailable' or energy is none%}unavailable{% else %}
|
||||||
{{ ((energy | float) / 1.0) | round(2, default=0) }}
|
{{ ((energy | float) / 1.0) | round(2, default=0) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
- name: "Total énergie climate 2"
|
||||||
|
unique_id: total_energie_climate2
|
||||||
|
unit_of_measurement: "kWh"
|
||||||
|
device_class: energy
|
||||||
|
state_class: total_increasing
|
||||||
|
state: >
|
||||||
|
{% set energy = state_attr('climate.thermostat_climate_2', 'total_energy') %}
|
||||||
|
{% if energy == 'unavailable' or energy is none%}unavailable{% else %}
|
||||||
|
{{ ((energy | float) / 1.0) | round(2, default=0) }}
|
||||||
|
{% endif %}
|
||||||
|
- name: "Total énergie chambre"
|
||||||
|
unique_id: total_energie_chambre
|
||||||
|
unit_of_measurement: "kWh"
|
||||||
|
device_class: energy
|
||||||
|
state_class: total_increasing
|
||||||
|
state: >
|
||||||
|
{% set energy = state_attr('climate.thermostat_chambre', 'total_energy') %}
|
||||||
|
{% if energy == 'unavailable' or energy is none%}unavailable{% else %}
|
||||||
|
{{ ((energy | float) / 1.0) | round(2, default=0) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
switch:
|
switch:
|
||||||
- platform: template
|
- platform: template
|
||||||
|
|||||||
+2
-2
@@ -323,8 +323,8 @@ Le pourcentage est calculé avec cette formule :
|
|||||||
Les valeurs par défaut pour coef_int et coef_ext sont respectivement : ``0.6`` et ``0.01``. Ces valeurs par défaut conviennent à une pièce standard bien isolée.
|
Les valeurs par défaut pour coef_int et coef_ext sont respectivement : ``0.6`` et ``0.01``. Ces valeurs par défaut conviennent à une pièce standard bien isolée.
|
||||||
|
|
||||||
Pour régler ces coefficients, gardez à l'esprit que :
|
Pour régler ces coefficients, gardez à l'esprit que :
|
||||||
1. **si la température cible n'est pas atteinte** après une situation stable, vous devez augmenter le ``coef_ext`` (le ``on_percent`` est trop élevé),
|
1. **si la température cible n'est pas atteinte** après une situation stable, vous devez augmenter le ``coef_ext`` (le ``on_percent`` est trop bas),
|
||||||
2. **si la température cible est dépassée** après une situation stable, vous devez diminuer le ``coef_ext`` (le ``on_percent`` est trop bas),
|
2. **si la température cible est dépassée** après une situation stable, vous devez diminuer le ``coef_ext`` (le ``on_percent`` est trop haut),
|
||||||
3. **si l'atteinte de la température cible est trop lente**, vous pouvez augmenter le ``coef_int`` pour donner plus de puissance au réchauffeur,
|
3. **si l'atteinte de la température cible est trop lente**, vous pouvez augmenter le ``coef_int`` pour donner plus de puissance au réchauffeur,
|
||||||
4. **si l'atteinte de la température cible est trop rapide et que des oscillations apparaissent** autour de la cible, vous pouvez diminuer le ``coef_int`` pour donner moins de puissance au radiateur
|
4. **si l'atteinte de la température cible est trop rapide et que des oscillations apparaissent** autour de la cible, vous pouvez diminuer le ``coef_int`` pour donner moins de puissance au radiateur
|
||||||
|
|
||||||
|
|||||||
@@ -309,8 +309,8 @@ The percentage is calculated with this formula:
|
|||||||
Defaults values for coef_int and coef_ext are respectively: ``0.6`` and ``0.01``. Those defaults values are suitable for a standard well isolated room.
|
Defaults values for coef_int and coef_ext are respectively: ``0.6`` and ``0.01``. Those defaults values are suitable for a standard well isolated room.
|
||||||
|
|
||||||
To tune those coefficients keep in mind that:
|
To tune those coefficients keep in mind that:
|
||||||
1. **if target temperature is not reach** after stable situation, you have to augment the ``coef_ext`` (the ``on_percent`` is too high),
|
1. **if target temperature is not reach** after stable situation, you have to augment the ``coef_ext`` (the ``on_percent`` is too low),
|
||||||
2. **if target temperature is exceeded** after stable situation, you have to decrease the ``coef_ext`` (the ``on_percent`` is too low),
|
2. **if target temperature is exceeded** after stable situation, you have to decrease the ``coef_ext`` (the ``on_percent`` is too high),
|
||||||
3. **if reaching the target temperature is too slow**, you can increase the ``coef_int`` to give more power to the heater,
|
3. **if reaching the target temperature is too slow**, you can increase the ``coef_int`` to give more power to the heater,
|
||||||
4. **if reaching the target temperature is too fast and some oscillations appears** around the target, you can decrease the ``coef_int`` to give less power to the heater
|
4. **if reaching the target temperature is too fast and some oscillations appears** around the target, you can decrease the ``coef_int`` to give less power to the heater
|
||||||
|
|
||||||
|
|||||||
@@ -261,6 +261,8 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
|||||||
self._attr_translation_key = "versatile_thermostat"
|
self._attr_translation_key = "versatile_thermostat"
|
||||||
|
|
||||||
self._total_energy = None
|
self._total_energy = None
|
||||||
|
self._underlying_climate_start_hvac_action_date = None
|
||||||
|
self._underlying_climate_delta_t = 0
|
||||||
|
|
||||||
self._current_tz = dt_util.get_time_zone(self._hass.config.time_zone)
|
self._current_tz = dt_util.get_time_zone(self._hass.config.time_zone)
|
||||||
|
|
||||||
@@ -407,8 +409,8 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
|||||||
or DEFAULT_SECURITY_DEFAULT_ON_PERCENT
|
or DEFAULT_SECURITY_DEFAULT_ON_PERCENT
|
||||||
)
|
)
|
||||||
self._minimal_activation_delay = entry_infos.get(CONF_MINIMAL_ACTIVATION_DELAY)
|
self._minimal_activation_delay = entry_infos.get(CONF_MINIMAL_ACTIVATION_DELAY)
|
||||||
self._last_temperature_mesure = datetime.now()
|
self._last_temperature_mesure = datetime.now(tz=self._current_tz)
|
||||||
self._last_ext_temperature_mesure = datetime.now()
|
self._last_ext_temperature_mesure = datetime.now(tz=self._current_tz)
|
||||||
self._security_state = False
|
self._security_state = False
|
||||||
self._saved_hvac_mode = None
|
self._saved_hvac_mode = None
|
||||||
|
|
||||||
@@ -1000,13 +1002,11 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
|||||||
@property
|
@property
|
||||||
def mean_cycle_power(self) -> float | None:
|
def mean_cycle_power(self) -> float | None:
|
||||||
"""Returns tne mean power consumption during the cycle"""
|
"""Returns tne mean power consumption during the cycle"""
|
||||||
if self._is_over_climate:
|
if not self._device_power or self._is_over_climate:
|
||||||
return None
|
|
||||||
elif self._device_power:
|
|
||||||
return float(self._device_power * self._prop_algorithm.on_percent)
|
|
||||||
else:
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
return float(self._device_power * self._prop_algorithm.on_percent)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def total_energy(self) -> float | None:
|
def total_energy(self) -> float | None:
|
||||||
"""Returns the total energy calculated for this thermostast"""
|
"""Returns the total energy calculated for this thermostast"""
|
||||||
@@ -1166,7 +1166,7 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
|||||||
):
|
):
|
||||||
self._last_temperature_mesure = (
|
self._last_temperature_mesure = (
|
||||||
self._last_ext_temperature_mesure
|
self._last_ext_temperature_mesure
|
||||||
) = datetime.now()
|
) = datetime.now(tz=self._current_tz)
|
||||||
|
|
||||||
def find_preset_temp(self, preset_mode):
|
def find_preset_temp(self, preset_mode):
|
||||||
"""Find the right temperature of a preset considering the presence if configured"""
|
"""Find the right temperature of a preset considering the presence if configured"""
|
||||||
@@ -1265,6 +1265,22 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
|||||||
CLIMATE_DOMAIN, SERVICE_SET_TEMPERATURE, data, context=self._context
|
CLIMATE_DOMAIN, SERVICE_SET_TEMPERATURE, data, context=self._context
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_state_date_or_now(self, state: State):
|
||||||
|
"""Extract the last_changed state from State or return now if not available"""
|
||||||
|
return (
|
||||||
|
state.last_changed.astimezone(self._current_tz)
|
||||||
|
if state.last_changed is not None
|
||||||
|
else datetime.now(tz=self._current_tz)
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_last_updated_date_or_now(self, state: State):
|
||||||
|
"""Extract the last_changed state from State or return now if not available"""
|
||||||
|
return (
|
||||||
|
state.last_updated.astimezone(self._current_tz)
|
||||||
|
if state.last_updated is not None
|
||||||
|
else datetime.now(tz=self._current_tz)
|
||||||
|
)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
async def entry_update_listener(
|
async def entry_update_listener(
|
||||||
self, _, config_entry: ConfigEntry # hass: HomeAssistant,
|
self, _, config_entry: ConfigEntry # hass: HomeAssistant,
|
||||||
@@ -1315,8 +1331,6 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
|||||||
self._hvac_mode,
|
self._hvac_mode,
|
||||||
self._saved_hvac_mode,
|
self._saved_hvac_mode,
|
||||||
)
|
)
|
||||||
if new_state is None or old_state is None or new_state.state == old_state.state:
|
|
||||||
return
|
|
||||||
|
|
||||||
# Check delay condition
|
# Check delay condition
|
||||||
async def try_window_condition(_):
|
async def try_window_condition(_):
|
||||||
@@ -1357,6 +1371,9 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
|||||||
await self.async_set_hvac_mode(HVACMode.OFF)
|
await self.async_set_hvac_mode(HVACMode.OFF)
|
||||||
self.update_custom_attributes()
|
self.update_custom_attributes()
|
||||||
|
|
||||||
|
if new_state is None or old_state is None or new_state.state == old_state.state:
|
||||||
|
return try_window_condition
|
||||||
|
|
||||||
if self._window_call_cancel:
|
if self._window_call_cancel:
|
||||||
self._window_call_cancel()
|
self._window_call_cancel()
|
||||||
self._window_call_cancel = None
|
self._window_call_cancel = None
|
||||||
@@ -1450,14 +1467,29 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
|||||||
async def _async_climate_changed(self, event):
|
async def _async_climate_changed(self, event):
|
||||||
"""Handle unerdlying climate state changes."""
|
"""Handle unerdlying climate state changes."""
|
||||||
new_state = event.data.get("new_state")
|
new_state = event.data.get("new_state")
|
||||||
|
_LOGGER.warning("%s - _async_climate_changed new_state is %s", self, new_state)
|
||||||
|
old_state = event.data.get("old_state")
|
||||||
|
old_hvac_action = (
|
||||||
|
old_state.attributes.get("hvac_action")
|
||||||
|
if old_state and old_state.attributes
|
||||||
|
else None
|
||||||
|
)
|
||||||
|
new_hvac_action = (
|
||||||
|
new_state.attributes.get("hvac_action")
|
||||||
|
if new_state and new_state.attributes
|
||||||
|
else None
|
||||||
|
)
|
||||||
|
|
||||||
_LOGGER.info(
|
_LOGGER.info(
|
||||||
"%s - Underlying climate changed. Event.new_state is %s, hvac_mode=%s",
|
"%s - Underlying climate changed. Event.new_state is %s, hvac_mode=%s, hvac_action=%s, old_hvac_action=%s",
|
||||||
self,
|
self,
|
||||||
new_state,
|
new_state,
|
||||||
self._hvac_mode,
|
self._hvac_mode,
|
||||||
|
new_hvac_action,
|
||||||
|
old_hvac_action,
|
||||||
)
|
)
|
||||||
# old_state = event.data.get("old_state")
|
|
||||||
if new_state is None or new_state.state not in [
|
if new_state.state in [
|
||||||
HVACMode.OFF,
|
HVACMode.OFF,
|
||||||
HVACMode.HEAT,
|
HVACMode.HEAT,
|
||||||
HVACMode.COOL,
|
HVACMode.COOL,
|
||||||
@@ -1466,8 +1498,45 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
|||||||
HVACMode.AUTO,
|
HVACMode.AUTO,
|
||||||
HVACMode.FAN_ONLY,
|
HVACMode.FAN_ONLY,
|
||||||
]:
|
]:
|
||||||
return
|
self._hvac_mode = new_state.state
|
||||||
self._hvac_mode = new_state.state
|
|
||||||
|
# Interpretation of hvac
|
||||||
|
HVAC_ACTION_ON = [
|
||||||
|
HVACAction.COOLING,
|
||||||
|
HVACAction.DRYING,
|
||||||
|
HVACAction.FAN,
|
||||||
|
HVACAction.HEATING,
|
||||||
|
]
|
||||||
|
if old_hvac_action not in HVAC_ACTION_ON and new_hvac_action in HVAC_ACTION_ON:
|
||||||
|
self._underlying_climate_start_hvac_action_date = (
|
||||||
|
self.get_last_updated_date_or_now(new_state)
|
||||||
|
)
|
||||||
|
_LOGGER.info(
|
||||||
|
"%s - underlying just switch ON. Set power and energy start date %s",
|
||||||
|
self,
|
||||||
|
self._underlying_climate_start_hvac_action_date.isoformat(),
|
||||||
|
)
|
||||||
|
|
||||||
|
if old_hvac_action in HVAC_ACTION_ON and new_hvac_action not in HVAC_ACTION_ON:
|
||||||
|
stop_power_date = self.get_last_updated_date_or_now(new_state)
|
||||||
|
if self._underlying_climate_start_hvac_action_date:
|
||||||
|
delta = (
|
||||||
|
stop_power_date - self._underlying_climate_start_hvac_action_date
|
||||||
|
)
|
||||||
|
self._underlying_climate_delta_t = delta.total_seconds() / 3600.0
|
||||||
|
|
||||||
|
# increment energy at the end of the cycle
|
||||||
|
self.incremente_energy()
|
||||||
|
|
||||||
|
self._underlying_climate_start_hvac_action_date = None
|
||||||
|
|
||||||
|
_LOGGER.info(
|
||||||
|
"%s - underlying just switch OFF at %s. delta_h=%.3f h",
|
||||||
|
self,
|
||||||
|
stop_power_date.isoformat(),
|
||||||
|
self._underlying_climate_delta_t,
|
||||||
|
)
|
||||||
|
|
||||||
self.update_custom_attributes()
|
self.update_custom_attributes()
|
||||||
await self._async_control_heating(True)
|
await self._async_control_heating(True)
|
||||||
|
|
||||||
@@ -1479,9 +1548,16 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
|||||||
if math.isnan(cur_temp) or math.isinf(cur_temp):
|
if math.isnan(cur_temp) or math.isinf(cur_temp):
|
||||||
raise ValueError(f"Sensor has illegal state {state.state}")
|
raise ValueError(f"Sensor has illegal state {state.state}")
|
||||||
self._cur_temp = cur_temp
|
self._cur_temp = cur_temp
|
||||||
self._last_temperature_mesure = (
|
|
||||||
state.last_changed if state.last_changed is not None else datetime.now()
|
self._last_temperature_mesure = self.get_state_date_or_now(state)
|
||||||
|
|
||||||
|
_LOGGER.debug(
|
||||||
|
"%s - After setting _last_temperature_mesure %s , state.last_changed.replace=%s",
|
||||||
|
self,
|
||||||
|
self._last_temperature_mesure,
|
||||||
|
state.last_changed.astimezone(self._current_tz),
|
||||||
)
|
)
|
||||||
|
|
||||||
# try to restart if we were in security mode
|
# try to restart if we were in security mode
|
||||||
if self._security_state:
|
if self._security_state:
|
||||||
await self.check_security()
|
await self.check_security()
|
||||||
@@ -1497,9 +1573,15 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
|||||||
if math.isnan(cur_ext_temp) or math.isinf(cur_ext_temp):
|
if math.isnan(cur_ext_temp) or math.isinf(cur_ext_temp):
|
||||||
raise ValueError(f"Sensor has illegal state {state.state}")
|
raise ValueError(f"Sensor has illegal state {state.state}")
|
||||||
self._cur_ext_temp = cur_ext_temp
|
self._cur_ext_temp = cur_ext_temp
|
||||||
self._last_ext_temperature_mesure = (
|
self._last_ext_temperature_mesure = self.get_state_date_or_now(state)
|
||||||
state.last_changed if state.last_changed is not None else datetime.now()
|
|
||||||
|
_LOGGER.debug(
|
||||||
|
"%s - After setting _last_ext_temperature_mesure %s , state.last_changed.replace=%s",
|
||||||
|
self,
|
||||||
|
self._last_ext_temperature_mesure,
|
||||||
|
state.last_changed.astimezone(self._current_tz),
|
||||||
)
|
)
|
||||||
|
|
||||||
# try to restart if we were in security mode
|
# try to restart if we were in security mode
|
||||||
if self._security_state:
|
if self._security_state:
|
||||||
await self.check_security()
|
await self.check_security()
|
||||||
@@ -2098,14 +2180,30 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
|||||||
|
|
||||||
def incremente_energy(self):
|
def incremente_energy(self):
|
||||||
"""increment the energy counter if device is active"""
|
"""increment the energy counter if device is active"""
|
||||||
if self.hvac_mode != HVACMode.OFF:
|
if self.hvac_mode == HVACMode.OFF:
|
||||||
self._total_energy += self.mean_cycle_power * float(self._cycle_min) / 60.0
|
return
|
||||||
|
|
||||||
|
added_energy = 0
|
||||||
|
if self._is_over_climate and self._underlying_climate_delta_t is not None:
|
||||||
|
added_energy = self._device_power * self._underlying_climate_delta_t
|
||||||
|
|
||||||
|
if not self._is_over_climate and self.mean_cycle_power is not None:
|
||||||
|
added_energy = self.mean_cycle_power * float(self._cycle_min) / 60.0
|
||||||
|
|
||||||
|
self._total_energy += added_energy
|
||||||
|
_LOGGER.debug(
|
||||||
|
"%s - added energy is %.3f . Total energy is now: %.3f",
|
||||||
|
self,
|
||||||
|
added_energy,
|
||||||
|
self._total_energy,
|
||||||
|
)
|
||||||
|
|
||||||
def update_custom_attributes(self):
|
def update_custom_attributes(self):
|
||||||
"""Update the custom extra attributes for the entity"""
|
"""Update the custom extra attributes for the entity"""
|
||||||
|
|
||||||
self._attr_extra_state_attributes: dict(str, str) = {
|
self._attr_extra_state_attributes: dict(str, str) = {
|
||||||
"hvac_mode": self._hvac_mode,
|
"hvac_mode": self.hvac_mode,
|
||||||
|
"preset_mode": self.preset_mode,
|
||||||
"type": self._thermostat_type,
|
"type": self._thermostat_type,
|
||||||
"eco_temp": self._presets[PRESET_ECO],
|
"eco_temp": self._presets[PRESET_ECO],
|
||||||
"boost_temp": self._presets[PRESET_BOOST],
|
"boost_temp": self._presets[PRESET_BOOST],
|
||||||
@@ -2133,11 +2231,11 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
|||||||
"security_delay_min": self._security_delay_min,
|
"security_delay_min": self._security_delay_min,
|
||||||
"security_min_on_percent": self._security_min_on_percent,
|
"security_min_on_percent": self._security_min_on_percent,
|
||||||
"security_default_on_percent": self._security_default_on_percent,
|
"security_default_on_percent": self._security_default_on_percent,
|
||||||
"last_temperature_datetime": self._last_temperature_mesure.replace(
|
"last_temperature_datetime": self._last_temperature_mesure.astimezone(
|
||||||
tzinfo=self._current_tz
|
self._current_tz
|
||||||
).isoformat(),
|
).isoformat(),
|
||||||
"last_ext_temperature_datetime": self._last_ext_temperature_mesure.replace(
|
"last_ext_temperature_datetime": self._last_ext_temperature_mesure.astimezone(
|
||||||
tzinfo=self._current_tz
|
self._current_tz
|
||||||
).isoformat(),
|
).isoformat(),
|
||||||
"security_state": self._security_state,
|
"security_state": self._security_state,
|
||||||
"minimal_activation_delay_sec": self._minimal_activation_delay,
|
"minimal_activation_delay_sec": self._minimal_activation_delay,
|
||||||
@@ -2145,7 +2243,7 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
|||||||
ATTR_MEAN_POWER_CYCLE: self.mean_cycle_power,
|
ATTR_MEAN_POWER_CYCLE: self.mean_cycle_power,
|
||||||
ATTR_TOTAL_ENERGY: self.total_energy,
|
ATTR_TOTAL_ENERGY: self.total_energy,
|
||||||
"last_update_datetime": datetime.now()
|
"last_update_datetime": datetime.now()
|
||||||
.replace(tzinfo=self._current_tz)
|
.astimezone(self._current_tz)
|
||||||
.isoformat(),
|
.isoformat(),
|
||||||
"timezone": str(self._current_tz),
|
"timezone": str(self._current_tz),
|
||||||
}
|
}
|
||||||
@@ -2153,6 +2251,9 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
|||||||
self._attr_extra_state_attributes[
|
self._attr_extra_state_attributes[
|
||||||
"underlying_climate"
|
"underlying_climate"
|
||||||
] = self._climate_entity_id
|
] = self._climate_entity_id
|
||||||
|
self._attr_extra_state_attributes[
|
||||||
|
"start_hvac_action_date"
|
||||||
|
] = self._underlying_climate_start_hvac_action_date
|
||||||
else:
|
else:
|
||||||
self._attr_extra_state_attributes[
|
self._attr_extra_state_attributes[
|
||||||
"underlying_switch"
|
"underlying_switch"
|
||||||
|
|||||||
@@ -204,6 +204,7 @@ class VersatileThermostatBaseConfigFlow(FlowHandler):
|
|||||||
vol.Required(CONF_CYCLE_MIN, default=5): cv.positive_int,
|
vol.Required(CONF_CYCLE_MIN, default=5): cv.positive_int,
|
||||||
vol.Required(CONF_TEMP_MIN, default=7): vol.Coerce(float),
|
vol.Required(CONF_TEMP_MIN, default=7): vol.Coerce(float),
|
||||||
vol.Required(CONF_TEMP_MAX, default=35): vol.Coerce(float),
|
vol.Required(CONF_TEMP_MAX, default=35): vol.Coerce(float),
|
||||||
|
vol.Optional(CONF_DEVICE_POWER, default="1"): vol.Coerce(float),
|
||||||
vol.Optional(CONF_USE_WINDOW_FEATURE, default=False): cv.boolean,
|
vol.Optional(CONF_USE_WINDOW_FEATURE, default=False): cv.boolean,
|
||||||
vol.Optional(CONF_USE_MOTION_FEATURE, default=False): cv.boolean,
|
vol.Optional(CONF_USE_MOTION_FEATURE, default=False): cv.boolean,
|
||||||
vol.Optional(CONF_USE_POWER_FEATURE, default=False): cv.boolean,
|
vol.Optional(CONF_USE_POWER_FEATURE, default=False): cv.boolean,
|
||||||
@@ -290,7 +291,6 @@ class VersatileThermostatBaseConfigFlow(FlowHandler):
|
|||||||
domain=[SENSOR_DOMAIN, INPUT_NUMBER_DOMAIN]
|
domain=[SENSOR_DOMAIN, INPUT_NUMBER_DOMAIN]
|
||||||
),
|
),
|
||||||
), # vol.In(power_sensors),
|
), # vol.In(power_sensors),
|
||||||
vol.Optional(CONF_DEVICE_POWER, default="1"): vol.Coerce(float),
|
|
||||||
vol.Optional(CONF_PRESET_POWER, default="13"): vol.Coerce(float),
|
vol.Optional(CONF_PRESET_POWER, default="13"): vol.Coerce(float),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
{
|
{
|
||||||
"version": "0.0.1",
|
|
||||||
"domain": "versatile_thermostat",
|
"domain": "versatile_thermostat",
|
||||||
"name": "Versatile Thermostat",
|
"name": "Versatile Thermostat",
|
||||||
"config_flow": true,
|
|
||||||
"documentation": "https://github.com/jmcollin78/versatile_thermostat",
|
|
||||||
"issue_tracker": "https://github.com/jmcollin78/versatile_thermostat/issues",
|
|
||||||
"requirements": [],
|
|
||||||
"ssdp": [],
|
|
||||||
"zeroconf": [],
|
|
||||||
"homekit": {},
|
|
||||||
"dependencies": [],
|
|
||||||
"codeowners": [
|
"codeowners": [
|
||||||
"@jmcollin78"
|
"@jmcollin78"
|
||||||
],
|
],
|
||||||
"quality_scale": "silver",
|
"config_flow": true,
|
||||||
|
"dependencies": [],
|
||||||
|
"documentation": "https://github.com/jmcollin78/versatile_thermostat",
|
||||||
|
"homekit": {},
|
||||||
|
"integration_type": "device",
|
||||||
"iot_class": "calculated",
|
"iot_class": "calculated",
|
||||||
"integration_type": "device"
|
"issue_tracker": "https://github.com/jmcollin78/versatile_thermostat/issues",
|
||||||
|
"quality_scale": "silver",
|
||||||
|
"requirements": [],
|
||||||
|
"ssdp": [],
|
||||||
|
"version": "0.0.1",
|
||||||
|
"zeroconf": []
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
"cycle_min": "Cycle duration (minutes)",
|
"cycle_min": "Cycle duration (minutes)",
|
||||||
"temp_min": "Minimal temperature allowed",
|
"temp_min": "Minimal temperature allowed",
|
||||||
"temp_max": "Maximal temperature allowed",
|
"temp_max": "Maximal temperature allowed",
|
||||||
|
"device_power": "Device power (kW)",
|
||||||
"use_window_feature": "Use window detection",
|
"use_window_feature": "Use window detection",
|
||||||
"use_motion_feature": "Use motion detection",
|
"use_motion_feature": "Use motion detection",
|
||||||
"use_power_feature": "Use power management",
|
"use_power_feature": "Use power management",
|
||||||
@@ -70,7 +71,6 @@
|
|||||||
"data": {
|
"data": {
|
||||||
"power_sensor_entity_id": "Power sensor entity id",
|
"power_sensor_entity_id": "Power sensor entity id",
|
||||||
"max_power_sensor_entity_id": "Max power sensor entity id",
|
"max_power_sensor_entity_id": "Max power sensor entity id",
|
||||||
"device_power": "Device power (kW)",
|
|
||||||
"power_temp": "Temperature for Power shedding"
|
"power_temp": "Temperature for Power shedding"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -117,6 +117,7 @@
|
|||||||
"cycle_min": "Cycle duration (minutes)",
|
"cycle_min": "Cycle duration (minutes)",
|
||||||
"temp_min": "Minimal temperature allowed",
|
"temp_min": "Minimal temperature allowed",
|
||||||
"temp_max": "Maximal temperature allowed",
|
"temp_max": "Maximal temperature allowed",
|
||||||
|
"device_power": "Device power (kW)",
|
||||||
"use_window_feature": "Use window detection",
|
"use_window_feature": "Use window detection",
|
||||||
"use_motion_feature": "Use motion detection",
|
"use_motion_feature": "Use motion detection",
|
||||||
"use_power_feature": "Use power management",
|
"use_power_feature": "Use power management",
|
||||||
@@ -173,7 +174,6 @@
|
|||||||
"data": {
|
"data": {
|
||||||
"power_sensor_entity_id": "Power sensor entity id",
|
"power_sensor_entity_id": "Power sensor entity id",
|
||||||
"max_power_sensor_entity_id": "Max power sensor entity id",
|
"max_power_sensor_entity_id": "Max power sensor entity id",
|
||||||
"device_power": "Device power (kW)",
|
|
||||||
"power_temp": "Temperature for Power shedding"
|
"power_temp": "Temperature for Power shedding"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
""" Some common resources """
|
""" Some common resources """
|
||||||
from unittest.mock import patch
|
from typing import Mapping
|
||||||
|
from unittest.mock import patch, MagicMock
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant, Event, EVENT_STATE_CHANGED, State
|
from homeassistant.core import HomeAssistant, Event, EVENT_STATE_CHANGED, State
|
||||||
from homeassistant.const import UnitOfTemperature, STATE_ON, STATE_OFF
|
from homeassistant.const import UnitOfTemperature, STATE_ON, STATE_OFF
|
||||||
@@ -18,6 +19,7 @@ from homeassistant.components.climate import (
|
|||||||
ATTR_PRESET_MODE,
|
ATTR_PRESET_MODE,
|
||||||
HVACMode,
|
HVACMode,
|
||||||
HVACAction,
|
HVACAction,
|
||||||
|
ClimateEntityFeature,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
@@ -78,6 +80,64 @@ class MockClimate(ClimateEntity):
|
|||||||
self._attr_temperature_unit = UnitOfTemperature.CELSIUS
|
self._attr_temperature_unit = UnitOfTemperature.CELSIUS
|
||||||
|
|
||||||
|
|
||||||
|
class MagicMockClimate(MagicMock):
|
||||||
|
@property
|
||||||
|
def temperature_unit(self):
|
||||||
|
return UnitOfTemperature.CELSIUS
|
||||||
|
|
||||||
|
@property
|
||||||
|
def hvac_mode(self):
|
||||||
|
return HVACMode.HEAT
|
||||||
|
|
||||||
|
@property
|
||||||
|
def hvac_action(self):
|
||||||
|
return HVACAction.IDLE
|
||||||
|
|
||||||
|
@property
|
||||||
|
def target_temperature(self):
|
||||||
|
return 15
|
||||||
|
|
||||||
|
@property
|
||||||
|
def current_temperature(self):
|
||||||
|
return 14
|
||||||
|
|
||||||
|
@property
|
||||||
|
def target_temperature_step(self) -> float | None:
|
||||||
|
return 0.5
|
||||||
|
|
||||||
|
@property
|
||||||
|
def target_temperature_high(self) -> float | None:
|
||||||
|
return 35
|
||||||
|
|
||||||
|
@property
|
||||||
|
def target_temperature_low(self) -> float | None:
|
||||||
|
return 7
|
||||||
|
|
||||||
|
@property
|
||||||
|
def hvac_modes(self) -> list[str] | None:
|
||||||
|
return [HVACMode.HEAT, HVACMode.OFF, HVACMode.COOL]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def fan_modes(self) -> list[str] | None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def swing_modes(self) -> list[str] | None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def fan_mode(self) -> str | None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def swing_mode(self) -> str | None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
return ClimateEntityFeature.TARGET_TEMPERATURE
|
||||||
|
|
||||||
|
|
||||||
async def create_thermostat(
|
async def create_thermostat(
|
||||||
hass: HomeAssistant, entry: MockConfigEntry, entity_id: str
|
hass: HomeAssistant, entry: MockConfigEntry, entity_id: str
|
||||||
) -> VersatileThermostat:
|
) -> VersatileThermostat:
|
||||||
@@ -149,7 +209,9 @@ async def send_max_power_change_event(entity: VersatileThermostat, new_power_max
|
|||||||
return await entity._async_max_power_changed(power_event)
|
return await entity._async_max_power_changed(power_event)
|
||||||
|
|
||||||
|
|
||||||
async def send_window_change_event(entity: VersatileThermostat, new_state: bool, date):
|
async def send_window_change_event(
|
||||||
|
entity: VersatileThermostat, new_state: bool, old_state: bool, date
|
||||||
|
):
|
||||||
"""Sending a new window event simulating a change on the window state"""
|
"""Sending a new window event simulating a change on the window state"""
|
||||||
window_event = Event(
|
window_event = Event(
|
||||||
EVENT_STATE_CHANGED,
|
EVENT_STATE_CHANGED,
|
||||||
@@ -162,7 +224,7 @@ async def send_window_change_event(entity: VersatileThermostat, new_state: bool,
|
|||||||
),
|
),
|
||||||
"old_state": State(
|
"old_state": State(
|
||||||
entity_id=entity.entity_id,
|
entity_id=entity.entity_id,
|
||||||
state=STATE_ON if not new_state else STATE_OFF,
|
state=STATE_ON if old_state else STATE_OFF,
|
||||||
last_changed=date,
|
last_changed=date,
|
||||||
last_updated=date,
|
last_updated=date,
|
||||||
),
|
),
|
||||||
@@ -176,3 +238,34 @@ def get_tz(hass):
|
|||||||
"""Get the current timezone"""
|
"""Get the current timezone"""
|
||||||
|
|
||||||
return dt_util.get_time_zone(hass.config.time_zone)
|
return dt_util.get_time_zone(hass.config.time_zone)
|
||||||
|
|
||||||
|
|
||||||
|
async def send_climate_change_event(
|
||||||
|
entity: VersatileThermostat,
|
||||||
|
new_hvac_mode: HVACMode,
|
||||||
|
old_hvac_mode: HVACMode,
|
||||||
|
new_hvac_action: HVACAction,
|
||||||
|
old_hvac_action: HVACAction,
|
||||||
|
date,
|
||||||
|
):
|
||||||
|
"""Sending a new climate event simulating a change on the underlying climate state"""
|
||||||
|
climate_event = Event(
|
||||||
|
EVENT_STATE_CHANGED,
|
||||||
|
{
|
||||||
|
"new_state": State(
|
||||||
|
entity_id=entity.entity_id,
|
||||||
|
state=new_hvac_mode,
|
||||||
|
attributes={"hvac_action": new_hvac_action},
|
||||||
|
last_changed=date,
|
||||||
|
last_updated=date,
|
||||||
|
),
|
||||||
|
"old_state": State(
|
||||||
|
entity_id=entity.entity_id,
|
||||||
|
state=old_hvac_mode,
|
||||||
|
attributes={"hvac_action": old_hvac_action},
|
||||||
|
last_changed=date,
|
||||||
|
last_updated=date,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
ret = await entity._async_climate_changed(climate_event)
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ MOCK_TH_OVER_SWITCH_USER_CONFIG = {
|
|||||||
CONF_CYCLE_MIN: 5,
|
CONF_CYCLE_MIN: 5,
|
||||||
CONF_TEMP_MIN: 15,
|
CONF_TEMP_MIN: 15,
|
||||||
CONF_TEMP_MAX: 30,
|
CONF_TEMP_MAX: 30,
|
||||||
|
CONF_DEVICE_POWER: 1,
|
||||||
CONF_USE_WINDOW_FEATURE: True,
|
CONF_USE_WINDOW_FEATURE: True,
|
||||||
CONF_USE_MOTION_FEATURE: True,
|
CONF_USE_MOTION_FEATURE: True,
|
||||||
CONF_USE_POWER_FEATURE: True,
|
CONF_USE_POWER_FEATURE: True,
|
||||||
@@ -65,6 +66,7 @@ MOCK_TH_OVER_CLIMATE_USER_CONFIG = {
|
|||||||
CONF_CYCLE_MIN: 5,
|
CONF_CYCLE_MIN: 5,
|
||||||
CONF_TEMP_MIN: 15,
|
CONF_TEMP_MIN: 15,
|
||||||
CONF_TEMP_MAX: 30,
|
CONF_TEMP_MAX: 30,
|
||||||
|
CONF_DEVICE_POWER: 1,
|
||||||
# Keep default values which are False
|
# Keep default values which are False
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +105,6 @@ MOCK_MOTION_CONFIG = {
|
|||||||
MOCK_POWER_CONFIG = {
|
MOCK_POWER_CONFIG = {
|
||||||
CONF_POWER_SENSOR: "sensor.power_sensor",
|
CONF_POWER_SENSOR: "sensor.power_sensor",
|
||||||
CONF_MAX_POWER_SENSOR: "sensor.power_max_sensor",
|
CONF_MAX_POWER_SENSOR: "sensor.power_max_sensor",
|
||||||
CONF_DEVICE_POWER: 1,
|
|
||||||
CONF_PRESET_POWER: 10,
|
CONF_PRESET_POWER: 10,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
""" Test the Power management """
|
""" Test the Power management """
|
||||||
from unittest.mock import patch, call
|
from unittest.mock import patch, call, MagicMock
|
||||||
from .commons import * # pylint: disable=wildcard-import, unused-wildcard-import
|
from .commons import * # pylint: disable=wildcard-import, unused-wildcard-import
|
||||||
from datetime import datetime
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
from homeassistant.const import UnitOfTemperature
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@@ -224,7 +226,9 @@ async def test_power_management_hvac_on(hass: HomeAssistant, skip_hass_states_is
|
|||||||
assert mock_heater_off.call_count == 0
|
assert mock_heater_off.call_count == 0
|
||||||
|
|
||||||
|
|
||||||
async def test_power_management_energy(hass: HomeAssistant, skip_hass_states_is_state):
|
async def test_power_management_energy_over_switch(
|
||||||
|
hass: HomeAssistant, skip_hass_states_is_state
|
||||||
|
):
|
||||||
"""Test the Power management energy mesurement"""
|
"""Test the Power management energy mesurement"""
|
||||||
|
|
||||||
entry = MockConfigEntry(
|
entry = MockConfigEntry(
|
||||||
@@ -344,3 +348,100 @@ async def test_power_management_energy(hass: HomeAssistant, skip_hass_states_is_
|
|||||||
# Still no change
|
# Still no change
|
||||||
entity.incremente_energy()
|
entity.incremente_energy()
|
||||||
assert round(entity.total_energy, 2) == round((2.0 + 0.6) * 100 * 5 / 60.0, 2)
|
assert round(entity.total_energy, 2) == round((2.0 + 0.6) * 100 * 5 / 60.0, 2)
|
||||||
|
|
||||||
|
|
||||||
|
async def test_power_management_energy_over_climate(
|
||||||
|
hass: HomeAssistant, skip_hass_states_is_state
|
||||||
|
):
|
||||||
|
"""Test the Power management for a over_climate thermostat"""
|
||||||
|
|
||||||
|
the_mock_underlying = MagicMockClimate()
|
||||||
|
with patch(
|
||||||
|
"custom_components.versatile_thermostat.climate.VersatileThermostat.find_underlying_climate",
|
||||||
|
return_value=the_mock_underlying,
|
||||||
|
):
|
||||||
|
entry = MockConfigEntry(
|
||||||
|
domain=DOMAIN,
|
||||||
|
title="TheOverClimateMockName",
|
||||||
|
unique_id="uniqueId",
|
||||||
|
data={
|
||||||
|
CONF_NAME: "TheOverClimateMockName",
|
||||||
|
CONF_THERMOSTAT_TYPE: CONF_THERMOSTAT_CLIMATE,
|
||||||
|
CONF_TEMP_SENSOR: "sensor.mock_temp_sensor",
|
||||||
|
CONF_EXTERNAL_TEMP_SENSOR: "sensor.mock_ext_temp_sensor",
|
||||||
|
CONF_CYCLE_MIN: 5,
|
||||||
|
CONF_TEMP_MIN: 15,
|
||||||
|
CONF_TEMP_MAX: 30,
|
||||||
|
"eco_temp": 17,
|
||||||
|
"comfort_temp": 18,
|
||||||
|
"boost_temp": 19,
|
||||||
|
CONF_USE_WINDOW_FEATURE: False,
|
||||||
|
CONF_USE_MOTION_FEATURE: False,
|
||||||
|
CONF_USE_POWER_FEATURE: True,
|
||||||
|
CONF_USE_PRESENCE_FEATURE: False,
|
||||||
|
CONF_CLIMATE: "climate.mock_climate",
|
||||||
|
CONF_MINIMAL_ACTIVATION_DELAY: 30,
|
||||||
|
CONF_SECURITY_DELAY_MIN: 5,
|
||||||
|
CONF_SECURITY_MIN_ON_PERCENT: 0.3,
|
||||||
|
CONF_POWER_SENSOR: "sensor.mock_power_sensor",
|
||||||
|
CONF_MAX_POWER_SENSOR: "sensor.mock_power_max_sensor",
|
||||||
|
CONF_DEVICE_POWER: 100,
|
||||||
|
CONF_PRESET_POWER: 12,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
entity: VersatileThermostat = await create_thermostat(
|
||||||
|
hass, entry, "climate.theoverclimatemockname"
|
||||||
|
)
|
||||||
|
assert entity
|
||||||
|
assert entity._is_over_climate
|
||||||
|
|
||||||
|
now = datetime.now(tz=get_tz(hass))
|
||||||
|
await send_temperature_change_event(entity, 15, now)
|
||||||
|
await entity.async_set_hvac_mode(HVACMode.HEAT)
|
||||||
|
await entity.async_set_preset_mode(PRESET_BOOST)
|
||||||
|
|
||||||
|
assert entity.hvac_mode is HVACMode.HEAT
|
||||||
|
assert entity.hvac_action is HVACAction.IDLE
|
||||||
|
assert entity.preset_mode is PRESET_BOOST
|
||||||
|
assert entity.target_temperature == 19
|
||||||
|
assert entity.current_temperature == 15
|
||||||
|
|
||||||
|
# Not initialised yet
|
||||||
|
assert entity.mean_cycle_power is None
|
||||||
|
assert entity._underlying_climate_start_hvac_action_date is None
|
||||||
|
|
||||||
|
# Send a climate_change event with HVACAction=HEATING
|
||||||
|
event_timestamp = now - timedelta(minutes=3)
|
||||||
|
await send_climate_change_event(
|
||||||
|
entity,
|
||||||
|
new_hvac_mode=HVACMode.HEAT,
|
||||||
|
old_hvac_mode=HVACMode.HEAT,
|
||||||
|
new_hvac_action=HVACAction.HEATING,
|
||||||
|
old_hvac_action=HVACAction.OFF,
|
||||||
|
date=event_timestamp,
|
||||||
|
)
|
||||||
|
# We have the start event and not the end event
|
||||||
|
assert (entity._underlying_climate_start_hvac_action_date - now).total_seconds() < 1
|
||||||
|
|
||||||
|
entity.incremente_energy()
|
||||||
|
assert entity.total_energy == 0
|
||||||
|
|
||||||
|
# Send a climate_change event with HVACAction=IDLE (end of heating)
|
||||||
|
await send_climate_change_event(
|
||||||
|
entity,
|
||||||
|
new_hvac_mode=HVACMode.HEAT,
|
||||||
|
old_hvac_mode=HVACMode.HEAT,
|
||||||
|
new_hvac_action=HVACAction.IDLE,
|
||||||
|
old_hvac_action=HVACAction.HEATING,
|
||||||
|
date=now,
|
||||||
|
)
|
||||||
|
# We have the end event -> we should have some power and on_percent
|
||||||
|
assert entity._underlying_climate_start_hvac_action_date is None
|
||||||
|
|
||||||
|
# 3 minutes at 100 W
|
||||||
|
assert entity.total_energy == 100 * 3.0 / 60
|
||||||
|
|
||||||
|
# Test the re-increment
|
||||||
|
entity.incremente_energy()
|
||||||
|
assert entity.total_energy == 2 * 100 * 3.0 / 60
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ async def test_security_feature(hass: HomeAssistant, skip_hass_states_is_state):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# 1. creates a thermostat and check that security is off
|
# 1. creates a thermostat and check that security is off
|
||||||
now: datetime = datetime.now()
|
now: datetime = datetime.now(tz=tz)
|
||||||
entity: VersatileThermostat = await create_thermostat(
|
entity: VersatileThermostat = await create_thermostat(
|
||||||
hass, entry, "climate.theoverswitchmockname"
|
hass, entry, "climate.theoverswitchmockname"
|
||||||
)
|
)
|
||||||
@@ -68,8 +68,10 @@ async def test_security_feature(hass: HomeAssistant, skip_hass_states_is_state):
|
|||||||
]
|
]
|
||||||
assert entity._last_ext_temperature_mesure is not None
|
assert entity._last_ext_temperature_mesure is not None
|
||||||
assert entity._last_temperature_mesure is not None
|
assert entity._last_temperature_mesure is not None
|
||||||
assert (entity._last_temperature_mesure - now).total_seconds() < 1
|
assert (entity._last_temperature_mesure.astimezone(tz) - now).total_seconds() < 1
|
||||||
assert (entity._last_ext_temperature_mesure - now).total_seconds() < 1
|
assert (
|
||||||
|
entity._last_ext_temperature_mesure.astimezone(tz) - now
|
||||||
|
).total_seconds() < 1
|
||||||
|
|
||||||
# set a preset
|
# set a preset
|
||||||
assert entity.preset_mode is PRESET_NONE
|
assert entity.preset_mode is PRESET_NONE
|
||||||
@@ -104,12 +106,8 @@ async def test_security_feature(hass: HomeAssistant, skip_hass_states_is_state):
|
|||||||
call.send_event(
|
call.send_event(
|
||||||
EventType.TEMPERATURE_EVENT,
|
EventType.TEMPERATURE_EVENT,
|
||||||
{
|
{
|
||||||
"last_temperature_mesure": event_timestamp.replace(
|
"last_temperature_mesure": event_timestamp.isoformat(),
|
||||||
tzinfo=tz
|
"last_ext_temperature_mesure": entity._last_ext_temperature_mesure.isoformat(),
|
||||||
).isoformat(),
|
|
||||||
"last_ext_temperature_mesure": entity._last_ext_temperature_mesure.replace(
|
|
||||||
tzinfo=tz
|
|
||||||
).isoformat(),
|
|
||||||
"current_temp": 15,
|
"current_temp": 15,
|
||||||
"current_ext_temp": None,
|
"current_ext_temp": None,
|
||||||
"target_temp": 18,
|
"target_temp": 18,
|
||||||
@@ -119,12 +117,8 @@ async def test_security_feature(hass: HomeAssistant, skip_hass_states_is_state):
|
|||||||
EventType.SECURITY_EVENT,
|
EventType.SECURITY_EVENT,
|
||||||
{
|
{
|
||||||
"type": "start",
|
"type": "start",
|
||||||
"last_temperature_mesure": event_timestamp.replace(
|
"last_temperature_mesure": event_timestamp.isoformat(),
|
||||||
tzinfo=tz
|
"last_ext_temperature_mesure": entity._last_ext_temperature_mesure.isoformat(),
|
||||||
).isoformat(),
|
|
||||||
"last_ext_temperature_mesure": entity._last_ext_temperature_mesure.replace(
|
|
||||||
tzinfo=tz
|
|
||||||
).isoformat(),
|
|
||||||
"current_temp": 15,
|
"current_temp": 15,
|
||||||
"current_ext_temp": None,
|
"current_ext_temp": None,
|
||||||
"target_temp": 18,
|
"target_temp": 18,
|
||||||
@@ -176,11 +170,11 @@ async def test_security_feature(hass: HomeAssistant, skip_hass_states_is_state):
|
|||||||
EventType.SECURITY_EVENT,
|
EventType.SECURITY_EVENT,
|
||||||
{
|
{
|
||||||
"type": "end",
|
"type": "end",
|
||||||
"last_temperature_mesure": event_timestamp.replace(
|
"last_temperature_mesure": event_timestamp.astimezone(
|
||||||
tzinfo=tz
|
tz
|
||||||
).isoformat(),
|
).isoformat(),
|
||||||
"last_ext_temperature_mesure": entity._last_ext_temperature_mesure.replace(
|
"last_ext_temperature_mesure": entity._last_ext_temperature_mesure.astimezone(
|
||||||
tzinfo=tz
|
tz
|
||||||
).isoformat(),
|
).isoformat(),
|
||||||
"current_temp": 15.2,
|
"current_temp": 15.2,
|
||||||
"current_ext_temp": None,
|
"current_ext_temp": None,
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ async def test_window_management_time_not_enough(
|
|||||||
) as mock_condition:
|
) as mock_condition:
|
||||||
await send_temperature_change_event(entity, 15, datetime.now())
|
await send_temperature_change_event(entity, 15, datetime.now())
|
||||||
try_window_condition = await send_window_change_event(
|
try_window_condition = await send_window_change_event(
|
||||||
entity, True, datetime.now()
|
entity, True, False, datetime.now()
|
||||||
)
|
)
|
||||||
# simulate the call to try_window_condition
|
# simulate the call to try_window_condition
|
||||||
await try_window_condition(None)
|
await try_window_condition(None)
|
||||||
@@ -88,7 +88,7 @@ async def test_window_management_time_not_enough(
|
|||||||
|
|
||||||
# Close the window
|
# Close the window
|
||||||
try_window_condition = await send_window_change_event(
|
try_window_condition = await send_window_change_event(
|
||||||
entity, False, datetime.now()
|
entity, False, False, datetime.now()
|
||||||
)
|
)
|
||||||
# simulate the call to try_window_condition
|
# simulate the call to try_window_condition
|
||||||
await try_window_condition(None)
|
await try_window_condition(None)
|
||||||
@@ -163,7 +163,7 @@ async def test_window_management_time_enough(
|
|||||||
):
|
):
|
||||||
await send_temperature_change_event(entity, 15, datetime.now())
|
await send_temperature_change_event(entity, 15, datetime.now())
|
||||||
try_window_condition = await send_window_change_event(
|
try_window_condition = await send_window_change_event(
|
||||||
entity, True, datetime.now()
|
entity, True, False, datetime.now()
|
||||||
)
|
)
|
||||||
# simulate the call to try_window_condition
|
# simulate the call to try_window_condition
|
||||||
await try_window_condition(None)
|
await try_window_condition(None)
|
||||||
@@ -181,7 +181,7 @@ async def test_window_management_time_enough(
|
|||||||
|
|
||||||
# Close the window
|
# Close the window
|
||||||
try_window_condition = await send_window_change_event(
|
try_window_condition = await send_window_change_event(
|
||||||
entity, False, datetime.now()
|
entity, False, True, datetime.now()
|
||||||
)
|
)
|
||||||
# simulate the call to try_window_condition
|
# simulate the call to try_window_condition
|
||||||
await try_window_condition(None)
|
await try_window_condition(None)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
"cycle_min": "Cycle duration (minutes)",
|
"cycle_min": "Cycle duration (minutes)",
|
||||||
"temp_min": "Minimal temperature allowed",
|
"temp_min": "Minimal temperature allowed",
|
||||||
"temp_max": "Maximal temperature allowed",
|
"temp_max": "Maximal temperature allowed",
|
||||||
|
"device_power": "Device power (kW)",
|
||||||
"use_window_feature": "Use window detection",
|
"use_window_feature": "Use window detection",
|
||||||
"use_motion_feature": "Use motion detection",
|
"use_motion_feature": "Use motion detection",
|
||||||
"use_power_feature": "Use power management",
|
"use_power_feature": "Use power management",
|
||||||
@@ -70,7 +71,6 @@
|
|||||||
"data": {
|
"data": {
|
||||||
"power_sensor_entity_id": "Power sensor entity id",
|
"power_sensor_entity_id": "Power sensor entity id",
|
||||||
"max_power_sensor_entity_id": "Max power sensor entity id",
|
"max_power_sensor_entity_id": "Max power sensor entity id",
|
||||||
"device_power": "Device power (kW)",
|
|
||||||
"power_temp": "Temperature for Power shedding"
|
"power_temp": "Temperature for Power shedding"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -117,6 +117,7 @@
|
|||||||
"cycle_min": "Cycle duration (minutes)",
|
"cycle_min": "Cycle duration (minutes)",
|
||||||
"temp_min": "Minimal temperature allowed",
|
"temp_min": "Minimal temperature allowed",
|
||||||
"temp_max": "Maximal temperature allowed",
|
"temp_max": "Maximal temperature allowed",
|
||||||
|
"device_power": "Device power (kW)",
|
||||||
"use_window_feature": "Use window detection",
|
"use_window_feature": "Use window detection",
|
||||||
"use_motion_feature": "Use motion detection",
|
"use_motion_feature": "Use motion detection",
|
||||||
"use_power_feature": "Use power management",
|
"use_power_feature": "Use power management",
|
||||||
@@ -173,7 +174,6 @@
|
|||||||
"data": {
|
"data": {
|
||||||
"power_sensor_entity_id": "Power sensor entity id",
|
"power_sensor_entity_id": "Power sensor entity id",
|
||||||
"max_power_sensor_entity_id": "Max power sensor entity id",
|
"max_power_sensor_entity_id": "Max power sensor entity id",
|
||||||
"device_power": "Device power (kW)",
|
|
||||||
"power_temp": "Temperature for Power shedding"
|
"power_temp": "Temperature for Power shedding"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
"cycle_min": "Durée du cycle (minutes)",
|
"cycle_min": "Durée du cycle (minutes)",
|
||||||
"temp_min": "Température minimale permise",
|
"temp_min": "Température minimale permise",
|
||||||
"temp_max": "Température maximale permise",
|
"temp_max": "Température maximale permise",
|
||||||
|
"device_power": "Puissance de l'équipement",
|
||||||
"use_window_feature": "Avec détection des ouvertures",
|
"use_window_feature": "Avec détection des ouvertures",
|
||||||
"use_motion_feature": "Avec détection de mouvement",
|
"use_motion_feature": "Avec détection de mouvement",
|
||||||
"use_power_feature": "Avec gestion de la puissance",
|
"use_power_feature": "Avec gestion de la puissance",
|
||||||
@@ -69,7 +70,6 @@
|
|||||||
"data": {
|
"data": {
|
||||||
"power_sensor_entity_id": "Capteur de puissance totale (entity id)",
|
"power_sensor_entity_id": "Capteur de puissance totale (entity id)",
|
||||||
"max_power_sensor_entity_id": "Capteur de puissance Max (entity id)",
|
"max_power_sensor_entity_id": "Capteur de puissance Max (entity id)",
|
||||||
"device_power": "Puissance de l'équipement",
|
|
||||||
"power_temp": "Température si délestaqe"
|
"power_temp": "Température si délestaqe"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -117,6 +117,7 @@
|
|||||||
"cycle_min": "Durée du cycle (minutes)",
|
"cycle_min": "Durée du cycle (minutes)",
|
||||||
"temp_min": "Température minimale permise",
|
"temp_min": "Température minimale permise",
|
||||||
"temp_max": "Température maximale permise",
|
"temp_max": "Température maximale permise",
|
||||||
|
"device_power": "Puissance de l'équipement",
|
||||||
"use_window_feature": "Avec détection des ouvertures",
|
"use_window_feature": "Avec détection des ouvertures",
|
||||||
"use_motion_feature": "Avec détection de mouvement",
|
"use_motion_feature": "Avec détection de mouvement",
|
||||||
"use_power_feature": "Avec gestion de la puissance",
|
"use_power_feature": "Avec gestion de la puissance",
|
||||||
@@ -173,7 +174,6 @@
|
|||||||
"data": {
|
"data": {
|
||||||
"power_sensor_entity_id": "Capteur de puissance totale (entity id)",
|
"power_sensor_entity_id": "Capteur de puissance totale (entity id)",
|
||||||
"max_power_sensor_entity_id": "Capteur de puissance Max (entity id)",
|
"max_power_sensor_entity_id": "Capteur de puissance Max (entity id)",
|
||||||
"device_power": "Puissance de l'équipement",
|
|
||||||
"power_temp": "Température si délestaqe"
|
"power_temp": "Température si délestaqe"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user