Start Modbus cover timer independent if there is a state to restore (#49919)
* Start timer independent if there is a state to restore. * Update test cases, that now start working.
This commit is contained in:
parent
2b46c6bcda
commit
aa8ce07e35
2 changed files with 9 additions and 10 deletions
|
@ -103,8 +103,7 @@ class ModbusCover(CoverEntity, RestoreEntity):
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Handle entity which will be added."""
|
"""Handle entity which will be added."""
|
||||||
state = await self.async_get_last_state()
|
state = await self.async_get_last_state()
|
||||||
if not state:
|
if state:
|
||||||
return
|
|
||||||
self._value = state.state
|
self._value = state.state
|
||||||
|
|
||||||
async_track_time_interval(
|
async_track_time_interval(
|
||||||
|
|
|
@ -10,8 +10,8 @@ from homeassistant.const import (
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
CONF_SCAN_INTERVAL,
|
CONF_SCAN_INTERVAL,
|
||||||
CONF_SLAVE,
|
CONF_SLAVE,
|
||||||
|
STATE_CLOSED,
|
||||||
STATE_OPEN,
|
STATE_OPEN,
|
||||||
STATE_OPENING,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from .conftest import base_config_test, base_test
|
from .conftest import base_config_test, base_test
|
||||||
|
@ -52,23 +52,23 @@ async def test_config_cover(hass, do_options, read_type):
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
[0x00],
|
[0x00],
|
||||||
STATE_OPENING,
|
STATE_CLOSED,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[0x80],
|
[0x80],
|
||||||
STATE_OPENING,
|
STATE_CLOSED,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[0xFE],
|
[0xFE],
|
||||||
STATE_OPENING,
|
STATE_CLOSED,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[0xFF],
|
[0xFF],
|
||||||
STATE_OPENING,
|
STATE_OPEN,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[0x01],
|
[0x01],
|
||||||
STATE_OPENING,
|
STATE_OPEN,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -99,7 +99,7 @@ async def test_coil_cover(hass, regs, expected):
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
[0x00],
|
[0x00],
|
||||||
STATE_OPEN,
|
STATE_CLOSED,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
[0x80],
|
[0x80],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue