Set nest climate hvac_action to report idle when hvac mode is not off (#62811)

This commit is contained in:
Allen Porter 2022-01-04 08:28:46 -08:00 committed by GitHub
parent 829ff9c423
commit 0bcad5579b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View File

@ -20,6 +20,7 @@ from homeassistant.components.climate.const import (
ATTR_TARGET_TEMP_LOW, ATTR_TARGET_TEMP_LOW,
CURRENT_HVAC_COOL, CURRENT_HVAC_COOL,
CURRENT_HVAC_HEAT, CURRENT_HVAC_HEAT,
CURRENT_HVAC_IDLE,
CURRENT_HVAC_OFF, CURRENT_HVAC_OFF,
FAN_OFF, FAN_OFF,
FAN_ON, FAN_ON,
@ -234,6 +235,8 @@ class ThermostatEntity(ClimateEntity):
def hvac_action(self) -> str | None: def hvac_action(self) -> str | None:
"""Return the current HVAC action (heating, cooling).""" """Return the current HVAC action (heating, cooling)."""
trait = self._device.traits[ThermostatHvacTrait.NAME] trait = self._device.traits[ThermostatHvacTrait.NAME]
if trait.status == "OFF" and self.hvac_mode != HVAC_MODE_OFF:
return CURRENT_HVAC_IDLE
if trait.status in THERMOSTAT_HVAC_STATUS_MAP: if trait.status in THERMOSTAT_HVAC_STATUS_MAP:
return THERMOSTAT_HVAC_STATUS_MAP[trait.status] return THERMOSTAT_HVAC_STATUS_MAP[trait.status]
return None return None

View File

@ -21,6 +21,7 @@ from homeassistant.components.climate.const import (
ATTR_TARGET_TEMP_LOW, ATTR_TARGET_TEMP_LOW,
CURRENT_HVAC_COOL, CURRENT_HVAC_COOL,
CURRENT_HVAC_HEAT, CURRENT_HVAC_HEAT,
CURRENT_HVAC_IDLE,
CURRENT_HVAC_OFF, CURRENT_HVAC_OFF,
FAN_LOW, FAN_LOW,
FAN_OFF, FAN_OFF,
@ -356,7 +357,7 @@ async def test_thermostat_eco_heat_only(hass):
thermostat = hass.states.get("climate.my_thermostat") thermostat = hass.states.get("climate.my_thermostat")
assert thermostat is not None assert thermostat is not None
assert thermostat.state == HVAC_MODE_HEAT assert thermostat.state == HVAC_MODE_HEAT
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_OFF assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_IDLE
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 29.9 assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 29.9
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == { assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
HVAC_MODE_HEAT, HVAC_MODE_HEAT,
@ -428,7 +429,7 @@ async def test_thermostat_set_hvac_mode(hass, auth):
thermostat = hass.states.get("climate.my_thermostat") thermostat = hass.states.get("climate.my_thermostat")
assert thermostat is not None assert thermostat is not None
assert thermostat.state == HVAC_MODE_HEAT assert thermostat.state == HVAC_MODE_HEAT
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_OFF assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_IDLE
# Simulate pubsub message when the thermostat starts heating # Simulate pubsub message when the thermostat starts heating
event = EventMessage( event = EventMessage(
@ -733,7 +734,7 @@ async def test_thermostat_fan_on(hass):
thermostat = hass.states.get("climate.my_thermostat") thermostat = hass.states.get("climate.my_thermostat")
assert thermostat is not None assert thermostat is not None
assert thermostat.state == HVAC_MODE_FAN_ONLY assert thermostat.state == HVAC_MODE_FAN_ONLY
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_OFF assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_IDLE
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 16.2 assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 16.2
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == { assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
HVAC_MODE_HEAT, HVAC_MODE_HEAT,
@ -769,7 +770,7 @@ async def test_thermostat_cool_with_fan(hass):
thermostat = hass.states.get("climate.my_thermostat") thermostat = hass.states.get("climate.my_thermostat")
assert thermostat is not None assert thermostat is not None
assert thermostat.state == HVAC_MODE_COOL assert thermostat.state == HVAC_MODE_COOL
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_OFF assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_IDLE
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == { assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
HVAC_MODE_HEAT, HVAC_MODE_HEAT,
HVAC_MODE_COOL, HVAC_MODE_COOL,
@ -898,7 +899,7 @@ async def test_thermostat_invalid_fan_mode(hass):
thermostat = hass.states.get("climate.my_thermostat") thermostat = hass.states.get("climate.my_thermostat")
assert thermostat is not None assert thermostat is not None
assert thermostat.state == HVAC_MODE_FAN_ONLY assert thermostat.state == HVAC_MODE_FAN_ONLY
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_OFF assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_IDLE
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 16.2 assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 16.2
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == { assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
HVAC_MODE_HEAT, HVAC_MODE_HEAT,
@ -1075,7 +1076,7 @@ async def test_thermostat_missing_temperature_trait(hass):
thermostat = hass.states.get("climate.my_thermostat") thermostat = hass.states.get("climate.my_thermostat")
assert thermostat is not None assert thermostat is not None
assert thermostat.state == HVAC_MODE_HEAT assert thermostat.state == HVAC_MODE_HEAT
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_OFF assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_IDLE
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] is None assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] is None
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == { assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
HVAC_MODE_HEAT, HVAC_MODE_HEAT,
@ -1143,7 +1144,7 @@ async def test_thermostat_missing_set_point(hass):
thermostat = hass.states.get("climate.my_thermostat") thermostat = hass.states.get("climate.my_thermostat")
assert thermostat is not None assert thermostat is not None
assert thermostat.state == HVAC_MODE_HEAT_COOL assert thermostat.state == HVAC_MODE_HEAT_COOL
assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_OFF assert thermostat.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_IDLE
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] is None assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] is None
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == { assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
HVAC_MODE_HEAT, HVAC_MODE_HEAT,