Last week I wrote up about how to set up vacation mode for your lights easily. This week we're going to complete the loop a bit and automate turning on vacation mode. Note this setup requires an Ecobee thermostat. It's a popular thermostat so this may be of some use to folks. I like the Ecobee vacation mode because it allows me to set up a permanent hold whenever I'm not at home for an extended period of time, which usually coincides with me being on vacation/away from home. Thanks to HomeAssistant you can set up a vacation on your Ecobee from a Google Calendar or other supported calendar (I used CalDAV).
Now you can set up a vacation from either the app or on the Ecobee website. So you may be asking "why do this?" The answer is I'm lazy and I hate having to open another app/webpage when I already put vacations in my calendar. So why not automate it at that point?
There are two main calendar options: CalDAV and Google Calendar. The HASS documentation is pretty decent for these so I'm not going to spend a lot of time on how to set them up. For our purposes it doesn't matter which one you use, just use whichever one you use/are most comfortable with.
Once you get your calendars imported, find the entity_id for your vacation calendar. I find it useful to have a separate calendar for vacation but you could also use another calendar and just use a search/regex to pull out your vacation entities. Either way, look for a calendar. entry in your states page of HASS and use that for the below automations.
Since I use NodeRed the below is how I got things to work. I'll share an automation for HomeAssistant that should work but I don't make any promises. Here's a visual of what the flow looks like (code will be towards the end of the post).
The first node is simply a trigger node to start the flow when the calendar in HomeAssistant goes from "off" to "on" (ie the calendar event is starting). You will need to change the entity_id to match your calendar's name.
The next 5 flows use templates to set the various variables we will need later when calling the ecobee.create_vacation service call in HomeAssistant. You will need to adjust the calendar name in each node to match your own calendar name. For the Function node, you will need to adjust the entity_id of the thermostat to yours and also adjust the temperature presets (can be in Celsius or Fahrenheit). You'll need to do the same in the Create Vacation service node.
That's it. Now whenever the calendar reaches an event on your vacation calendar, the Ecobee vacation mode will automatically be set for you. I then use proximity to trigger a flow/automation to turn on my vacation input_boolean when I get more than 20 miles from home and the Ecobee is in vacation mode. And then same works in reverse (when I go under 20 miles and the input_boolean is on, it turns off the input_boolean).