mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Fix fan device actions (#102797)
This commit is contained in:
parent
e5078a3e13
commit
43ac77ca2f
@ -3,14 +3,24 @@ from __future__ import annotations
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.device_automation import toggle_entity
|
||||
from homeassistant.components.device_automation import (
|
||||
async_validate_entity_schema,
|
||||
toggle_entity,
|
||||
)
|
||||
from homeassistant.const import CONF_DOMAIN
|
||||
from homeassistant.core import Context, HomeAssistant
|
||||
from homeassistant.helpers.typing import ConfigType, TemplateVarsType
|
||||
|
||||
from . import DOMAIN
|
||||
|
||||
ACTION_SCHEMA = toggle_entity.ACTION_SCHEMA.extend({vol.Required(CONF_DOMAIN): DOMAIN})
|
||||
_ACTION_SCHEMA = toggle_entity.ACTION_SCHEMA.extend({vol.Required(CONF_DOMAIN): DOMAIN})
|
||||
|
||||
|
||||
async def async_validate_action_config(
|
||||
hass: HomeAssistant, config: ConfigType
|
||||
) -> ConfigType:
|
||||
"""Validate config."""
|
||||
return async_validate_entity_schema(hass, config, _ACTION_SCHEMA)
|
||||
|
||||
|
||||
async def async_get_actions(
|
||||
|
@ -171,6 +171,7 @@ async def test_action(
|
||||
hass.bus.async_fire("test_event_turn_off")
|
||||
await hass.async_block_till_done()
|
||||
assert len(turn_off_calls) == 1
|
||||
assert turn_off_calls[0].data["entity_id"] == entry.entity_id
|
||||
assert len(turn_on_calls) == 0
|
||||
assert len(toggle_calls) == 0
|
||||
|
||||
@ -178,6 +179,7 @@ async def test_action(
|
||||
await hass.async_block_till_done()
|
||||
assert len(turn_off_calls) == 1
|
||||
assert len(turn_on_calls) == 1
|
||||
assert turn_on_calls[0].data["entity_id"] == entry.entity_id
|
||||
assert len(toggle_calls) == 0
|
||||
|
||||
hass.bus.async_fire("test_event_toggle")
|
||||
@ -185,6 +187,7 @@ async def test_action(
|
||||
assert len(turn_off_calls) == 1
|
||||
assert len(turn_on_calls) == 1
|
||||
assert len(toggle_calls) == 1
|
||||
assert toggle_calls[0].data["entity_id"] == entry.entity_id
|
||||
|
||||
|
||||
async def test_action_legacy(
|
||||
|
Loading…
x
Reference in New Issue
Block a user