Issue with a Trigger Rule using "changes from blank=any value to blank=any value"
-
Hello Patrick,
Hoping this is the right place to ask the following.
Not sure why, but since I upgraded Reactor to 22293 from 22258 I have a rule that no longer works as expected. I keep a log of all changes/updates/upgrades/etc. I make in my environment and cannot find any recent changes that could have caused this. Maybe it was pure luck that it worked until recently? Hopefully you can steer me in the right direction. Thanks
I am running Reactor (22293) / HA (2022.10.5) /InfluxDB (2.4.0) / Grafana (9.1.5) inside Docker on a Synology NAS (DSM 7.1.1-42962 Update 1).
The rule's trigger is designed to update a Home Assistant Helper entity (input_number) value that is used in Grafana to display Humidity Target in my house.
I set the rule as follow:
When the Variable Value (HumidityTarget) changes from blank=any value to blank=any value, set the Home Assistant Helper entity value (h_Humidity Target) to Variable Value (HumidityTarget).
If I manually change the Global Expression Variable Value (HumidityTarget) it works but using the changes from blank=any value to blank=any value does not seem to work anymore.
Below the Variable Value (HumidityTarget) created under Global Expression
-
Hello Patrick,
Hoping this is the right place to ask the following.
Not sure why, but since I upgraded Reactor to 22293 from 22258 I have a rule that no longer works as expected. I keep a log of all changes/updates/upgrades/etc. I make in my environment and cannot find any recent changes that could have caused this. Maybe it was pure luck that it worked until recently? Hopefully you can steer me in the right direction. Thanks
I am running Reactor (22293) / HA (2022.10.5) /InfluxDB (2.4.0) / Grafana (9.1.5) inside Docker on a Synology NAS (DSM 7.1.1-42962 Update 1).
The rule's trigger is designed to update a Home Assistant Helper entity (input_number) value that is used in Grafana to display Humidity Target in my house.
I set the rule as follow:
When the Variable Value (HumidityTarget) changes from blank=any value to blank=any value, set the Home Assistant Helper entity value (h_Humidity Target) to Variable Value (HumidityTarget).
If I manually change the Global Expression Variable Value (HumidityTarget) it works but using the changes from blank=any value to blank=any value does not seem to work anymore.
Below the Variable Value (HumidityTarget) created under Global Expression
@snowman said in Issue with a Trigger Rule using "changes from blank=any value to blank=any value":
If I manually change the Global Expression Variable Value (HumidityTarget) it works but using the changes from blank=any value to blank=any value does not seem to work anymore.
This is not at all clear. "it works"... what works?
-
Hello Patrick,
Hoping this is the right place to ask the following.
Not sure why, but since I upgraded Reactor to 22293 from 22258 I have a rule that no longer works as expected. I keep a log of all changes/updates/upgrades/etc. I make in my environment and cannot find any recent changes that could have caused this. Maybe it was pure luck that it worked until recently? Hopefully you can steer me in the right direction. Thanks
I am running Reactor (22293) / HA (2022.10.5) /InfluxDB (2.4.0) / Grafana (9.1.5) inside Docker on a Synology NAS (DSM 7.1.1-42962 Update 1).
The rule's trigger is designed to update a Home Assistant Helper entity (input_number) value that is used in Grafana to display Humidity Target in my house.
I set the rule as follow:
When the Variable Value (HumidityTarget) changes from blank=any value to blank=any value, set the Home Assistant Helper entity value (h_Humidity Target) to Variable Value (HumidityTarget).
If I manually change the Global Expression Variable Value (HumidityTarget) it works but using the changes from blank=any value to blank=any value does not seem to work anymore.
Below the Variable Value (HumidityTarget) created under Global Expression
-
I think it has to do with how the global expression is evaluated, see the excerpt from the docs "A global variable is evaluated when a rule that refers to the global variable in its own (rule-based) expressions or conditions is evaluated, or when a reaction is run that contains actions with substitutions referring to the global variable.". If that is the case try moving this variable to a local expression and see if that works.
-
To answer Patrick question. If I manually change the Global Expression Variable Value (HumidityTarget) to equal 45 (instead of 40), it will trickle up to HA / Influxdb / Grafana.
This value could be stale for a long time and don't want to manually update/refresh this value. That is why I used "changes from blank=any value to blank=any value".
I'll try @Pabla suggestion.
-
OK, wait... if you change the variable manually, and it trickles up to HA/Influxdb/Grafana, that means the changes is working, because that true pulse causes the Set reaction to run, which is what pushes the value to your input_number entity on Hass.
How do you know it's not working when you think it's not? What is the observed behavior?
-
OK. And is the value actually changing from one value to another during that time, or is it static (same value) for that time?
-
OK. changes means just that. If the value doesn't change, it isn't going to trigger anything. When you make a condition for changes from any to any, that means the value changes from any value to any other value. But if the value never changes, that condition doesn't go true, your Set reaction does not run, etc.
If you want to make sure your value is pushed out to HA on some interval, you need to set the logic mode to OR and add an Interval condition with an interval you are happy with, let's say hourly. The two conditions together working in an OR group will send the target to HA every hour, and any time the value (actually) changes.
Edit: There's nothing new here. It has always worked this way.
-
OK. changes means just that. If the value doesn't change, it isn't going to trigger anything. When you make a condition for changes from any to any, that means the value changes from any value to any other value. But if the value never changes, that condition doesn't go true, your Set reaction does not run, etc.
If you want to make sure your value is pushed out to HA on some interval, you need to set the logic mode to OR and add an Interval condition with an interval you are happy with, let's say hourly. The two conditions together working in an OR group will send the target to HA every hour, and any time the value (actually) changes.
Edit: There's nothing new here. It has always worked this way.
@toggledbits Wouldn't switching the expression to a local expression fix this issue to? Since a local expression is evaluated differently?
-
No. The issue is that the value is not changing for a long period of time, so regardless of if it's local or global, the changes will not trigger on its own, and the Set reaction will thus not be run. This creates a gap in Influxdb's data that may be larger than the period he's asking to show in the graphs in Grafana, so nothing is displayed.
The other way to address this is to use the
last
aggregator in the Influxdb query in Grafana, so that the last value stored in the database is carried forward through the graph. This is harder for people to understand and implement (because you need to be fluent in the query language), but it's actually the "right" way to do it. Having data pushed on an interval can wastefully fill the database with identical values. -
T toggledbits locked this topic on