1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Register Wemo fan services with entity service helper (#44192)

* Use a singleton for the Wemo registry and fan services

* Undo changes to the wemo subscription registry

* Use an entity service helper to register the Wemo fan services

* Fix Wemo fan test (missing ATTR_ENTITY_ID)

* Use the function name directly rather than a string

* Improve test coverage of the set_humidity service
This commit is contained in:
Eric Severance
2020-12-15 05:19:57 -08:00
committed by GitHub
parent 69a7eff55d
commit 2765c6f1e9
2 changed files with 44 additions and 58 deletions

View File

@@ -87,21 +87,34 @@ async def test_fan_reset_filter_service(hass, pywemo_device, wemo_entity):
assert await hass.services.async_call(
DOMAIN,
fan.SERVICE_RESET_FILTER_LIFE,
{fan.ATTR_ENTITY_ID: wemo_entity.entity_id},
{ATTR_ENTITY_ID: wemo_entity.entity_id},
blocking=True,
)
pywemo_device.reset_filter_life.assert_called_with()
async def test_fan_set_humidity_service(hass, pywemo_device, wemo_entity):
@pytest.mark.parametrize(
"test_input,expected",
[
(0, fan.WEMO_HUMIDITY_45),
(45, fan.WEMO_HUMIDITY_45),
(50, fan.WEMO_HUMIDITY_50),
(55, fan.WEMO_HUMIDITY_55),
(60, fan.WEMO_HUMIDITY_60),
(100, fan.WEMO_HUMIDITY_100),
],
)
async def test_fan_set_humidity_service(
hass, pywemo_device, wemo_entity, test_input, expected
):
"""Verify that SERVICE_SET_HUMIDITY is registered and works."""
assert await hass.services.async_call(
DOMAIN,
fan.SERVICE_SET_HUMIDITY,
{
fan.ATTR_ENTITY_ID: wemo_entity.entity_id,
fan.ATTR_TARGET_HUMIDITY: "50",
ATTR_ENTITY_ID: wemo_entity.entity_id,
fan.ATTR_TARGET_HUMIDITY: test_input,
},
blocking=True,
)
pywemo_device.set_humidity.assert_called_with(fan.WEMO_HUMIDITY_50)
pywemo_device.set_humidity.assert_called_with(expected)