Is there a better way to have a Rule run when Variable changes?

I have been running a Rule that detects when any change to HeatingDemand takes place either turn on Heating or Turn it Off.

But it fails to trip when the HeatingDemand changes

So I have to put a periodic check of every 30 seconds.

Is there another, better way to trap when HeatingDemand changes and act upon it, or is it just a matter of balancing how often you check for it?

I set up an Alert that checked the HeatingDemand variable against whether the boiler was still on.

Funnily enough, it currently detects when HeatingDemand=TRUE but ignores it when it changes to FALSE.

I have ramped up the detection rate to every 30 seconds as I was having so many instances where the house was overheating.

This doesn't explain what you are seeing, necessarily, but your conditionals are overly complex. It's OK if you want to leave it like this, but you really should add END-IF to delineate the block paired with matching IFs. It may be true that it still works in RM, but it is bad style, and I don't like it when computers try to guess what I meant.

But you really don't need the ELSE-IF construct here. If HeatDemand = true fails, then you already know it is false, so you can simply

If HeatDemand = true then
Else
END-IF

How does HeatingDemand get set?

2 Likes

I have had issues with switches in the past when I used changed. I switched to two triggers one for turned on and another for turned off and it then worked. Maybe that is an issue with a variable as well. So try two triggers, if you are sure the variable is changing.

@HAL9000 comments are valid as well but I don't think RM is that picky about syntax, so it should work but wouldn't hurt to try his suggestions.

Each Heating Zone has an Attribute HeatingDemand_Bathroom that is set when the Zone ThermostatOperatingState changes to heating - and changes back when it is not heating.

There is a rule watching ALL the Zone Demand variables - If ONE or more is demanding heat the HeatingDemand gets set to TRUE and if ALL zone Demands are FALSE the Heating Demand is set to FALSE.

It had been working well until recently, I suspect coincided with a recent HE update, but all of a sudden the change of some HeatingDemand=FALSE no longer triggered the Rule only HeatingDemand=TRUE was working consistently.

I am going to recreate the whole rule in line with your suggestions.

I've now come across 4 rules that use global boolean variables that have stopped running since the last update.
With full logging on I can see the rule being triggered in the logs but no actions are logged. It just does nothing.
I re-wrote the rules exactly as they were before and they worked. Opening and clicking done on the old rule did nothing. :man_shrugging:

So have now implemented the new rule and paused the old one.

So it should either turn on Boiler or turn it off when any change to HeatDemand occurs

Watch it now

OK looks like it may be an issue.

I'll check other TRIGGERS based on Global Variables

It hasn't happened on all my rules that use variables as a trigger and that's the spooky part. :ghost:

Ugh I do love an inconsistent issue.......