Turn on light when user arrives and it is after sunset?

Hi everyone! I am a HA newbie, but am loving it so far. I have all the basics setup and am now trying to dive deeper. I would like to trigger the porch light (Hue) when I arrive home (via iCloud integration) and it is after sunset. I am having a hard time figuring it out and couldn’t find an example script to work off of. Would someone mind posting one? Thanks so much!

See of this helps you figure it out; think of it this way:

The Trigger is the person arriving (An event or state on the device tracker)
The Condition is the sunset (the state of the platform Sun)
The Action is turning on (service light.turn_on) the Hue light (entity_id= light.YourHueLight)

1 Like

That is extremely helpful! I should have asked for hints instead. Is there an easy way to test this type of thing to see if it will work instead of having to wait until all the conditions are met?

Here is what I came up with. Not sure if it works :slight_smile:

http://pastebin.com/Ubr8NDjj

Looks OK, just the one extra space on line 14 needs to be fixed. I think you can fire the automations from the UI if you put them in à group now.