Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions custom_components/pyscript/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ def has_value(self) -> bool:
return not self.is_unknown() and not self.is_unavailable()


STATE_CALLABLE_ATTRS = {
attr for attr, value in StateVal.__dict__.items() if callable(value) and not attr.startswith("_")
}


class State:
"""Class for state functions."""

Expand Down Expand Up @@ -308,6 +313,7 @@ def exist(cls, var_name):
or (parts[0] in cls.service2args and parts[2] in cls.service2args[parts[0]])
or parts[2] in value.attributes
or parts[2] in STATE_VIRTUAL_ATTRS
or parts[2] in STATE_CALLABLE_ATTRS
):
return True
return False
Expand Down
Loading