for scenarios of enabling/disabling (~ creating/removing) entities, so it does not trigger in removal if a `to: xxx` is defined, and also does not trigger in creation if a `from: xxx` is present.
This commit is contained in:
1 parent
6652af5cc0
commit
8cfffd00d6
2 files changed
+58
-29
No files matched your search
@@ -73,16 +73,13 @@ async def async_attach_trigger(
|
||||
|
||||
from_s = event.data.get("old_state")
|
||||
to_s = event.data.get("new_state")
|
||||
old_state = getattr(from_s, "state", None)
|
||||
new_state = getattr(to_s, "state", None)
|
||||
|
||||
if (
|
||||
(from_s is not None and not match_from_state(from_s.state))
|
||||
or (to_s is not None and not match_to_state(to_s.state))
|
||||
or (
|
||||
not match_all
|
||||
and from_s is not None
|
||||
and to_s is not None
|
||||
and from_s.state == to_s.state
|
||||
)
|
||||
not match_from_state(old_state)
|
||||
or not match_to_state(new_state)
|
||||
or (not match_all and old_state == new_state)
|
||||
):
|
||||
return
|
||||
|
||||
@@ -104,15 +101,6 @@ async def async_attach_trigger(
|
||||
)
|
||||
)
|
||||
|
||||
# Ignore changes to state attributes if from/to is in use
|
||||
if (
|
||||
not match_all
|
||||
and from_s is not None
|
||||
and to_s is not None
|
||||
and from_s.state == to_s.state
|
||||
):
|
||||
return
|
||||
|
||||
if not time_delta:
|
||||
call_action()
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user