diff --git a/custom_components/pyscript/state.py b/custom_components/pyscript/state.py index dab935e..102a06f 100644 --- a/custom_components/pyscript/state.py +++ b/custom_components/pyscript/state.py @@ -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.""" @@ -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