I am trying to create the following automation:
When someone rings my doorbell (I have a Ring configured as binary sensor), I want my frontdoor light to flash a few times in blue. If it is night, the frontdoor light has to go back normal (white). If it is daytime, the light has to go back off.
The frontdoor light turns on (white) when the sun goes down. And turns off when the sun comes up.
So I looked if there was a possibility for if-else (IF sun is up turn light off after flash, ELSE stay turned on and change color back to white). But can’t find out how to fix it.
Is there a way to fix it (with or without if-else).
The easiest way might be to use my light_store python script. The idea is, when the automation wants to flash the light, it first uses the script to save the current state of the light. Then it flashes the light however it wants. Then the last step would be to call the script again, but this time to restore the state of the light back to what it was before it was flashed. Let me know if you have any questions.
Thanks for the reply! I have no idea how to use that python script haha, I am a bit of a noob.
But I think I found a way to fix it. I have created two automations (one for day, and one for night). And handled it with conditions. It works at daytime, now I only have to try if it works at night.
- id: '1543590779207'
alias: Aanbellen Avond
trigger:
- entity_id: binary_sensor.ring_veurdeur_ding
from: 'off'
platform: state
to: 'on'
condition:
condition: or
conditions:
- condition: sun
after: sunset
- condition: sun
before: sunrise
action:
- data:
brightness: 250
color_name: blue
entity_id: light.frontdoor
flash: short
service: light.turn_on
- alias: ''
data:
brightness: 250
color_name: blue
entity_id: light.frontdoor
flash: short
service: light.turn_on
- data:
brightness: 250
color_name: blue
entity_id: light.frontdoor
flash: short
service: light.turn_on
- data:
entity_id: light.frontdoor
brightness: 250
color_name: white
entity_id: light.frontdoor
service: light.turn_on