So I just got my first automation working with the google calendar plugin today. I’m currently a SmartThings user but I’m working on moving some stuff over to HASSIO.
I created a calendar for me to plug in things that I want to fire off based off the date. For example right now I turn on my Christmas lights at 20 mins after sunset. Since there isn’t a way to plug sunset into the calendar. Should I just create the event as an all day event and then in the automation to turn on those lights would I just add a condition for sunset with a 20 min offset? Thanks for your help, I can’t believe everything that you can do with this platform its just incredible.
Edit: Or rather than a condition just add it to the trigger section?
A technique that I use with Google Calendars is to have an input_boolean that gets flipped to “true” based on a calendar event. Then I have an automation that runs at end of day to reset the booleans. I use this for “is today trash day / is tomorrow trash day”, then, knowing that today is trash day, I can trigger spoken notifications at certain times during that day based on motion in a particular room. I cluster the calendar events around 12:30am so they’re valued before we start our day.
thank you @ih8gates thats an interesting approach to that.
Right now I’ve got it setup like this. I’ll have to add another event to the calendar since we only run ours through the 31st of Dec but well I can always just create an event for tonight and see what happens.
-
action:
-
entity_id: group.christmas_lights
service: light.turn_on
alias: "Christmas Lights"
id: christmas_lights
trigger:
-
entity_id: calendar.christmas_lights
platform: state
to: "True"
-
event: sunset
offset: "00:20:00"
platform: sun
Just what I was looking to do this year, but couldn’t really figure it out. Would any of you know where I could find an example on how to turn on an Input_Boolean from a calendar entry? Should that entry be an all day event?
Also do you need one entry for every day or one single entry at the beginning of December to turn the input_boolean “on” and one at the end of December to turn it “off”? I can see the reasoning of having one entry per day, this way if the system is down on the day that it is supposed to be turned off, then it will correct itself by the end of the day.
Thanks … this is a great start and good examples. Now your calendar entry … is it for an “All Day” even or do you schedule it for a specific time of the day? And does your Subject line just lists “trash_today” … “recycle_today”? I am assuming that the text in your calendar should match closely your entity_id … correct?
The event only needs to be a minute long since the boolean keeps state. You could probably have an all-day event and do the exact same thing, skipping the boolean entirely.
I use a search key to match the name of my event. Read up here:
That’ll also let you configure the entity_id of your calendar sensor.
Well mine did not fire off like it should’ve tonight. It shows in the attributes that the event is true but it didn’t turn on the lights at 20 mins after sunset. Time to diagnose. I am using an all day event for mine.
Set the sunset as a trigger and the calendar entry as a condition. The way you’ve set things, the automation will trigger once when the calendar sensor is true, then never trigger again unless the calendar goes false then back to true. And then the trigger will coincide with the calendar, not sunset.
Look at the states dev tool. Make sure that calendar.christmas_lights has a state of “on”
Look at the automation in the states dev tool - does it have a “last_triggered” value?
What happens if you manually trigger the automation? Do the lights behave correctly?
Is that really what your YAML looks like? I don’t have newlines after dashes (-). But that might be fine notation - just not how I do it. Make sure there are no errors in your home_assistant.log
Some additional advice: I’m not sure I’d go with a 4 hour delay in the action. Set up 2 automations, one for turning the lights on, one for turning them off. Use a 4 hour offset for the off.
Also - I sometimes notice issues when I restart my HA within the window of sunset-based automations that use offsets.
My system speaks reminders so that my kids remember to take cans to the curb. They get a couple reminders the evening before, then one more the morning of.
Also, I can ask: “Alexa, is tomorrow recycle day?” (we get recycling every other week)
Yeah the formatting is from the yamlint checker. It does that apparently to make it ruby compliant. I’m like eh whatever lol.
Ok so I moved the event from yesterday to, today and it is now showing up as on. However when I trigger the automation nothing happens. Is this because I need to call a different service to turn on a group? Time to google that one.
I can’t do the light.turn_on because I have switches and lights tied together in the group. So I have to use homeassistant.turn_on to turn on the group. Now to test it out but I think this might be the kicker
EDIT2: Yep that was it. So obvious now to see if it turns on the lights after sunset tonight.
Oh I also took your advice to separate the turn off so its no longer in the turn on automation instead I did it where it will turn off 6 hours and 20 mins after sunset. I forgot that I wanted 6 hours and not 4