I have two sensors and two lights and I want the lights to respond to the status of the sensors

I’m sure this is a “magic word” problem, if I knew the HA Magic word to search for, I’d find my answer easily. The terms I know from Uni are state transition table, but state seems to have a different meaning in HA.

Let’s say we’re “NEUTRAL”, if sensor 1 opens, I want to move to “R” and set lights a particular way. If sensor 2 opens, I want to move to “E” and set lights a different way. From “E” if sensor 2 closes I want to move back to “NEUTRAL”.

The ? is how do I do this in HA?

TIA -----Burton

Complete the following table by specifying the desired light behavior for the given states of sensor1 and sensor2.

S1 S2 Lights
off off ?
off on ?
on off ?
on on ?
1 Like

I wanted to key it off the transition, not the state - that’s more reliable for my use case (keeping two cats separated). If I go in to feed CatE, I don’t want CatR’s safety light to switch colors.

State Event-Ro Event-Rc Event-Eo Event-Ec
Eout DANGER Eout Eout Nobody
Rout Rout Nobody DANGER Rout
Nobody Rout Nobody Eout Nobody
Danger DANGER Eout DANGER Rout

The events would be the sensor open/closed for more than 10 seconds.

So if Eout and Ropens, I want both lights to set to DANGER.

Then state DANGER = Both Lights RED
State Rout would be one light green, the other light red

etc.

You’re presenting this in a way that is very hard to read, and I do hope that “cats” are not a euphemism for “workers in an industrial machine situation”.

It looks like you’re trying to make a state machine. You could record your states in a helper (perhaps enumerated in an input_number), and set them via automations that use the sensor transitions and that state record as triggers and conditions.

Does that help, or do you need more hand-holding through this?

Sorry for the delay, life interfered.

Yes, it really is two cats. Ernie attacked Ruby and bit her badly enough to cause an abscess. So we keep them separated.

Yes, I want to create a state machine, that’s how I presented it—the benefits of an Electrical Engineering degree and Computer Science background.

I’ll look into helpers. Magic word problem - once you know what something is called in a problem domain, there are lots of resources. If you don’t know the word…

Thanks!

-----Burton

1 Like