Skip to content

Commit 0da11b9

Browse files
committed
make and use STATE_VIRTUAL_ATTRS
1 parent 729f522 commit 0da11b9

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

custom_components/pyscript/state.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
_LOGGER = logging.getLogger(LOGGER_PATH + ".state")
1414

15+
STATE_VIRTUAL_ATTRS = {"last_updated", "last_changed"}
1516

1617
class StateVar(str):
1718
"""Class for representing the value and attributes of a state variable."""

custom_components/pyscript/trigger.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from .eval import AstEval
1818
from .event import Event
1919
from .function import Function
20-
from .state import State
20+
from .state import State, STATE_VIRTUAL_ATTRS
2121

2222
_LOGGER = logging.getLogger(LOGGER_PATH + ".trigger")
2323

@@ -675,7 +675,7 @@ def ident_any_values_changed(self, func_args):
675675
all_attributes |= set(value.__dict__.keys())
676676
if old_value is not None:
677677
all_attributes |= set(old_value.__dict__.keys())
678-
all_attributes -= {"last_updated", "last_changed"}
678+
all_attributes -= STATE_VIRTUAL_ATTRS
679679
for attribute in all_attributes:
680680
attrib_val = getattr(value, attribute, None)
681681
attrib_old_val = getattr(old_value, attribute, None)

0 commit comments

Comments
 (0)