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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user