1
mirror of https://github.com/home-assistant/core synced 2024-09-06 10:29:55 +02:00

Add current humidity to zwave_js climate platform (#45857)

This commit is contained in:
Raman Gupta 2021-02-02 02:41:00 -06:00 committed by GitHub
parent 3ef7bd6b73
commit 8d9b66e23d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -142,6 +142,12 @@ class ZWaveClimate(ZWaveBaseEntity, ClimateEntity):
add_to_watched_value_ids=True,
check_all_endpoints=True,
)
self._current_humidity = self.get_zwave_value(
"Humidity",
command_class=CommandClass.SENSOR_MULTILEVEL,
add_to_watched_value_ids=True,
check_all_endpoints=True,
)
self._set_modes_and_presets()
def _setpoint_value(self, setpoint_type: ThermostatSetpointType) -> ZwaveValue:
@ -207,6 +213,11 @@ class ZWaveClimate(ZWaveBaseEntity, ClimateEntity):
return None
return HVAC_CURRENT_MAP.get(int(self._operating_state.value))
@property
def current_humidity(self) -> Optional[int]:
"""Return the current humidity level."""
return self._current_humidity.value if self._current_humidity else None
@property
def current_temperature(self) -> Optional[float]:
"""Return the current temperature."""

View File

@ -3,6 +3,7 @@ import pytest
from zwave_js_server.event import Event
from homeassistant.components.climate.const import (
ATTR_CURRENT_HUMIDITY,
ATTR_CURRENT_TEMPERATURE,
ATTR_HVAC_ACTION,
ATTR_HVAC_MODE,
@ -42,6 +43,7 @@ async def test_thermostat_v2(
HVAC_MODE_COOL,
HVAC_MODE_HEAT_COOL,
]
assert state.attributes[ATTR_CURRENT_HUMIDITY] == 30
assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 22.2
assert state.attributes[ATTR_TEMPERATURE] == 22.2
assert state.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_IDLE