2019-09-24 21:57:05 +00:00
|
|
|
"""The test for switch device automation."""
|
2019-10-02 20:14:52 +00:00
|
|
|
from datetime import timedelta
|
2019-12-08 17:50:17 +00:00
|
|
|
|
2019-09-24 21:57:05 +00:00
|
|
|
import pytest
|
2023-06-20 18:23:14 +00:00
|
|
|
from pytest_unordered import unordered
|
2019-09-24 21:57:05 +00:00
|
|
|
|
|
|
|
import homeassistant.components.automation as automation
|
2021-12-21 10:56:00 +00:00
|
|
|
from homeassistant.components.device_automation import DeviceAutomationType
|
2019-12-08 17:50:17 +00:00
|
|
|
from homeassistant.components.switch import DOMAIN
|
2023-06-26 07:59:01 +00:00
|
|
|
from homeassistant.const import STATE_OFF, STATE_ON, EntityCategory
|
2023-02-16 10:15:26 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
2022-04-21 06:01:32 +00:00
|
|
|
from homeassistant.helpers.entity_registry import RegistryEntryHider
|
2019-12-08 17:50:17 +00:00
|
|
|
from homeassistant.setup import async_setup_component
|
2019-10-02 20:14:52 +00:00
|
|
|
import homeassistant.util.dt as dt_util
|
2019-09-24 21:57:05 +00:00
|
|
|
|
|
|
|
from tests.common import (
|
|
|
|
MockConfigEntry,
|
2019-10-02 20:14:52 +00:00
|
|
|
async_fire_time_changed,
|
2019-12-08 17:50:17 +00:00
|
|
|
async_get_device_automation_capabilities,
|
|
|
|
async_get_device_automations,
|
2019-09-24 21:57:05 +00:00
|
|
|
async_mock_service,
|
|
|
|
)
|
2023-05-25 11:45:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(autouse=True, name="stub_blueprint_populate")
|
2023-05-26 06:13:13 +00:00
|
|
|
def stub_blueprint_populate_autouse(stub_blueprint_populate: None) -> None:
|
2023-05-25 11:45:19 +00:00
|
|
|
"""Stub copying the blueprints to the config folder."""
|
2019-09-24 21:57:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def calls(hass):
|
2020-01-27 18:56:26 +00:00
|
|
|
"""Track calls to a mock service."""
|
2019-09-24 21:57:05 +00:00
|
|
|
return async_mock_service(hass, "test", "automation")
|
|
|
|
|
|
|
|
|
2023-02-16 10:15:26 +00:00
|
|
|
async def test_get_triggers(
|
|
|
|
hass: HomeAssistant,
|
|
|
|
device_registry: dr.DeviceRegistry,
|
|
|
|
entity_registry: er.EntityRegistry,
|
|
|
|
) -> None:
|
2019-09-24 21:57:05 +00:00
|
|
|
"""Test we get the expected triggers from a switch."""
|
|
|
|
config_entry = MockConfigEntry(domain="test", data={})
|
|
|
|
config_entry.add_to_hass(hass)
|
2023-02-08 19:28:44 +00:00
|
|
|
device_entry = device_registry.async_get_or_create(
|
2019-09-24 21:57:05 +00:00
|
|
|
config_entry_id=config_entry.entry_id,
|
2023-02-08 19:28:44 +00:00
|
|
|
connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
|
|
|
)
|
2023-06-26 07:59:01 +00:00
|
|
|
entity_entry = entity_registry.async_get_or_create(
|
2023-02-08 19:28:44 +00:00
|
|
|
DOMAIN, "test", "5678", device_id=device_entry.id
|
2019-09-24 21:57:05 +00:00
|
|
|
)
|
|
|
|
expected_triggers = [
|
2022-01-03 09:41:30 +00:00
|
|
|
{
|
|
|
|
"platform": "device",
|
|
|
|
"domain": DOMAIN,
|
2022-04-21 06:01:32 +00:00
|
|
|
"type": trigger,
|
2022-01-03 09:41:30 +00:00
|
|
|
"device_id": device_entry.id,
|
2023-06-26 07:59:01 +00:00
|
|
|
"entity_id": entity_entry.id,
|
2022-04-21 06:01:32 +00:00
|
|
|
"metadata": {"secondary": False},
|
|
|
|
}
|
|
|
|
for trigger in ["changed_states", "turned_off", "turned_on"]
|
|
|
|
]
|
|
|
|
triggers = await async_get_device_automations(
|
|
|
|
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
|
|
|
)
|
2023-06-20 18:23:14 +00:00
|
|
|
assert triggers == unordered(expected_triggers)
|
2022-04-21 06:01:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
2023-02-15 13:09:50 +00:00
|
|
|
("hidden_by", "entity_category"),
|
2022-04-21 06:01:32 +00:00
|
|
|
(
|
|
|
|
(RegistryEntryHider.INTEGRATION, None),
|
|
|
|
(RegistryEntryHider.USER, None),
|
|
|
|
(None, EntityCategory.CONFIG),
|
|
|
|
(None, EntityCategory.DIAGNOSTIC),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
async def test_get_triggers_hidden_auxiliary(
|
2023-02-16 10:15:26 +00:00
|
|
|
hass: HomeAssistant,
|
|
|
|
device_registry: dr.DeviceRegistry,
|
|
|
|
entity_registry: er.EntityRegistry,
|
2022-04-21 06:01:32 +00:00
|
|
|
hidden_by,
|
|
|
|
entity_category,
|
2023-02-16 10:15:26 +00:00
|
|
|
) -> None:
|
2022-04-21 06:01:32 +00:00
|
|
|
"""Test we get the expected triggers from a hidden or auxiliary entity."""
|
|
|
|
config_entry = MockConfigEntry(domain="test", data={})
|
|
|
|
config_entry.add_to_hass(hass)
|
2023-02-08 19:28:44 +00:00
|
|
|
device_entry = device_registry.async_get_or_create(
|
2022-04-21 06:01:32 +00:00
|
|
|
config_entry_id=config_entry.entry_id,
|
2023-02-08 19:28:44 +00:00
|
|
|
connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
2022-04-21 06:01:32 +00:00
|
|
|
)
|
2023-06-26 07:59:01 +00:00
|
|
|
entity_entry = entity_registry.async_get_or_create(
|
2022-04-21 06:01:32 +00:00
|
|
|
DOMAIN,
|
|
|
|
"test",
|
|
|
|
"5678",
|
|
|
|
device_id=device_entry.id,
|
|
|
|
entity_category=entity_category,
|
|
|
|
hidden_by=hidden_by,
|
|
|
|
)
|
|
|
|
expected_triggers = [
|
2019-09-24 21:57:05 +00:00
|
|
|
{
|
|
|
|
"platform": "device",
|
|
|
|
"domain": DOMAIN,
|
2022-04-21 06:01:32 +00:00
|
|
|
"type": trigger,
|
2019-09-24 21:57:05 +00:00
|
|
|
"device_id": device_entry.id,
|
2023-06-26 07:59:01 +00:00
|
|
|
"entity_id": entity_entry.id,
|
2022-04-21 06:01:32 +00:00
|
|
|
"metadata": {"secondary": True},
|
|
|
|
}
|
|
|
|
for trigger in ["changed_states", "turned_off", "turned_on"]
|
2019-09-24 21:57:05 +00:00
|
|
|
]
|
2021-12-21 10:56:00 +00:00
|
|
|
triggers = await async_get_device_automations(
|
|
|
|
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
|
|
|
)
|
2023-06-20 18:23:14 +00:00
|
|
|
assert triggers == unordered(expected_triggers)
|
2019-09-24 21:57:05 +00:00
|
|
|
|
|
|
|
|
2023-02-16 10:15:26 +00:00
|
|
|
async def test_get_trigger_capabilities(
|
|
|
|
hass: HomeAssistant,
|
|
|
|
device_registry: dr.DeviceRegistry,
|
|
|
|
entity_registry: er.EntityRegistry,
|
|
|
|
) -> None:
|
2019-10-02 20:14:52 +00:00
|
|
|
"""Test we get the expected capabilities from a switch trigger."""
|
|
|
|
config_entry = MockConfigEntry(domain="test", data={})
|
|
|
|
config_entry.add_to_hass(hass)
|
2023-02-08 19:28:44 +00:00
|
|
|
device_entry = device_registry.async_get_or_create(
|
2019-10-02 20:14:52 +00:00
|
|
|
config_entry_id=config_entry.entry_id,
|
2023-02-08 19:28:44 +00:00
|
|
|
connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
|
|
|
)
|
|
|
|
entity_registry.async_get_or_create(
|
|
|
|
DOMAIN, "test", "5678", device_id=device_entry.id
|
2019-10-02 20:14:52 +00:00
|
|
|
)
|
|
|
|
expected_capabilities = {
|
|
|
|
"extra_fields": [
|
|
|
|
{"name": "for", "optional": True, "type": "positive_time_period_dict"}
|
|
|
|
]
|
|
|
|
}
|
2021-12-21 10:56:00 +00:00
|
|
|
triggers = await async_get_device_automations(
|
|
|
|
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
|
|
|
)
|
2019-10-02 20:14:52 +00:00
|
|
|
for trigger in triggers:
|
|
|
|
capabilities = await async_get_device_automation_capabilities(
|
2021-12-21 10:56:00 +00:00
|
|
|
hass, DeviceAutomationType.TRIGGER, trigger
|
2019-10-02 20:14:52 +00:00
|
|
|
)
|
|
|
|
assert capabilities == expected_capabilities
|
|
|
|
|
|
|
|
|
2023-06-26 07:59:01 +00:00
|
|
|
async def test_get_trigger_capabilities_legacy(
|
|
|
|
hass: HomeAssistant,
|
|
|
|
device_registry: dr.DeviceRegistry,
|
|
|
|
entity_registry: er.EntityRegistry,
|
|
|
|
) -> None:
|
|
|
|
"""Test we get the expected capabilities from a switch trigger."""
|
|
|
|
config_entry = MockConfigEntry(domain="test", data={})
|
|
|
|
config_entry.add_to_hass(hass)
|
|
|
|
device_entry = device_registry.async_get_or_create(
|
|
|
|
config_entry_id=config_entry.entry_id,
|
|
|
|
connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
|
|
|
)
|
|
|
|
entity_registry.async_get_or_create(
|
|
|
|
DOMAIN, "test", "5678", device_id=device_entry.id
|
|
|
|
)
|
|
|
|
expected_capabilities = {
|
|
|
|
"extra_fields": [
|
|
|
|
{"name": "for", "optional": True, "type": "positive_time_period_dict"}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
triggers = await async_get_device_automations(
|
|
|
|
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
|
|
|
)
|
|
|
|
for trigger in triggers:
|
|
|
|
trigger["entity_id"] = entity_registry.async_get(trigger["entity_id"]).entity_id
|
|
|
|
capabilities = await async_get_device_automation_capabilities(
|
|
|
|
hass, DeviceAutomationType.TRIGGER, trigger
|
|
|
|
)
|
|
|
|
assert capabilities == expected_capabilities
|
|
|
|
|
|
|
|
|
2023-02-16 10:15:26 +00:00
|
|
|
async def test_if_fires_on_state_change(
|
2023-06-26 07:59:01 +00:00
|
|
|
hass: HomeAssistant,
|
2023-10-24 20:41:27 +00:00
|
|
|
device_registry: dr.DeviceRegistry,
|
2023-06-26 07:59:01 +00:00
|
|
|
entity_registry: er.EntityRegistry,
|
|
|
|
calls,
|
|
|
|
enable_custom_integrations: None,
|
2023-02-16 10:15:26 +00:00
|
|
|
) -> None:
|
2019-09-24 21:57:05 +00:00
|
|
|
"""Test for turn_on and turn_off triggers firing."""
|
2023-10-24 20:41:27 +00:00
|
|
|
config_entry = MockConfigEntry(domain="test", data={})
|
|
|
|
config_entry.add_to_hass(hass)
|
|
|
|
device_entry = device_registry.async_get_or_create(
|
|
|
|
config_entry_id=config_entry.entry_id,
|
|
|
|
connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
|
|
|
)
|
|
|
|
entry = entity_registry.async_get_or_create(
|
|
|
|
DOMAIN, "test", "5678", device_id=device_entry.id
|
|
|
|
)
|
2019-09-24 21:57:05 +00:00
|
|
|
|
2023-06-26 07:59:01 +00:00
|
|
|
hass.states.async_set(entry.entity_id, STATE_ON)
|
2019-09-24 21:57:05 +00:00
|
|
|
|
|
|
|
assert await async_setup_component(
|
|
|
|
hass,
|
|
|
|
automation.DOMAIN,
|
|
|
|
{
|
|
|
|
automation.DOMAIN: [
|
|
|
|
{
|
|
|
|
"trigger": {
|
|
|
|
"platform": "device",
|
|
|
|
"domain": DOMAIN,
|
2023-10-24 20:41:27 +00:00
|
|
|
"device_id": device_entry.id,
|
2023-06-26 07:59:01 +00:00
|
|
|
"entity_id": entry.id,
|
2019-09-24 21:57:05 +00:00
|
|
|
"type": "turned_on",
|
|
|
|
},
|
|
|
|
"action": {
|
|
|
|
"service": "test.automation",
|
|
|
|
"data_template": {
|
|
|
|
"some": "turn_on {{ trigger.%s }}"
|
|
|
|
% "}} - {{ trigger.".join(
|
|
|
|
(
|
|
|
|
"platform",
|
|
|
|
"entity_id",
|
|
|
|
"from_state.state",
|
|
|
|
"to_state.state",
|
|
|
|
"for",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"trigger": {
|
|
|
|
"platform": "device",
|
|
|
|
"domain": DOMAIN,
|
2023-10-24 20:41:27 +00:00
|
|
|
"device_id": device_entry.id,
|
2023-06-26 07:59:01 +00:00
|
|
|
"entity_id": entry.id,
|
2019-09-24 21:57:05 +00:00
|
|
|
"type": "turned_off",
|
|
|
|
},
|
|
|
|
"action": {
|
|
|
|
"service": "test.automation",
|
|
|
|
"data_template": {
|
|
|
|
"some": "turn_off {{ trigger.%s }}"
|
|
|
|
% "}} - {{ trigger.".join(
|
|
|
|
(
|
|
|
|
"platform",
|
|
|
|
"entity_id",
|
|
|
|
"from_state.state",
|
|
|
|
"to_state.state",
|
|
|
|
"for",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-01-03 09:41:30 +00:00
|
|
|
{
|
|
|
|
"trigger": {
|
|
|
|
"platform": "device",
|
|
|
|
"domain": DOMAIN,
|
2023-10-24 20:41:27 +00:00
|
|
|
"device_id": device_entry.id,
|
2023-06-26 07:59:01 +00:00
|
|
|
"entity_id": entry.id,
|
2022-01-17 15:34:40 +00:00
|
|
|
"type": "changed_states",
|
2022-01-03 09:41:30 +00:00
|
|
|
},
|
|
|
|
"action": {
|
|
|
|
"service": "test.automation",
|
|
|
|
"data_template": {
|
|
|
|
"some": "turn_on_or_off {{ trigger.%s }}"
|
|
|
|
% "}} - {{ trigger.".join(
|
|
|
|
(
|
|
|
|
"platform",
|
|
|
|
"entity_id",
|
|
|
|
"from_state.state",
|
|
|
|
"to_state.state",
|
|
|
|
"for",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-09-24 21:57:05 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
)
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
assert len(calls) == 0
|
|
|
|
|
2023-06-26 07:59:01 +00:00
|
|
|
hass.states.async_set(entry.entity_id, STATE_OFF)
|
2019-09-24 21:57:05 +00:00
|
|
|
await hass.async_block_till_done()
|
2022-01-03 09:41:30 +00:00
|
|
|
assert len(calls) == 2
|
|
|
|
assert {calls[0].data["some"], calls[1].data["some"]} == {
|
2023-06-26 07:59:01 +00:00
|
|
|
f"turn_off device - {entry.entity_id} - on - off - None",
|
|
|
|
f"turn_on_or_off device - {entry.entity_id} - on - off - None",
|
2022-01-03 09:41:30 +00:00
|
|
|
}
|
2019-09-24 21:57:05 +00:00
|
|
|
|
2023-06-26 07:59:01 +00:00
|
|
|
hass.states.async_set(entry.entity_id, STATE_ON)
|
2019-09-24 21:57:05 +00:00
|
|
|
await hass.async_block_till_done()
|
2022-01-03 09:41:30 +00:00
|
|
|
assert len(calls) == 4
|
|
|
|
assert {calls[2].data["some"], calls[3].data["some"]} == {
|
2023-06-26 07:59:01 +00:00
|
|
|
f"turn_on device - {entry.entity_id} - off - on - None",
|
|
|
|
f"turn_on_or_off device - {entry.entity_id} - off - on - None",
|
2022-01-03 09:41:30 +00:00
|
|
|
}
|
2019-10-02 20:14:52 +00:00
|
|
|
|
|
|
|
|
2023-06-26 07:59:01 +00:00
|
|
|
async def test_if_fires_on_state_change_legacy(
|
|
|
|
hass: HomeAssistant,
|
2023-10-24 20:41:27 +00:00
|
|
|
device_registry: dr.DeviceRegistry,
|
2023-06-26 07:59:01 +00:00
|
|
|
entity_registry: er.EntityRegistry,
|
|
|
|
calls,
|
|
|
|
enable_custom_integrations: None,
|
2023-02-16 10:15:26 +00:00
|
|
|
) -> None:
|
2023-06-26 07:59:01 +00:00
|
|
|
"""Test for turn_on and turn_off triggers firing."""
|
2023-10-24 20:41:27 +00:00
|
|
|
config_entry = MockConfigEntry(domain="test", data={})
|
|
|
|
config_entry.add_to_hass(hass)
|
|
|
|
device_entry = device_registry.async_get_or_create(
|
|
|
|
config_entry_id=config_entry.entry_id,
|
|
|
|
connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
|
|
|
)
|
|
|
|
entry = entity_registry.async_get_or_create(
|
|
|
|
DOMAIN, "test", "5678", device_id=device_entry.id
|
|
|
|
)
|
2023-06-26 07:59:01 +00:00
|
|
|
|
|
|
|
hass.states.async_set(entry.entity_id, STATE_ON)
|
|
|
|
|
|
|
|
assert await async_setup_component(
|
|
|
|
hass,
|
|
|
|
automation.DOMAIN,
|
|
|
|
{
|
|
|
|
automation.DOMAIN: [
|
|
|
|
{
|
|
|
|
"trigger": {
|
|
|
|
"platform": "device",
|
|
|
|
"domain": DOMAIN,
|
2023-10-24 20:41:27 +00:00
|
|
|
"device_id": device_entry.id,
|
2023-06-26 07:59:01 +00:00
|
|
|
"entity_id": entry.entity_id,
|
|
|
|
"type": "turned_off",
|
|
|
|
},
|
|
|
|
"action": {
|
|
|
|
"service": "test.automation",
|
|
|
|
"data_template": {
|
|
|
|
"some": "turn_off {{ trigger.%s }}"
|
|
|
|
% "}} - {{ trigger.".join(
|
|
|
|
(
|
|
|
|
"platform",
|
|
|
|
"entity_id",
|
|
|
|
"from_state.state",
|
|
|
|
"to_state.state",
|
|
|
|
"for",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
)
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
assert len(calls) == 0
|
2019-10-02 20:14:52 +00:00
|
|
|
|
2023-06-26 07:59:01 +00:00
|
|
|
hass.states.async_set(entry.entity_id, STATE_OFF)
|
2020-06-01 05:18:30 +00:00
|
|
|
await hass.async_block_till_done()
|
2023-06-26 07:59:01 +00:00
|
|
|
assert len(calls) == 1
|
|
|
|
assert (
|
|
|
|
calls[0].data["some"]
|
|
|
|
== f"turn_off device - {entry.entity_id} - on - off - None"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
async def test_if_fires_on_state_change_with_for(
|
|
|
|
hass: HomeAssistant,
|
2023-10-24 20:41:27 +00:00
|
|
|
device_registry: dr.DeviceRegistry,
|
2023-06-26 07:59:01 +00:00
|
|
|
entity_registry: er.EntityRegistry,
|
|
|
|
calls,
|
|
|
|
enable_custom_integrations: None,
|
|
|
|
) -> None:
|
|
|
|
"""Test for triggers firing with delay."""
|
2023-10-24 20:41:27 +00:00
|
|
|
config_entry = MockConfigEntry(domain="test", data={})
|
|
|
|
config_entry.add_to_hass(hass)
|
|
|
|
device_entry = device_registry.async_get_or_create(
|
|
|
|
config_entry_id=config_entry.entry_id,
|
|
|
|
connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
|
|
|
)
|
|
|
|
entry = entity_registry.async_get_or_create(
|
|
|
|
DOMAIN, "test", "5678", device_id=device_entry.id
|
|
|
|
)
|
2019-10-02 20:14:52 +00:00
|
|
|
|
2023-06-26 07:59:01 +00:00
|
|
|
hass.states.async_set(entry.entity_id, STATE_ON)
|
2019-10-02 20:14:52 +00:00
|
|
|
|
|
|
|
assert await async_setup_component(
|
|
|
|
hass,
|
|
|
|
automation.DOMAIN,
|
|
|
|
{
|
|
|
|
automation.DOMAIN: [
|
|
|
|
{
|
|
|
|
"trigger": {
|
|
|
|
"platform": "device",
|
|
|
|
"domain": DOMAIN,
|
2023-10-24 20:41:27 +00:00
|
|
|
"device_id": device_entry.id,
|
2023-06-26 07:59:01 +00:00
|
|
|
"entity_id": entry.id,
|
2019-10-02 20:14:52 +00:00
|
|
|
"type": "turned_off",
|
|
|
|
"for": {"seconds": 5},
|
|
|
|
},
|
|
|
|
"action": {
|
|
|
|
"service": "test.automation",
|
|
|
|
"data_template": {
|
|
|
|
"some": "turn_off {{ trigger.%s }}"
|
|
|
|
% "}} - {{ trigger.".join(
|
|
|
|
(
|
|
|
|
"platform",
|
|
|
|
"entity_id",
|
|
|
|
"from_state.state",
|
|
|
|
"to_state.state",
|
|
|
|
"for",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
)
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
assert len(calls) == 0
|
|
|
|
|
2023-06-26 07:59:01 +00:00
|
|
|
hass.states.async_set(entry.entity_id, STATE_OFF)
|
2019-10-02 20:14:52 +00:00
|
|
|
await hass.async_block_till_done()
|
|
|
|
assert len(calls) == 0
|
|
|
|
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=10))
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
assert len(calls) == 1
|
|
|
|
await hass.async_block_till_done()
|
2023-06-26 07:59:01 +00:00
|
|
|
assert (
|
|
|
|
calls[0].data["some"]
|
|
|
|
== f"turn_off device - {entry.entity_id} - on - off - 0:00:05"
|
2019-10-02 20:14:52 +00:00
|
|
|
)
|