Howdy, folks!
New user running HA on a Pi4. I have successfully gotten ZwaveJS working, my devices are recognized, but I’m having some trouble getting my head around automation. I am able to get them ‘half working’, but I suspect I’m not fully comprehending the process.
What I’d like:
Turn on driveway lights 1 hour before sunset
Turn off driveway lights at 10PM
I’ve tried two different methods, one with a trigger condition, the other with actions only, hoping that a sequence of conditions and actions would execute.
Actions:
Conditions: Sun / before sunset -00:60:00
Device: driveway lights / turn on
Conditions: Time / Fixed Time / 20:00
Device: driveway lights / turn off
Seems I’m just not quite getting it right. Should these commands be in two separate automations?
Yes. An automation will not start without a trigger and it looks like you have two separate actions with different triggers.
Conditions are mostly used to prevent an automation running, or to stop it halfway through - if the condition is not met, the automation stops.
Based on your requirements…
You don’t need any conditions, so it seems you have misunderstood something.
This is easily done with a single automation
trigger:
- platform: sun
event: sunset
offset: '-01:00:00'
- platform: time
at: '22:00:00'
action:
service: "light.turn_{{ 'off' if trigger.platform == 'time' else 'on' }}"
entity_id: light.driveway
1 Like
Or to keep it simple…
Automation 1 Light on:
trigger:
- platform: sun
event: sunset
offset: '-01:00:00'
action:
service: light.turn_on
entity_id: light.driveway
Automation 2 Light off:
trigger:
- platform: time
at: '22:00:00'
action:
service: light.turn_off
entity_id: light.driveway
Thanks for the feedback, guys. That’s very helpful.
I’m not a command line guy, so until I get more comfortable with that, I think it’s safer to stick with the GUI. I’ll revise these and give it another go.
Appreciate the help!