I have created an automation that I need a little push in the correct direction for how to program for an exception situation that occurs.
I have hass.agent sending my desktop microphone process status to HA. I have two lights (a kauf bulb and a wyze bulb) turn red to let others in the home know that I am on the phone. I do this by having the automation perform the following:
I have two trigger states: changing to “Softphone” and changing from “Softphone” - both of them have IDs
The action is a CHOOSE
Option 1:When the status changes to “Softphone”, IF kauf bulb is on for 10 seconds, THEN create a scene of its current state, call service light.turn_on to change the color to darkred. And the same for the wyze bulb.
Option 2: When the status changes from “Softphone”, IF Kauf bulb is on, THEN change SCENE “bulb previous state”. and same for the wyze bulb.
Situation 1
How do I program for the situation that someone turns off the light while it is red? When they turn it back on, it is set to always on previous state in the bulb settings.
Situation 2
How do I program for the situation when someone turns on the light long after I am on the phone and the trigger has run
If I set the automation to repeat, it will overwrite the temporary scene.
I’m sure this isn’t very efficient code. I added multiple triggers with conditions. I had to add a delay and repeats for the wyze bulbs because they are far from reliable from what I have seen.
You would need to trigger on the light becoming available again and then test if you are on the phone or not to determine if the light still needs to be red, or if it should call the scene which gives the previous colour.
The same solution would fix ‘situation 2’.
EDIT: at a glance it looks like this is what you have done.
The Wyze bulbs don’t seem to listen the first time every time.
Changing to off would be one I would use if folks were controlling the lights with home assistant. The other folks in the home are just using the light switch. I could also add that or change my logic to be “from ON”.
Considering moving away from them entirely. So I’ll likely go zigbee or Wi-Fi esphome. We use Sneider electric zigbee devices at work (industrial automation) and they work pretty darn well.
I think what actually got the wyze bulbs working was the one minute delay. It doesn’t look like they like obeying a command from the api as soon as they are powered on. I also experience the same thing with their native app.