I trying to make a simple automation, where a switch should be turned on for 1 Minute, then turn off, then wait 20 MInutes, then repeat. Trigger is sunset. But for some reason the automation won’t start. Any hints? What am I overlooking here?
Here’s how I’d write that automation, assuming this is the only thing that operates that light.
With this setup, the automation is always run “instantly”, rather than having any timing or looping within it. This is better (IMO), avoiding complex logic in the action. Three triggers:
sunset, via below_horizon state
light has been on for a minute
light has been off for 20 minutes
The condition block prevents the light turning on before sunset, but allows the light to turn off if the sun rises whilst it is on.
- id: '1685191263449'
alias: Taubenabwehr
description: Steckdose Terrasse nachs alle 20 Min für 1 Min einschalten
trigger:
- platform: state
entity_id: sun.sun
to: "below_horizon"
id: "turn_on"
- platform: state
entity_id: light.steckdose_terrasse
to: "on"
for:
minutes: 1
id: "turn_off"
- platform: state
entity_id: light.steckdose_terrasse
to: "off"
for:
minutes: 20
id: "turn_on"
condition:
- condition: or
conditions:
- condition: state
entity_id: sun.sun
state: "below_horizon"
- condition: trigger
id: "turn_off"
action:
- service: light.{{ trigger.id }}
entity_id: light.steckdose_terrasse