Restore rfxtrx state to off when delay off is in effect (#38239)
This commit is contained in:
parent
a1e2bce1b9
commit
0bcee21333
2 changed files with 39 additions and 9 deletions
|
@ -13,6 +13,7 @@ from homeassistant.const import (
|
|||
CONF_COMMAND_ON,
|
||||
CONF_DEVICE_CLASS,
|
||||
CONF_DEVICES,
|
||||
STATE_ON,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import event as evt
|
||||
|
@ -28,12 +29,7 @@ from . import (
|
|||
get_pt2262_cmd,
|
||||
get_rfx_object,
|
||||
)
|
||||
from .const import (
|
||||
ATTR_EVENT,
|
||||
COMMAND_OFF_LIST,
|
||||
COMMAND_ON_LIST,
|
||||
DEVICE_PACKET_TYPE_LIGHTING4,
|
||||
)
|
||||
from .const import COMMAND_OFF_LIST, COMMAND_ON_LIST, DEVICE_PACKET_TYPE_LIGHTING4
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -184,9 +180,10 @@ class RfxtrxBinarySensor(RfxtrxEntity, BinarySensorEntity):
|
|||
if self._event is None:
|
||||
old_state = await self.async_get_last_state()
|
||||
if old_state is not None:
|
||||
event = old_state.attributes.get(ATTR_EVENT)
|
||||
if event:
|
||||
self._apply_event(get_rfx_object(event))
|
||||
self._state = old_state.state == STATE_ON
|
||||
|
||||
if self._state and self._off_delay is not None:
|
||||
self._state = False
|
||||
|
||||
@property
|
||||
def force_update(self) -> bool:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue