Does sunset event only work At the moment of sunset or beyond?

The entity already has the switch name in front of it:
- id: '9205477723305'
  alias: TEST
  trigger:
   platform: time
   at: '21:16:00'
  action:
   service: light.turn_on
   data:
    entity_id: switch.leviton_dzs151lz_switch_switch

But I noticed in your example you used switch.turn_on instead of light. let me try that.

I think that was it! Thank you!. That darn light.turn_on doesn’t really work after all
Hang on I have more to post but let me double check something first

to save any issues with device type you can use homeassistant.turn_on which will work for either type

yeah if it’s a switch then switch.turn_on for the service

or what @sparkydave said. In one of my examples it was a light and the other was a switch so hence the difference.

Yep it is working now.
Also something is now showing up in the service data window

{
  "entity_id": "switch.leviton_dzs151lz_switch_switch"
}

To me it looks it it would be easier to just edit the file directly instead trying to input all of that the automation editor?

Which do you guys use?

1 Like

I use both… I have come to prefer the yaml editor to the GUI one.

Would I have had to enter it exactly like below for it to work. Cause straight editor doesn’t need it and that way is easier for me.
{
“entity_id”: “switch.leviton_dzs151lz_switch_switch”
}

I just backed up all my work so I can work on the sunset tomorrow. I would have NEVER got this to work without all of your HELP. The ONLY part I had a hunch on was the light.turn_on being bad. And when I saw Dave’s example that gave me the push to find out!
Thanks for all your help!

Yes you would have entered it in the GUI exactly like that… you probably missed it in the post where I showed you my switch example I said you could add that in there.

Honestly, it’s a bastard getting this working and understanding the logic sometimes but I bet you learned a lot battling through it!

Yes it is.
I rushed into this too fast initially-I thought it was pnp and got frustrated, then started taking baby steps and have been having better luck.

Started it all on Thurs, then first thing working was a wifi switch on Friday.
Then ordered Zwave usb Friday night and had it Sunday morning (Amazon surprised me and it came early).

Got the zwave usb controller working on Sunday and then got my first Zwave switch working last night.

Now tonight got first small automation working (thanks again for all the help). Just now setup a sunset timer based on what we got working tonight. Hopeful it will work and then I will start adding more zwave once it is working good!
.

1 Like

Sunset worked!!!

1 Like

@Taras, - thank you for your idea. I need to test an automation that depends on sunset and I want to test the condition as it is. So I do what you have suggested - (a) stop NTP, (b) set OS time just before sunset in my location. While Developer tools → Templates with {{ now() }} shows that the time indeed was updated, not all components of HA seem to be aware of the change. If I do restart HA - they become aware. My question is - is there a more light way to make all components aware of the time change, because it full restart takes a lot of time… Something like emitting clock_updated event, or similar?..

My suggestion was made 2 years ago. Home Assistant today is nothing like it was 2 years ago. It’s inadvisable to assume advice posted 2 years ago is still applicable today.

So how do you test sunset based automations nowadays?

Let it run. If it failed to work like you expected, use the new Automation Debugging feature to examine it.

  1. I tried this already and it didn’t help.
  2. This way I can debug only once in 24 hours… not too effective…

It’s generally discouraged to revive old topics like this one (whose last post was in December 2018).

Create a new topic in the forum and post your condition.