{"id":2182,"date":"2023-10-15T13:27:08","date_gmt":"2023-10-15T13:27:08","guid":{"rendered":"https:\/\/www.creatingsmarthome.com\/?p=2182"},"modified":"2023-12-03T10:13:41","modified_gmt":"2023-12-03T10:13:41","slug":"home-assistant-automating-calendar-event-creation-and-running-devices-when-the-energy-price-drops-below-a-certain-point","status":"publish","type":"post","link":"https:\/\/www.creatingsmarthome.com\/index.php\/2023\/10\/15\/home-assistant-automating-calendar-event-creation-and-running-devices-when-the-energy-price-drops-below-a-certain-point\/","title":{"rendered":"Home Assistant: Automating calendar event creation and running devices when the energy price drops below a certain point"},"content":{"rendered":"\n<p>As you may know, I&#8217;m using <a href=\"https:\/\/www.creatingsmarthome.com\/index.php\/2023\/04\/12\/home-assistant-advanced-nord-pool-cheapest-hours-with-local-calendar-support\/\" data-type=\"URL\" data-id=\"https:\/\/www.creatingsmarthome.com\/index.php\/2023\/04\/12\/home-assistant-advanced-nord-pool-cheapest-hours-with-local-calendar-support\/\">local calendar these days to run specific automations when the electricity price is the cheapest<\/a> on each day. However, this time I want to heat my outdoor hot tub when ever the electricity price drops below certain point. And for that, I want to use the same local calendar as with the other electricity schedules. (<strong>Ps. If you haven&#8217;t read the <a href=\"https:\/\/www.creatingsmarthome.com\/index.php\/2023\/04\/12\/home-assistant-advanced-nord-pool-cheapest-hours-with-local-calendar-support\/\" data-type=\"link\" data-id=\"https:\/\/www.creatingsmarthome.com\/index.php\/2023\/04\/12\/home-assistant-advanced-nord-pool-cheapest-hours-with-local-calendar-support\/\">previous article yet<\/a>, I&#8217;d suggest to do that first since this is kind of continuation on that<\/strong>).<\/p>\n\n\n\n<p>In more details, this automation is going to fill <strong>the local calendar for the next day with heating schedules<\/strong> to fully heat my hot tub after the electricity prices are received. In fact, I&#8217;m just going to play with high \/ low range of the Balboa spa to toggle between 20\u00b0C (low) and 37\u00b0C (high) during the cheap hours, but that&#8217;s not the main point of this automation.<\/p>\n\n\n\n<p>The biggest change regarding the previous advanced cheapest hours automation is that this time the <strong>calendar entries might not be sequential<\/strong>. However, I don&#8217;t want to have separate entries of each hour on the calendar either if the prices happens to be sequential. That would cause some odd behaviour of the devices if in the same second the automation triggers off and on again. So I just got to join the sequential  entries with each other before actually adding them to calendar.<\/p>\n\n\n\n<p>Hopefully <strong>a picture<\/strong> will explain the situation a bit more, so here it goes. In the picture below you can see my heating schedule of the hot tub for today and tomorrow!<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"736\" height=\"364\" src=\"https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-12-at-15.02.37.png\" alt=\"\" class=\"wp-image-2219\" srcset=\"https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-12-at-15.02.37.png 736w, https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-12-at-15.02.37-300x148.png 300w\" sizes=\"auto, (max-width: 736px) 100vw, 736px\" \/><\/figure>\n\n\n\n<p><strong>Note<\/strong>: This solution might be a bit overkill, since you could just easily check the current price of nord pool sensor and act regarding that state. However, I would like to have a general overview of my electricity schedules through the calendar, so that&#8217;s why a bit over-engineering the whole system \ud83d\ude42<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating the calendar<\/h2>\n\n\n\n<p>Ok, I&#8217;m not going to repeat the same things as in previous posts, so you can check out the local calendar creation from previous <a href=\"https:\/\/www.creatingsmarthome.com\/index.php\/2023\/04\/12\/home-assistant-advanced-nord-pool-cheapest-hours-with-local-calendar-support\/\" data-type=\"link\" data-id=\"https:\/\/www.creatingsmarthome.com\/index.php\/2023\/04\/12\/home-assistant-advanced-nord-pool-cheapest-hours-with-local-calendar-support\/\">Advanced Cheapest Hours article<\/a> \ud83d\ude42<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing the package<\/h2>\n\n\n\n<p>Pre-requisites for this package to work is to have Nord Pool integration installed. You can look for integration installation guide from <a rel=\"noreferrer noopener\" href=\"https:\/\/www.creatingsmarthome.com\/index.php\/2022\/09\/17\/home-assistant-nord-pool-spot-prices-and-how-to-automate-devices-for-cheapest-hours\/\" data-type=\"URL\" data-id=\"https:\/\/www.creatingsmarthome.com\/index.php\/2022\/09\/17\/home-assistant-nord-pool-spot-prices-and-how-to-automate-devices-for-cheapest-hours\/\" target=\"_blank\">the original cheapest hours article<\/a> or directly from <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/custom-components\/nordpool\" data-type=\"URL\" data-id=\"https:\/\/github.com\/custom-components\/nordpool\" target=\"_blank\">Nord Pool integration GitHub page.<\/a> Once that is done, continue reading..<\/p>\n\n\n\n<p>Advanced cheapest hours package can be found from my <a href=\"https:\/\/github.com\/kotope\/ha_nordpool_cheapest_hours\/blob\/main\/cheap_hours_limit_price.yaml\" data-type=\"link\" data-id=\"https:\/\/github.com\/kotope\/ha_nordpool_cheapest_hours\/blob\/main\/cheap_hours.yaml\">Cheapest hours GitHub page<\/a>, so download it and copy it on your Home Assistant &#8216;<em>config<\/em>&#8216; folder.<\/p>\n\n\n\n<p>After copied, find the <em>homeassistant:<\/em> -block from your <em>configurations.yaml<\/em> file and add the package include on it. If you don&#8217;t have <em>homeassistant:<\/em> -block, just copy the whole block in any root level of <em>configuration.yaml<\/em> file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>homeassistant:\n  packages:\n    cheapest_hours_price_limit: !include cheap_hours_limit_price.yaml<\/code><\/pre>\n\n\n\n<p>More details about Home Assistant packages can be found from <a href=\"https:\/\/www.home-assistant.io\/docs\/configuration\/packages\/\" data-type=\"URL\" data-id=\"https:\/\/www.home-assistant.io\/docs\/configuration\/packages\/\">here<\/a>. Or if in doubt, leave a comment on the comment field and I&#8217;ll try to help you out \ud83d\ude42<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Configuring the package<\/h2>\n\n\n\n<p>Once the package is in place, it&#8217;s only about to configure your own preferences of it.<\/p>\n\n\n\n<p><strong>In this package there are only few configurable entries:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>price_limit<\/strong>: limit price when to create the calendar entry<\/li>\n\n\n\n<li><strong>sensor<\/strong>: your nordpool sensor id<\/li>\n\n\n\n<li><strong>grace_period<\/strong>: how long grace time we add if the hour is last of the day. We can&#8217;t merge the events between two days so in this case, we want to add a little delay so the off- and on-entries are not triggered at the same time. e.g. the last hour entry would be something like 23:00-23:55.<\/li>\n<\/ul>\n\n\n\n<p>Those entries can all be found under the first template sensor, just below &#8216;attributes&#8217;!<\/p>\n\n\n\n<p><strong>And one final and most important configuration required<\/strong>: what is being done when the calendar event triggers! Under the automation <em>&#8220;id<strong>: <\/strong>&#8216;Energy<strong>: <\/strong>Cheap hours schedule entry'&#8221;<\/em> there are couple of <strong>#CHANGE-ME<\/strong> tags where you can change your own actions what ever you like to do with the automation!<\/p>\n\n\n\n<p>When these changes are done, the entries should appear to your &#8216;<strong>electricity<\/strong>&#8216; calendar once the next day prices are published on the Nord Pool integration!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>A bit overkill maybe, but I like to keep my schedules under a calendar so I can have a quick look of the upcoming energy schedules! So far this automation has been working a bit more than a week with zero issues, hopefully it will continue that way as well.<\/p>\n\n\n\n<p>I might still need to do some tweaking with the grace period. I could just keep the automation running during the grace period and not to turn off the device if next period starts just after the grace time.<\/p>\n\n\n\n<p>Anyhow, in my opinion, this is a good start to go forward with energy optimisations and maybe the next step could be (finally) to enable non-sequential cheapest hours using relative energy price of each day \ud83d\ude42<\/p>\n\n\n\n<figure class=\"wp-block-image size-medium\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"263\" src=\"https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-15-at-15.52.12-300x263.png\" alt=\"\" class=\"wp-image-2227\" srcset=\"https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-15-at-15.52.12-300x263.png 300w, https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-15-at-15.52.12-1024x896.png 1024w, https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-15-at-15.52.12-768x672.png 768w, https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2023\/10\/Screenshot-2023-10-15-at-15.52.12.png 1122w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<div style=\"border: 3px dashed #abb8c3; border-radius: 0%; background-color: inherit; \" class=\"ub-styled-box ub-bordered-box wp-block-ub-styled-box\" id=\"ub-styled-box-c03f7c6f-0e74-417f-b394-326f6c5153c0\">\n<p id=\"ub-styled-box-bordered-content-\"><h5 class=\"wp-block-heading has-text-align-center\">Did you find this guide helpful? You can keep the blog going by bidding me a coffee!<\/h5>\r\n<center>\r\n<script type=\"text\/javascript\" src=\"https:\/\/cdnjs.buymeacoffee.com\/1.0.0\/button.prod.min.js\" data-name=\"bmc-button\" data-slug=\"tokorhon\" data-color=\"#FFDD00\" data-emoji=\"\"  data-font=\"Cookie\" data-text=\"Buy me a coffee\" data-outline-color=\"#000000\" data-font-color=\"#000000\" data-coffee-color=\"#ffffff\" ><\/script>\r\n<\/center><\/p>\n\n\n<\/div>","protected":false},"excerpt":{"rendered":"<p>As you may know, I&#8217;m using local calendar these days to run specific automations when the electricity price is the cheapest on each day. However,&hellip;<\/p>\n","protected":false},"author":1,"featured_media":2229,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[100],"tags":[105,324,323,224,267,106,7,325,218,266,223,8],"class_list":["post-2182","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-home-assistant","tag-automation","tag-calendar","tag-cheap-hours","tag-cheapest-hours","tag-energy","tag-energy-saving","tag-home-assistant","tag-local-calendar","tag-nord-pool","tag-nordpool","tag-package","tag-smart-home","has-post-thumbnail-archive"],"acf":[],"featured_image_src":"https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2023\/10\/cheap_hours_automation.png","author_info":{"display_name":"Toni","author_link":"https:\/\/www.creatingsmarthome.com\/index.php\/author\/topsy\/"},"_links":{"self":[{"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/posts\/2182","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/comments?post=2182"}],"version-history":[{"count":28,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/posts\/2182\/revisions"}],"predecessor-version":[{"id":3285,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/posts\/2182\/revisions\/3285"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/media\/2229"}],"wp:attachment":[{"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/media?parent=2182"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/categories?post=2182"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/tags?post=2182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}