Add deconz current hvac operation to thermostate based on "state" (#59989)

* deconz - add current hvac operation to thermostate based on "state"

* deconz - extend current hvac operation to thermostate based on "state" and "mode"

* Add tests for current hvac action

* Add boost mode as special case

* format using Black

* sort imports

* Add test for device with mode none and state none

* Update homeassistant/components/deconz/climate.py

Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>

* Fix test_climate.py test_no_mode_no_state

* Add test for boost mode

Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
This commit is contained in:
Michael Jäger 2022-09-21 08:20:44 +02:00 committed by GitHub
parent d7eb277bc8
commit 7a6897c757
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 216 additions and 1 deletions

View file

@ -24,6 +24,7 @@ from homeassistant.components.climate import (
PRESET_ECO,
ClimateEntity,
ClimateEntityFeature,
HVACAction,
HVACMode,
)
from homeassistant.config_entries import ConfigEntry
@ -172,6 +173,21 @@ class DeconzThermostat(DeconzDevice[Thermostat], ClimateEntity):
mode=HVAC_MODE_TO_DECONZ[hvac_mode],
)
@property
def hvac_action(self) -> str | None:
"""Return current hvac operation ie. heat, cool.
Preset 'BOOST' is interpreted as 'state_on'.
"""
if self._device.mode == ThermostatMode.OFF:
return HVACAction.OFF
if self._device.state_on or self._device.preset == ThermostatPreset.BOOST:
if self._device.mode == ThermostatMode.COOL:
return HVACAction.COOLING
return HVACAction.HEATING
return HVACAction.IDLE
# Preset control
@property