Add humidity support to homekit thermostats (#33367)
This commit is contained in:
1 parent
f5cbc9d208
commit
6cafc9aaef
3 files changed
+103
No files matched your search
@@ -5,7 +5,9 @@ from unittest.mock import patch
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.climate.const import (
|
||||
ATTR_CURRENT_HUMIDITY,
|
||||
ATTR_CURRENT_TEMPERATURE,
|
||||
ATTR_HUMIDITY,
|
||||
ATTR_HVAC_ACTION,
|
||||
ATTR_HVAC_MODE,
|
||||
ATTR_HVAC_MODES,
|
||||
@@ -18,6 +20,7 @@ from homeassistant.components.climate.const import (
|
||||
CURRENT_HVAC_HEAT,
|
||||
CURRENT_HVAC_IDLE,
|
||||
DEFAULT_MAX_TEMP,
|
||||
DEFAULT_MIN_HUMIDITY,
|
||||
DEFAULT_MIN_TEMP,
|
||||
DOMAIN as DOMAIN_CLIMATE,
|
||||
HVAC_MODE_AUTO,
|
||||
@@ -99,6 +102,8 @@ async def test_thermostat(hass, hk_driver, cls, events):
|
||||
assert acc.char_display_units.value == 0
|
||||
assert acc.char_cooling_thresh_temp is None
|
||||
assert acc.char_heating_thresh_temp is None
|
||||
assert acc.char_target_humidity is None
|
||||
assert acc.char_current_humidity is None
|
||||
|
||||
assert acc.char_target_temp.properties[PROP_MAX_VALUE] == DEFAULT_MAX_TEMP
|
||||
assert acc.char_target_temp.properties[PROP_MIN_VALUE] == DEFAULT_MIN_TEMP
|
||||
@@ -357,6 +362,49 @@ async def test_thermostat_auto(hass, hk_driver, cls, events):
|
||||
assert events[-1].data[ATTR_VALUE] == "cooling threshold 25.0°C"
|
||||
|
||||
|
||||
async def test_thermostat_humidity(hass, hk_driver, cls, events):
|
||||
"""Test if accessory and HA are updated accordingly with humidity."""
|
||||
entity_id = "climate.test"
|
||||
|
||||
# support_auto = True
|
||||
hass.states.async_set(entity_id, HVAC_MODE_OFF, {ATTR_SUPPORTED_FEATURES: 4})
|
||||
await hass.async_block_till_done()
|
||||
acc = cls.thermostat(hass, hk_driver, "Climate", entity_id, 2, None)
|
||||
await hass.async_add_job(acc.run)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert acc.char_target_humidity.value == 50
|
||||
assert acc.char_current_humidity.value == 50
|
||||
|
||||
assert acc.char_target_humidity.properties[PROP_MIN_VALUE] == DEFAULT_MIN_HUMIDITY
|
||||
|
||||
hass.states.async_set(
|
||||
entity_id, HVAC_MODE_HEAT_COOL, {ATTR_HUMIDITY: 65, ATTR_CURRENT_HUMIDITY: 40},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert acc.char_current_humidity.value == 40
|
||||
assert acc.char_target_humidity.value == 65
|
||||
|
||||
hass.states.async_set(
|
||||
entity_id, HVAC_MODE_COOL, {ATTR_HUMIDITY: 35, ATTR_CURRENT_HUMIDITY: 70},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert acc.char_current_humidity.value == 70
|
||||
assert acc.char_target_humidity.value == 35
|
||||
|
||||
# Set from HomeKit
|
||||
call_set_humidity = async_mock_service(hass, DOMAIN_CLIMATE, "set_humidity")
|
||||
|
||||
await hass.async_add_job(acc.char_target_humidity.client_update_value, 35)
|
||||
await hass.async_block_till_done()
|
||||
assert call_set_humidity[0]
|
||||
assert call_set_humidity[0].data[ATTR_ENTITY_ID] == entity_id
|
||||
assert call_set_humidity[0].data[ATTR_HUMIDITY] == 35
|
||||
assert acc.char_target_humidity.value == 35
|
||||
assert len(events) == 1
|
||||
assert events[-1].data[ATTR_VALUE] == "35%"
|
||||
|
||||
|
||||
async def test_thermostat_power_state(hass, hk_driver, cls, events):
|
||||
"""Test if accessory and HA are updated accordingly."""
|
||||
entity_id = "climate.test"
|
||||
|
||||
Reference in new issue
Block a user