Not reactive light, but changing light at times if someone is home

I’m in the progress of migrating my automations from Reactor to Node Red. I’m still very new to Node Red.

One of the automations worked something like this (for a RGBW LED strip behind a buffet unit):
At sunset, cool white.
At 9PM, warm white.
At 10PM, orange
At 11PM, RED
At 12PM turn off.
If the alarm is armed, then turn off and don’t turn on as scheduled.
If the alarm is disarmed during one of the scheduled times, then turn on as scheduled, even if partway through the schedule.

This was trivial to do with Reactor but I’m struggling with Node Red.

To achieve, I have:

  • Created an input boolean helper in HAss named “NoOneIsHome”. This is toggled on and off by the alarm integration via a Node red flow and works fine. I created a helper on the basis that later on home occupancy may be determined by other things so I can just change one flow and everthing else that depends on it automatically updates.
  • Created four scenes in HAss for the LED strip, named Warm, Cool, Orange, Red etc.

I’ve created this flow. It seems to be awkward and clunky. Is there a better way to do this?

(It also doesn’t have the feature that if I arrive home between sunset and midnight, the light should come on to the correct color. Instead what I think will happen is I will arrive home and then light will come on when the timer next triggers. I guess I could use the every-minute output of BigTimer but then if someone changes the LED strip manually it’ll be overidden within a minute.)

A switch or state machine node could simplify this (big timer node output msg would need to be set appropriately).

Thanks @MaxK
Based on your suggestion,

  • A state machine that operates regardless of the home occupancy status to decide what color the light should be
  • A current state node that doesn’t pass on the state machine outputs if no one is home
  • A switch to route to the correct scene depending on the payload from the state machine

Just need to figure out how to get the correct scene activated if the ‘no one is home’ changes to off in the middle of a time-range.