Rule For Fan Automation?

Hello.

Trying to see if I'm on the right path here. Trying to automate our living room ceiling fan.

Between 8am and 7:35pm, Would like the fan to turn on if the temp is above 73* and turn off if there is a period of inactivity, if temp drops below 71*, or off at 8pm.

Im not that skilled with motion sensor but is a Zooz 4-in-1 and is quick to switch between active and inactive. like goes from active to inactive in 20 secs if you don't move. haven't been able to slow the change down in the device page. maybe you can't which is why i put a delay in (plus thats what the hubitat docs showed?)

the fan in the rule below is a virtual lock switch so I can actually turn the fan on/off through a alexa routine since its a "BIG ■■■ FAN" and doesn't work with hubitat easily. unlock is OFF, locked is ON.

am I on the right path here? or should I change something???

Trigger: Temp changes

IF (Time between 8:00 AM EDT and 7:35 PM EDT(F) AND
Temperature of Living Room Temp Sensor(72.05) is >= 73.0(F) [FALSE]) THEN
Lock: Virtual Switch For Living Room Fan
Cancel Delayed Actions
ELSE-IF (Temperature of Living Room Temp Sensor(72.05) is < 71.0(F) OR
Living Room Temp Sensor inactive(T) OR
Time is 8:00 PM EDT(F) [TRUE]) THEN
Unlock: Virtual Switch For Living Room Fan --> delayed: 0:20:00 (cancelable)
END-IF

Thanks!

I'll probably not be a ton of help, but here goes...

FIrst, Bruce has helped me out a couple of times by suggesting that I simplify my rules. Sometimes this means separate rules/triggers for turning something ON and OFF and not using a bunch of IF statements. This might be a good candidate for that approach.

Based on your trigger and your first IF statement, this fan will turn on even if nobody is home, then turn off 20 minutes later, then on again at the next trigger...repeating indefinitely. But I see that the limitations of the motion sensor (short restet time) are an issue as well. I might rewrite this rule as shown below, and use a virtual switch to handle occupancy. [Edit: First version is a bit clunky...skip right to the 2-rule version at the end of the post]

Create new virtual switch (VS1) with a 20 minute auto-off time.
Rule 1:
Trigger: Motion Switch Active
Actions: Turn on VS1, Run actions of Rule 2

Rule 2:
Trigger: None.
Actions: Check conditions of time and temperature. If TRUE, turn on fan.

Rule 3:
Trigger: VS1 turns OFF
Actions: Turn off fan.

I'm sure there are ways to combine these rules using multiple triggers and conditional actions, but these should be dead simple to write and execute correctly every time.

Edit: After looking at this a bit more closely, maybe it won't be that hard to get these condensed down into 2 rules.

Rule 1:
Trigger: Motion Switch Active
Actions: Turn on VS1, Check conditions of time and temperature. If TRUE, turn on fan.

Rule 2:
Trigger: VS1 turns OFF
Actions: Turn off fan.