From 8d9b66e23daba8526d6778f70d0f29ce0beb34f9 Mon Sep 17 00:00:00 2001 From: Raman Gupta <7243222+raman325@users.noreply.github.com> Date: Tue, 2 Feb 2021 02:41:00 -0600 Subject: [PATCH] Add current humidity to zwave_js climate platform (#45857) --- homeassistant/components/zwave_js/climate.py | 11 +++++++++++ tests/components/zwave_js/test_climate.py | 2 ++ 2 files changed, 13 insertions(+) diff --git a/homeassistant/components/zwave_js/climate.py b/homeassistant/components/zwave_js/climate.py index 6c0b4a0335e..417f5aa5e5d 100644 --- a/homeassistant/components/zwave_js/climate.py +++ b/homeassistant/components/zwave_js/climate.py @@ -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.""" diff --git a/tests/components/zwave_js/test_climate.py b/tests/components/zwave_js/test_climate.py index f7deefc1360..bede37e6959 100644 --- a/tests/components/zwave_js/test_climate.py +++ b/tests/components/zwave_js/test_climate.py @@ -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