-
Notifications
You must be signed in to change notification settings - Fork 55
state_trigger only triggers on value changes (using StateVar) #82
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
Conversation
OMG, I fixed a test AND caught a bug because of a test! GO TESTS! |
entity.domain.* is not valid python, so it's a bunch of extra hurdles to jump through to make this the way to designate "all attributes". I suggest we either use something else -- entity.domain.all, perhaps -- or we indicate this functionality with a kwarg or we just don't implement it at all and require users to be specific about what they want to trigger on. Thoughts? |
This is look great. The trigger on any change values (eg: The drawback with |
Excellent. I can see if I can figure out where to put that, but the deeper it gets into the Ast bits, the harder it is for me to decipher. Perhaps if you get some time you can figure out where to put it? Right now, if I put "domain.entity.*" into a state_trigger, I get an error like this:
|
You need to update I guess |
okay. I think I can manage that. I'll give it a shot now. |
@craigbarratt limited testing shows domain.entity.* feature to be working. |
@craigbarratt I think I covered everything. Let me know if I missed something. |
self.name, | ||
check_var, | ||
) | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this whole if
clause necessary? In this case ident_any_values_changed()
would already have returned True
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thought process was that ident_any_values_changed() checked it, but the value did not change. Therefore, it didn't return True. So, in ident_values_changed() we can skip it (and save some CPU) since they were already checked. If we take the if out, since it didn't return True before, it won't return True now either.
This is looking great - all the logic looks correct to me. I just added a few cosmetic comments. I'm happy to merge after your next changes, and then I can add the same features to |
As yes, I can do the wait_until part as well. These functions will need to not only be global, but also take self.state_trig_ident_any, etc, as an additional parameter since it won't be there as "self". |
@craigbarratt limited testing shows I don't use that feature much, so I wasn't sure what to test. I tested waiting for a state to change (and ensuring the wait didn't end because an attribute changed), wait for an attribute to change, waiting for "*", and waiting for an attribute to be a certain thing. They all seemed to work correctly. |
This looks good to me. I'm happy to merge if you don't have any other changes. I'll add some tests after I merge. |
I think it's ready to go. Thanks! |
This works for me. Needs more testing.
Does not implement domain.entity.* functionality. Suggesting we save that for a future PR.