You’re going to need some helpers. You’ll need one or more timer helpers and probably an input_select helper to keep track of where you are in the process. A timer can be cancelled or (re)started. You can trigger an automation on timer.finished. You can add the timers and input_select to your dashboard and watch the process.
I assume you’ve already created some automations to get where you are. See how far you can get with these hints. Sometimes it’s good to struggle a bit in order to gain understanding. Scripts are just automations without a trigger. They are useful when you need to reuse the same logic/actions from multiple automations or maybe even multiple places in the same automation.
One final hint. As long as your motion sensor is reliable, I like to cancel the timer(s) when motion is first detected and then restart the timer when the motion is clear. Otherwise, constant motion could allow your timer to expire. It’s OK to cancel a timer that is already idle. It has no effect.
Yes, that could work. Didn’t occur to me because I’ve yet to use multicolor lights with HA. However, in general, there might be more states than colors. Maybe he’ll want to add flashing next?
The red light does really not make any sense.
The sensor will not transmit motion all the time, when there is motion, but with intervals, so the red light will just be the “cool down” of the sensor or it’s transmitting interval.
The easiest way would just be to make anautomation that have mode set to restart and then all the events will just be timed with delays.
Success! I now have 2 color-coded bathroom occupancy indicators (1 for each bathroom in an office). Red when occupied, yellow for 3 minutes (let the smells dissipate =), then green for 10 minutes. I used the Linptech ES1ZZ(TY) zigbee occupancy sensor reviewed on https://www.youtube.com/watch?v=Kt1FpRM8R18
For reference, here’s what I ended up doing. There’s an automation that triggers off the mmwave occupancy sensor, it sets a RGB light to red and clears the 3 minute and 10 minute timers: