mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Add current_humidity
state attribute to Google Nest climate entity (#134426)
This commit is contained in:
parent
87454babfa
commit
c8699dc066
@ -5,7 +5,7 @@ from __future__ import annotations
|
||||
from typing import Any, cast
|
||||
|
||||
from google_nest_sdm.device import Device
|
||||
from google_nest_sdm.device_traits import FanTrait, TemperatureTrait
|
||||
from google_nest_sdm.device_traits import FanTrait, HumidityTrait, TemperatureTrait
|
||||
from google_nest_sdm.exceptions import ApiException
|
||||
from google_nest_sdm.thermostat_traits import (
|
||||
ThermostatEcoTrait,
|
||||
@ -133,6 +133,14 @@ class ThermostatEntity(ClimateEntity):
|
||||
trait: TemperatureTrait = self._device.traits[TemperatureTrait.NAME]
|
||||
return trait.ambient_temperature_celsius
|
||||
|
||||
@property
|
||||
def current_humidity(self) -> float | None:
|
||||
"""Return the current humidity."""
|
||||
if HumidityTrait.NAME not in self._device.traits:
|
||||
return None
|
||||
trait: HumidityTrait = self._device.traits[HumidityTrait.NAME]
|
||||
return trait.ambient_humidity_percent
|
||||
|
||||
@property
|
||||
def target_temperature(self) -> float | None:
|
||||
"""Return the temperature currently set to be reached."""
|
||||
|
@ -13,6 +13,7 @@ import aiohttp
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.climate import (
|
||||
ATTR_CURRENT_HUMIDITY,
|
||||
ATTR_CURRENT_TEMPERATURE,
|
||||
ATTR_FAN_MODE,
|
||||
ATTR_FAN_MODES,
|
||||
@ -122,6 +123,9 @@ async def test_thermostat_off(
|
||||
"sdm.devices.traits.Temperature": {
|
||||
"ambientTemperatureCelsius": 16.2,
|
||||
},
|
||||
"sdm.devices.traits.Humidity": {
|
||||
"ambientHumidityPercent": 40.6,
|
||||
},
|
||||
},
|
||||
)
|
||||
await setup_platform()
|
||||
@ -131,6 +135,7 @@ async def test_thermostat_off(
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVACMode.OFF
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.OFF
|
||||
assert thermostat.attributes[ATTR_CURRENT_HUMIDITY] == 40.6
|
||||
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 16.2
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
|
||||
HVACMode.HEAT,
|
||||
@ -163,6 +168,9 @@ async def test_thermostat_heat(
|
||||
"sdm.devices.traits.Temperature": {
|
||||
"ambientTemperatureCelsius": 16.2,
|
||||
},
|
||||
"sdm.devices.traits.Humidity": {
|
||||
"ambientHumidityPercent": 40.6,
|
||||
},
|
||||
"sdm.devices.traits.ThermostatTemperatureSetpoint": {
|
||||
"heatCelsius": 22.0,
|
||||
},
|
||||
@ -175,6 +183,7 @@ async def test_thermostat_heat(
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVACMode.HEAT
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.HEATING
|
||||
assert thermostat.attributes[ATTR_CURRENT_HUMIDITY] == 40.6
|
||||
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 16.2
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
|
||||
HVACMode.HEAT,
|
||||
@ -883,6 +892,9 @@ async def test_thermostat_fan_off(
|
||||
"sdm.devices.traits.Temperature": {
|
||||
"ambientTemperatureCelsius": 16.2,
|
||||
},
|
||||
"sdm.devices.traits.Humidity": {
|
||||
"ambientHumidityPercent": 40.6,
|
||||
},
|
||||
}
|
||||
)
|
||||
await setup_platform()
|
||||
@ -892,6 +904,7 @@ async def test_thermostat_fan_off(
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVACMode.COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.IDLE
|
||||
assert thermostat.attributes[ATTR_CURRENT_HUMIDITY] == 40.6
|
||||
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 16.2
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
|
||||
HVACMode.HEAT,
|
||||
@ -932,6 +945,9 @@ async def test_thermostat_fan_on(
|
||||
"sdm.devices.traits.Temperature": {
|
||||
"ambientTemperatureCelsius": 16.2,
|
||||
},
|
||||
"sdm.devices.traits.Humidity": {
|
||||
"ambientHumidityPercent": 40.6,
|
||||
},
|
||||
}
|
||||
)
|
||||
await setup_platform()
|
||||
@ -941,6 +957,7 @@ async def test_thermostat_fan_on(
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVACMode.COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.IDLE
|
||||
assert thermostat.attributes[ATTR_CURRENT_HUMIDITY] == 40.6
|
||||
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 16.2
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
|
||||
HVACMode.HEAT,
|
||||
@ -1128,6 +1145,9 @@ async def test_thermostat_fan_empty(
|
||||
"sdm.devices.traits.Temperature": {
|
||||
"ambientTemperatureCelsius": 16.2,
|
||||
},
|
||||
"sdm.devices.traits.Humidity": {
|
||||
"ambientHumidityPercent": 40.6,
|
||||
},
|
||||
}
|
||||
)
|
||||
await setup_platform()
|
||||
@ -1137,6 +1157,7 @@ async def test_thermostat_fan_empty(
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVACMode.OFF
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.OFF
|
||||
assert thermostat.attributes[ATTR_CURRENT_HUMIDITY] == 40.6
|
||||
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 16.2
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
|
||||
HVACMode.HEAT,
|
||||
@ -1181,6 +1202,9 @@ async def test_thermostat_invalid_fan_mode(
|
||||
"sdm.devices.traits.Temperature": {
|
||||
"ambientTemperatureCelsius": 16.2,
|
||||
},
|
||||
"sdm.devices.traits.Humidity": {
|
||||
"ambientHumidityPercent": 40.6,
|
||||
},
|
||||
}
|
||||
)
|
||||
await setup_platform()
|
||||
@ -1190,6 +1214,7 @@ async def test_thermostat_invalid_fan_mode(
|
||||
assert thermostat is not None
|
||||
assert thermostat.state == HVACMode.COOL
|
||||
assert thermostat.attributes[ATTR_HVAC_ACTION] == HVACAction.IDLE
|
||||
assert thermostat.attributes[ATTR_CURRENT_HUMIDITY] == 40.6
|
||||
assert thermostat.attributes[ATTR_CURRENT_TEMPERATURE] == 16.2
|
||||
assert set(thermostat.attributes[ATTR_HVAC_MODES]) == {
|
||||
HVACMode.HEAT,
|
||||
|
Loading…
x
Reference in New Issue
Block a user