I have hunted though multiple other topics and am doing my best to understand the docs, but just can’t seem to find a simple way of doing this.
Is there a way to have a condition that looks at the PREVIOUS STATE of an entity?
Situation:
I have a few Shelly Dimmer 2’s that control the brightness of our lights. I use scenes and automations to change those brightness for varied reasons, however I would like a simple physical way to reset the brightness back to 100% via the wall switch. The wall switch will toggle the Shelly Dimmer between ON and OFF but uses its last brightness setting.
Desired solution:
An automation that sets the lights to 100% brightness, using a condition that checks that the light WERE only off for 2 (or less) seconds.
automation:
# When the light turns on
trigger:
- platform: state
- entity_id: light.my_light
- to: "on"
# Light is only off for 2 seconds
- condition: state
entity_id: light.my_light
state: 'off'
- condition: not
conditions:
- condition: state
entity_id: light.my_lights
state: 'off'
for:
seconds: 2
Obviously the above won’t work as it contradicts itself. I think I may need templates? But not quite sure how to implement.
Absolutely perfect! Thanks so much for your reply.
I have read up on Wait For Triggers and now am able to get the exact result I was after. I tweaked your code slightly, as after testing I realised I only wanted a 2 second wait between off and on, and the initial off timeout wasn’t required. Also 2 seconds was a bit ambitious, so I increased to 4. Here is the complete code for anyone else who finds this useful, and a link to Wait For Trigger docs.