{"id":786,"date":"2019-02-27T14:22:40","date_gmt":"2019-02-27T19:22:40","guid":{"rendered":"http:\/\/www.thesmarthomehookup.com\/test_install\/?p=786"},"modified":"2023-04-24T15:43:00","modified_gmt":"2023-04-24T19:43:00","slug":"adding-google-calendar-to-your-smart-home-home-assistant","status":"publish","type":"post","link":"https:\/\/www.thesmarthomehookup.com\/test_install\/adding-google-calendar-to-your-smart-home-home-assistant\/","title":{"rendered":"Adding Google Calendar to Your Smart Home (Home Assistant)"},"content":{"rendered":"<p><iframe width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/OEzpG-iDDlA\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"\"><\/iframe><\/p>\n<p>Today on the hookup I\u2019m going to show you how to let your smart home adapt to your busy and ever changing schedule by integrating google calendar into your automations.<\/p>\n<p>My wife is a planner, and an awesome one at that.&nbsp; Our shared google calendar is always accurate and up to date, and knowing that really takes a lot of stress out of my life.&nbsp; Unfortunately, based on the events on the calendar I often find myself needing to manually switch automations on or off in home assistant, which sounds like the opposite of automation to me.<\/p>\n<p>In this video I\u2019m going to show you two different ways to integrate your google calendar with your smart home:&nbsp; First through a simple webservice like IFTTT, and then as a component in home assistant.<\/p>\n<p>The easiest way to allow your smart home interact with your google calendar is with the IFTTT webservice.&nbsp; If you\u2019ve never heard of IFTTT, first of all, congratulations on living under a rock for the last 4 years, and second, IFTTT or I. F. T. T. T. is a web service that allows you to write simple If this than that integrations for many of your cloud based products.&nbsp; After simply signing in to your google account and granting access to IFTTT, your google calendar events can be used as If triggers or Then responses in IFTTT and you can pair them with all of the other services already supported by their platform.&nbsp; Some notable integrations include Samsung smart things hub, wink hub, and the Tuya smart app. &nbsp;The setup process is extremely straight forward, and that\u2019s ultimately the reason why IFTTT is so popular.&nbsp; That being said, IFTTT is a web service, and honestly in my experience with it, it has been clunky, slow to respond, and not super reliable. If you\u2019ve only got a few automations and those automations are non-critical, IFTTT will probably work out just fine for you, but if you\u2019re getting serious about home automation there are better ways.<\/p>\n<p>Specifically, home assistant integration with google calendar is not only powerful, but pretty simple and well documented.<\/p>\n<p>To add your google calendar to home assistant you\u2019ll first head over to the google developers console while logged into the google account you want to integrate.<\/p>\n<p>You\u2019ll be presented with a setup wizard that will step you through all the consent screens needed to obtain your OAuth credentials, but you don\u2019t need to finish the whole wizard.&nbsp; When you get to the question asking about which API you\u2019ll be using, you can just click cancel.<\/p>\n<p>Then under API\u2019s and Services select \u201ccredentials\u201d and then click on the tab \u201cOAuth consent screen\u201d<\/p>\n<p>On this screen you\u2019ll enter a descriptive product name for this credential, homeAssistant works well, but you can call it anything you\u2019d like.&nbsp; Click save.<\/p>\n<p>Next click \u201ccreate credentials\u201d \u201cOAuth Client ID\u201d, set the application type to \u201cother\u201d and give a specific name to the credential you are creating, again homeAssistant works fine here.&nbsp; Then click create and it will generate a ClientID and Secret for you.<\/p>\n<p>At this point you\u2019ll want to go into your configuration.yaml file and create an entry called \u201cgoogle\u201d with the values client_id and client_secret.&nbsp; Copy and paste your ClientID and ClientSecret into your configuration.yaml file (or better yet, use your secrets file for these values), but don\u2019t restart home assistant yet.<\/p>\n<p>Go back to the google developers console and search for \u201cCalendar\u201d and select \u201cGoogle Calendar API\u201d.&nbsp; On the next screen that pops up just click \u201cEnable\u201d and you\u2019re all set.<\/p>\n<p>When you restart home assistant you\u2019ll see a new file show up in your config folder called google_calendars.yaml that will have separate listings for each calendar that you have created yourself or has been shared with you.<\/p>\n<p>For me, I was only interested in adding a sensor two of my calendars, so I under the rest of my calendars I changed the value from \u201ctrack: true\u201d to \u201ctrack: false\u201d.&nbsp; I also added a value called \u201cname\u201d to make the calendar names a bit more user friendly, when you\u2019re all finished hit save, then restart home assistant.<\/p>\n<p>When home assistant comes back up you should see all of your tracked calendars under the \u201cstates\u201d tab in home assistant, and all that\u2019s left to do at that point is automate.<\/p>\n<p>I do all of my automations in Node-RED, so lets take a quick look at what I\u2019ve done with that.&nbsp;&nbsp; A quick side node before we begin.&nbsp; There is a node palette for node red to directly support google calendar, but the nodes are not being actively maintained, and I was not able to make direct google calendar integration work in node red, I suspect this is because it relies on the google plus API, which was recently marked as end of life.&nbsp; Thankfully, the home assistant integration works perfectly, and node-red plays nice with home assistant.<\/p>\n<p>The two main automations that I\u2019m modifying with google calendar are my sunrise alarm clock, and my daughter\u2019s RGB alarm clock.<\/p>\n<p>The sunrise is simple enough.&nbsp; I just added a home assistant current state node in the middle of the flow to check if the day is marked as \u201cschool\u201d or \u201cnonschool\u201d in the calendar. &nbsp;The part of the message that contains that information is specifically msg.data.attributes.message, which I know sounds confusing, but it just comes from the json object that is generated by home assistant. If that particular value comes back as nonschool it blocks the flow and prevents the sunrise from starting so I can sleep in a bit on days off.<\/p>\n<p>My daughter\u2019s schedules are a bit different.&nbsp; On weekdays she has 10 minutes in between her \u201cstart waking up\u201d, \u201cstart getting dressed\u201d and \u201cgo downstairs\u201d lights, so I\u2019m utilizing a trigger node to send the next color after a set amount of time.&nbsp; The light scheduler node triggers every day for \u201cnon school days\u201d before checking the calendar to confirm the schedule, this means that long breaks like spring break and winter break will automatically switch for every day.&nbsp; The school days light scheduler is only on weekdays, since we won\u2019t have any surprise school days on the weekend, but it will also check the google calendar with a current state node in home assistant to make sure it won\u2019t wake my daughter up on a non-school day.<\/p>\n<p>Another useful change you could make to these flows would be to use the \u201ccontains\u201d flag in the switch node which allows you to parse your events to look for a single word, rather than having to have the entire string correct.&nbsp; In other words, the event doesn\u2019t have to be called exactly \u201cnon-school\u201d it could be \u201cnon-school \u2013 winter break) and because it still contains the word non-school it could work in the automation.<\/p>\n<p>As you can see, the integrations you can make in home assistant are significantly more powerful than what you can do with IFTTT, but they come with a bit more setup.&nbsp; Either way, I hope this video gave you some ideas for how to add google calendar into YOUR automations.&nbsp; If you\u2019re using google calendar in a different way that\u2019s working well for you, let me know down in the comments.<\/p>\n<p>Thank you to all of my awesome patrons over at patreon for your continued support of my channel.&nbsp; If you\u2019re interested in supporting my channel check out the links in the description.&nbsp; If you enjoyed this video, please consider subscribing, and as always, thanks for watching the hookup.<\/p>\n<h5>Node Red Flow: <a href=\"https:\/\/github.com\/thehookup\/Node-RED-Examples\/blob\/master\/Calendar_Flow.json\">https:\/\/github.com\/thehookup\/Node-RED-Examples\/blob\/master\/Calendar_Flow.json<\/a><\/h5>\n<h5>Follow me on Twitter: @TheHookUp1<\/h5>\n<h5><\/h5>\n<h5>Support my channel:<\/h5>\n<h5>Patreon: <a href=\"https:\/\/www.patreon.com\/thehookup\">https:\/\/www.patreon.com\/thehookup<\/a><\/h5>\n<h5><\/h5>\n<h5><\/h5>\n<h5>Music by www.BenSound.com<\/h5>\n","protected":false},"excerpt":{"rendered":"<p>Today on the hookup I\u2019m going to show you how to let your smart home adapt to your busy and ever changing schedule by integrating google calendar into your automations. My wife is a planner, and an awesome one at that.&nbsp; Our shared google calendar is always accurate and up to date, and knowing that [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":2574,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-786","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"acf":[],"mb":[],"mfb_rest_fields":["title","gutenberg_elementor_mode"],"_links":{"self":[{"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/posts\/786","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/comments?post=786"}],"version-history":[{"count":4,"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/posts\/786\/revisions"}],"predecessor-version":[{"id":2327,"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/posts\/786\/revisions\/2327"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/media\/2574"}],"wp:attachment":[{"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/media?parent=786"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/categories?post=786"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/tags?post=786"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}