New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: cleaner @state_trigger('True or ... ') #44
Comments
Yes, the current suggested approach isn't very intuitive. However, the last example (putting the variables in a list) should work with
Do you agree it's sufficient to document this method as the way to get a trigger on any change? For a single variable, it almost works correctly without using a list, except for the case where the variable is an empty string (since non-empty string are non-zero). |
Documenting it this way is certainly make the code more readable. It still means that if you already have a python list of entities to watch, you have to do this:
In which case, this is still cleaner to me
But isn't nearly as good as:
|
I notice that almost all of my state triggers follow the |
Ok, that's two votes for
so let me look at doing that. I was also thinking about using a list of strings for multiple expressions, that are It would be possible to make both forms work. A single string argument state variable (ie, no expression and no list) could be detected and treated as trigger on any change. And a list of strings, each of which could be an expression or a state variable name meaning any change, would be logically |
Ok,
|
I tested THANKS! |
This syntax is a bit hacky looking and hard for new users to follow:
There's no reason to make the above syntax NOT work, but think a convenience decorator for this use pattern might be beneficial. Something like this:
Though, naming things is hard. There's probably something better than
state_change_trigger
.The text was updated successfully, but these errors were encountered: