Skip to content

Commit

Permalink
issue with ac and mouvement detection (#471)
Browse files Browse the repository at this point in the history
* Update base_thermostat.py

issue with ac and mouvement detection

* issue ac with detection mouvement

modif class find_preset_temps for preset activity
  • Loading branch information
cddu33 authored Jun 17, 2024
1 parent 53dce22 commit 0ee4fe3
Showing 1 changed file with 30 additions and 13 deletions.
43 changes: 30 additions & 13 deletions custom_components/versatile_thermostat/base_thermostat.py
Original file line number Diff line number Diff line change
Expand Up @@ -1377,11 +1377,19 @@ def find_preset_temp(self, preset_mode: str):
if preset_mode == PRESET_POWER:
return self._power_temp
if preset_mode == PRESET_ACTIVITY:
motion_preset = (
self._motion_preset
if self._motion_state == STATE_ON
else self._no_motion_preset
)
if self._ac_mode and self._hvac_mode == HVACMode.COOL:
motion_preset = (
self._motion_preset + PRESET_AC_SUFFIX
if self._motion_state == STATE_ON
else self._no_motion_preset + PRESET_AC_SUFFIX
)
else:
motion_preset = (
self._motion_preset
if self._motion_state == STATE_ON
else self._no_motion_preset
)

if motion_preset in self._presets:
return self._presets[motion_preset]
else:
Expand Down Expand Up @@ -1646,6 +1654,7 @@ async def try_motion_condition(_):
_LOGGER.debug("%s - Motion delay condition is satisfied", self)
self._motion_state = new_state.state
if self._attr_preset_mode == PRESET_ACTIVITY:

new_preset = (
self._motion_preset
if self._motion_state == STATE_ON
Expand All @@ -1658,6 +1667,7 @@ async def try_motion_condition(_):
)
# We do not change the preset which is kept to ACTIVITY but only the target_temperature
# We take the presence into account

await self._async_internal_set_temperature(
self.find_preset_temp(new_preset)
)
Expand Down Expand Up @@ -1895,17 +1905,24 @@ async def _async_update_motion_temp(self):
or self._attr_preset_mode != PRESET_ACTIVITY
):
return

new_preset = (
self._motion_preset
if self._motion_state == STATE_ON
else self._no_motion_preset
)
_LOGGER.info(
"%s - Motion condition have changes. New preset temp will be %s",
self,
new_preset,
)
# We do not change the preset which is kept to ACTIVITY but only the target_temperature
# We take the presence into account

await self._async_internal_set_temperature(
self._presets.get(
(
self._motion_preset
if self._motion_state == STATE_ON
else self._no_motion_preset
),
None,
)
self.find_preset_temp(new_preset)
)

_LOGGER.debug(
"%s - regarding motion, target_temp have been set to %.2f",
self,
Expand Down

0 comments on commit 0ee4fe3

Please sign in to comment.