Best practice for rule that modifies its behavior if device controlled manually

I’m running 3.3.0 on Raspbian, scripting in ECMAscript.

I have a rule that adjusts the speed of the ceiling fan in our two-story living room based on the temperature difference between the seating area and the upstairs area. The rule is triggered by changes to the upstairs temp sensor. It works very well when we are using our wood stove – the more heat the stove is throwing, the faster the fan runs, yet it never feels drafty (it took a while to tune the rules to that point).
The fan is controlled by a Lutron Caseta fan control.

I’d like to have this rule sit on the sideline for some period of time after a manual change to the fan speed – either via main UI or the physical device control.
I briefly considered a shadow item, but I don’t see how to have it work when the change is made on the physical device, which only records an “item changed” event.

So far, my best idea is to have the script save a timestamp when it adjusts the fan speed, and a separate script set a second timestamp on any change to the fan control item. The main script could then detect a change that occurred more than a few ms after its own last change as a manual change and modify its behavior accordingly. This requires one simple new rule, an item to carry the “fan last changed” timestamp, and changes to the main script.
Any other suggestions?

See Design Pattern: Manual Trigger Detection.

The most robust approach is the “Proxy Items” approach. At a high level, you have three Items, on controlled by the temp, one put on your UIs, and one linked to the Channel. The you need a rule triggered by all three. If the first Item triggers the rule, you know it was triggered by a temp change. If the second or third one trigger the rule you know that it was manually commanded. Take what ever action is appropriate.

1 Like

Thanks Rich, I’lm studying the design pattern and will take a shot at it tomorrow.