forked from Egyras/HeishaMon
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rule triggers should contain up-to-date values
- Loading branch information
Showing
2 changed files
with
29 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9b5e500
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.
I don't understand the reason for this change. If you want rules_event_cb to only be called when the value is changed and not every updateAllTime period (due to maybe useless processing) then this could be much simpler
9b5e500
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.
I'm open for suggestions.
9b5e500
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.
First need to understand why this change was needed. Was it, as it looks too me, to prevent rules_event_cb to be callled too often for each (even unchanged) value (each 300 seconds by default)?
9b5e500
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.
No, the issue was that the rules where triggered with the old value instead of the new one. Right @McMagellan
9b5e500
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.
That would not be possible as the pre-commit line would cause the mqtt message but also the rules_event_cb to be called.
if ((updatenow) || ( getDataValue(actData, Topic_Number) != Topic_Value )) {
But it did result in calling rules_event_cb each 300 seconds for each (even unchanged) value. Maybe that had side effects?
9b5e500
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.
I can't find the discussion we had on this. That's why i tagged @McMagellan. He reported it first.
9b5e500
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.
I see again what the point was. The
actData
is updated after therule_event_cb
was called. So, the trigger was correct, but when you inside the rule block wanted to retrieve the updated value, it would give you the old one. Because it would try to extract the current value from theactData
which wasn't updated yet.9b5e500
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.
I asked CurlyMoo whether it was possible to provide the variable trigger with the correct value. So far I have avoided working with triggers.
I'll give you an example: This test rule should add the variable @Quiet_Mode_Level to the current ruleset.
A query takes place within the trigger (#Test1) and the same query one second later from a timer (Test2).
The quiet mode level is then manually changed from 0 to 2 on the remote control.
You can see what happens in the log file: The first query returns the value before the change in #Test1, the second query returns the correct value in #Test2.
I asked CurlyMoo to make a change, which he did, thank you very much for that. After that, the triggers for my CoPilot ruleset are perfectly usable.
CurlyMoo then also turned off the completely pointless triggering every 300 seconds, which makes the console totally confusing and just wastes resources. Thank you very much for that too.
I currently use 7 triggers, all of which work well in Egyras#544. In version 3.62, however, it looks like this.
2Trigger 3.62.txt
9b5e500
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.
Ah that explains a lot. Then the change is indeed necessary. Maybe I'll update it with a improved patch but for now ok.