mirror of
https://github.com/Electric-Special/ha-core.git
synced 2026-03-21 06:05:26 +01:00
Update HomeKit humidifiers to handle current humidity (#101964)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"""Test different accessory types: HumidifierDehumidifier."""
|
||||
from pyhap.accessory_driver import AccessoryDriver
|
||||
from pyhap.const import (
|
||||
CATEGORY_HUMIDIFIER,
|
||||
HAP_REPR_AID,
|
||||
@@ -18,6 +19,7 @@ from homeassistant.components.homekit.const import (
|
||||
)
|
||||
from homeassistant.components.homekit.type_humidifiers import HumidifierDehumidifier
|
||||
from homeassistant.components.humidifier import (
|
||||
ATTR_CURRENT_HUMIDITY,
|
||||
ATTR_HUMIDITY,
|
||||
ATTR_MAX_HUMIDITY,
|
||||
ATTR_MIN_HUMIDITY,
|
||||
@@ -75,7 +77,11 @@ async def test_humidifier(hass: HomeAssistant, hk_driver, events) -> None:
|
||||
assert acc.char_target_humidifier_dehumidifier.properties[PROP_VALID_VALUES] == {
|
||||
"Humidifier": 1
|
||||
}
|
||||
|
||||
assert acc.char_current_humidifier_dehumidifier.properties[PROP_VALID_VALUES] == {
|
||||
"Humidifying": 2,
|
||||
"Idle": 1,
|
||||
"Inactive": 0,
|
||||
}
|
||||
hass.states.async_set(
|
||||
entity_id,
|
||||
STATE_ON,
|
||||
@@ -156,6 +162,11 @@ async def test_dehumidifier(hass: HomeAssistant, hk_driver, events) -> None:
|
||||
assert acc.char_target_humidifier_dehumidifier.properties[PROP_VALID_VALUES] == {
|
||||
"Dehumidifier": 2
|
||||
}
|
||||
assert acc.char_current_humidifier_dehumidifier.properties[PROP_VALID_VALUES] == {
|
||||
"Dehumidifying": 3,
|
||||
"Idle": 1,
|
||||
"Inactive": 0,
|
||||
}
|
||||
|
||||
hass.states.async_set(
|
||||
entity_id,
|
||||
@@ -523,3 +534,30 @@ async def test_dehumidifier_as_humidifier(
|
||||
await hass.async_block_till_done()
|
||||
assert "TargetHumidifierDehumidifierState is not supported" in caplog.text
|
||||
assert len(events) == 0
|
||||
|
||||
|
||||
async def test_humidifier_that_reports_current_humidity(
|
||||
hass: HomeAssistant, hk_driver: AccessoryDriver
|
||||
) -> None:
|
||||
"""Test a humidifier that provides current humidity can update."""
|
||||
entity_id = "humidifier.test"
|
||||
hass.states.async_set(entity_id, STATE_OFF, {ATTR_CURRENT_HUMIDITY: 42})
|
||||
await hass.async_block_till_done()
|
||||
acc = HumidifierDehumidifier(
|
||||
hass,
|
||||
hk_driver,
|
||||
"HumidifierDehumidifier",
|
||||
entity_id,
|
||||
1,
|
||||
{},
|
||||
)
|
||||
hk_driver.add_accessory(acc)
|
||||
|
||||
await acc.run()
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert acc.char_current_humidity.value == 42.0
|
||||
hass.states.async_set(entity_id, STATE_OFF, {ATTR_CURRENT_HUMIDITY: 43})
|
||||
|
||||
await hass.async_block_till_done()
|
||||
assert acc.char_current_humidity.value == 43.0
|
||||
|
||||
Reference in New Issue
Block a user