Make sure command entities restore from state (#38038)
This commit is contained in:
1 parent
ad5d7ee615
commit
945acb4e29
11 files changed
+182
-11
No files matched your search
@@ -3,10 +3,13 @@ from unittest.mock import call
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.core import State
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from . import _signal_event
|
||||
|
||||
from tests.common import mock_restore_cache
|
||||
|
||||
|
||||
async def test_one_switch(hass, rfxtrx):
|
||||
"""Test with 1 switch."""
|
||||
@@ -42,6 +45,24 @@ async def test_one_switch(hass, rfxtrx):
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("state", ["on", "off"])
|
||||
async def test_state_restore(hass, rfxtrx, state):
|
||||
"""State restoration."""
|
||||
|
||||
entity_id = "switch.ac_213c7f2_16"
|
||||
|
||||
mock_restore_cache(hass, [State(entity_id, state)])
|
||||
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
"rfxtrx",
|
||||
{"rfxtrx": {"device": "abcd", "devices": {"0b1100cd0213c7f210010f51": {}}}},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(entity_id).state == state
|
||||
|
||||
|
||||
async def test_several_switches(hass, rfxtrx):
|
||||
"""Test with 3 switches."""
|
||||
assert await async_setup_component(
|
||||
|
||||
Reference in new issue
Block a user