Logic error

I need some help with a couple of rules that perform as I expect most of the time.

The descriptions below are as I think things will work but clearly there are things that I do not understand and wish to get a better understanding of.

The UtilityFanSch app is intended to enable the switch UtilityFanAuto between two configurable times and for the UtilityFanControl to automatically control the fan when humidity is outside the parameters set.

This has worked well until yesterday when:

UtilityFanAuto was switched off at 18:30:00.432
UtilityFan was switched on at 18:30:01.007 and 18:30:01.013
UtilityFanAppOn was switched on at 18:30:00.841

The result being that the utility fan stayed on (uncontrolled) until my system changed to Night mode at 23:00.

Looking at the UtilityFanControl app I guess that it was about to switch on the fan when UtilityFanAuto was switched off.

How can I change the rules to be more defensive or in fact 'correct'.

Many thanks for all advice.

Chris


It looks like it should work, but perhaps the second rule had just started as the UtilityFanAuto had turned off. Once a rule starts it will continue until complete even if the required expression is false.

Perhaps adding a check for the UtilityFanAuto before you turn on the Fan in the second rule. If UtilityFanAuto is off exit the rule.

Thanks for the reply.

There is still a possibility that code will run after the IF test so I am thinking about changing the UtilityFanSch rule so that is switches off the UtilityFanAuto switch and then switches off the UtilityFan and UtilityFanAppOn after a delay of 1 minute to give the other rule time to finish whatever it is doing.