Skip to content

Commit

Permalink
Revamp presets (#41)
Browse files Browse the repository at this point in the history
This change removes the `LOCKED` and `NONE` presets, introduces the `ECO` and
`COMFORT` presets, and makes the `OPEN` preset clear the boost and away modes.

This means that now:
  * the child lock is no longer affected by changing presets
  * feature parity with the TRV display/buttons is achieved with regards to
    setting and viewing current comfort/eco mode
  * ambiguity regarding what temperature to set with the NONE preset is avoided
  * the `OPEN`, `ECO`, and `COMFORT` presets now clear the Boost/Away functions
  • Loading branch information
ignisf authored Jan 25, 2023
1 parent cc6707d commit 7da10c3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
29 changes: 18 additions & 11 deletions custom_components/dbuezas_eq3btsmart/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
ATTR_HVAC_MODE,
ClimateEntityFeature,
HVACAction,
PRESET_NONE,
)
from homeassistant.components.climate import HVACMode

Expand Down Expand Up @@ -261,11 +262,13 @@ def preset_mode(self):
return "Low Battery"
if self._thermostat.away:
return Preset.AWAY
if self._thermostat.locked:
return Preset.LOCKED
if self.target_temperature == self._thermostat.eco_temperature:
return Preset.ECO
if self.target_temperature == self._thermostat.comfort_temperature:
return Preset.COMFORT
if self._thermostat.mode == Mode.On:
return Preset.OPEN
return Preset.NONE
return PRESET_NONE

async def async_set_preset_mode(self, preset_mode):
"""Set new preset mode."""
Expand All @@ -274,23 +277,27 @@ async def async_set_preset_mode(self, preset_mode):
await self._thermostat.async_set_boost(True)
case Preset.AWAY:
await self._thermostat.async_set_away(True)
case Preset.LOCKED:
await self._thermostat.async_set_locked(True)
case Preset.ECO:
if self._thermostat.boost:
await self._thermostat.async_set_boost(False)
if self._thermostat.away:
await self._thermostat.async_set_away(False)

await self._thermostat.async_activate_eco()
case Preset.COMFORT:
if self._thermostat.boost:
await self._thermostat.async_set_boost(False)
if self._thermostat.away:
await self._thermostat.async_set_away(False)

await self._thermostat.async_activate_comfort()
case Preset.OPEN:
await self._thermostat.async_set_mode(Mode.On)
case Preset.NONE:
if self._thermostat.locked:
await self._thermostat.async_set_locked(False)
if self._thermostat.boost:
await self._thermostat.async_set_boost(False)
if self._thermostat.away:
await self._thermostat.async_set_away(False)
if self._thermostat.mode == Mode.On:
await self._thermostat.async_activate_comfort()

await self._thermostat.async_set_mode(Mode.On)

# by now, the target temperature should have been (maybe set) and fetched
self._target_temperature_to_set = self.target_temperature
Expand Down
3 changes: 0 additions & 3 deletions custom_components/dbuezas_eq3btsmart/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
PRESET_BOOST,
PRESET_ECO,
PRESET_COMFORT,
PRESET_NONE,
)

EQ_TO_HA_HVAC = {
Expand All @@ -28,12 +27,10 @@


class Preset(str, Enum):
NONE = PRESET_NONE
ECO = PRESET_ECO
COMFORT = PRESET_COMFORT
BOOST = PRESET_BOOST
AWAY = PRESET_AWAY
LOCKED = "Locked"
OPEN = "Open"


Expand Down

0 comments on commit 7da10c3

Please sign in to comment.