{"id":769,"date":"2021-10-23T06:53:23","date_gmt":"2021-10-23T06:53:23","guid":{"rendered":"https:\/\/www.creatingsmarthome.com\/?p=769"},"modified":"2023-11-06T12:58:28","modified_gmt":"2023-11-06T12:58:28","slug":"home-assistant-scheduling-the-car-heater","status":"publish","type":"post","link":"https:\/\/www.creatingsmarthome.com\/index.php\/2021\/10\/23\/home-assistant-scheduling-the-car-heater\/","title":{"rendered":"Home Assistant: Scheduling the car heater"},"content":{"rendered":"\n<p>Winter is coming once again and pre-heating car is needed when the temperature drops below five degrees. This automation is something that I wrote to a friend of mine and he has been using it for a year now for two cars, so I&#8217;d say it&#8217;s usable since I&#8217;ve had no complaints about it \ud83d\ude42 <\/p>\n\n\n\n<p>Full package can be downloaded from my GitHub repository at <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/kotope\/ha_car_heater\" data-type=\"URL\" data-id=\"https:\/\/github.com\/kotope\/ha_car_heater\" target=\"_blank\">https:\/\/github.com\/kotope\/ha_car_heater<\/a><\/p>\n\n\n\n<p><strong>(Note 10.12.2021: The old version automation will break with Home Assistant release 2021.12, since time format changes on the Home Assistant end. Fixed version of the automation is available at GitHub link above (basically just changing all timestamp_local -&gt; timestamp_custom)<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Scheduling car heater with Home Assistant\" width=\"774\" height=\"581\" src=\"https:\/\/www.youtube.com\/embed\/PWPEg_CgOIs?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p><em>This is automation is based on existing automation, but this has quite many tweaks compared to the original. Original can be found from <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/newlund\/HA-Engine_heater\" data-type=\"URL\" data-id=\"https:\/\/github.com\/newlund\/HA-Engine_heater\" target=\"_blank\">here<\/a> (thanks to the original author as well).<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What does it do?<\/h2>\n\n\n\n<p>The grand idea is to make pre-heating car as simple as possible. You set departure time from Home Assistant UI and the automation handles the rest. <\/p>\n\n\n\n<p>Of course below the hood there&#8217;s more logic:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>User sets the departure time from UI<\/li>\n\n\n\n<li>Automation calculates how long should the heating be on using current temperature\n<ul class=\"wp-block-list\">\n<li>Will run only if temperature drops &lt; 10<\/li>\n\n\n\n<li>Formula: temperature * -0.05 + 1\n<ul class=\"wp-block-list\">\n<li>Summary: -30c = 2.5h; -20c = 2h; -10c = 1.5h; 0c=1h; +5c=0.8h<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>3 hours before departure automation re-checks the temperature and does adjustments to heating time<\/li>\n\n\n\n<li>At calculated heater start time checks the power comsumption of the plug\n<ul class=\"wp-block-list\">\n<li>If power consumption stays at zero, send push notification to user to check if power cable is connected<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Stop heating at departure time<\/li>\n<\/ul>\n\n\n\n<p>Also there&#8217;s also a text included that shows the current status of the automation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Requirements<\/h2>\n\n\n\n<p>Required and optional hardware for this to work:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Home Assistant supported outdoor plug with power consumption support (e.g. <a rel=\"noreferrer noopener\" href=\"https:\/\/www.puuilo.fi\/nedis-wi-fi-ulkopistorasia-smartlife-ip44-schuko-16a\" data-type=\"URL\" data-id=\"https:\/\/www.puuilo.fi\/nedis-wi-fi-ulkopistorasia-smartlife-ip44-schuko-16a\" target=\"_blank\">Nedis Outdoor plug<\/a> flashed with <a rel=\"noreferrer noopener\" href=\"https:\/\/templates.blakadder.com\/nedis_WIFIPO120FWT.html\" data-type=\"URL\" data-id=\"https:\/\/templates.blakadder.com\/nedis_WIFIPO120FWT.html\" target=\"_blank\">Tasmota<\/a>. <strong>Note:<\/strong> latest Nedis plugs might contain other than ESP8266 and cannot be flashed to use Tasmota)<\/li>\n\n\n\n<li>Home Assistant supported Outdoor temperature sensor (<strong>OPTIONAL<\/strong>)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Installation<\/h2>\n\n\n\n<p>Automation is created as a package, because it includes input components, helpers and automations. Download the car_heater.yaml package from <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/kotope\/ha_car_heater\" target=\"_blank\">https:\/\/github.com\/kotope\/ha_car_heater\/blob\/main\/car_heater.yaml<\/a> and copy to Home Assistant configuration directory. The package can be set up by adding it to configuration.yaml like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>homeassistant:\n  packages:\n    car_heater: !include car_heater.yaml<\/code><\/pre>\n\n\n\n<p>After including the package in the configuration file, we should setup proper entities in the package file. Entities that needs to be added are: (All changed entities are marked as <strong>#CHANGE-ME<\/strong> in the <em>car_heater.yaml<\/em> file).<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Car heater power switch<\/strong><\/h4>\n\n\n\n<p><em>entity_id: switch.car_heater<\/em><\/p>\n\n\n\n<p>This switch is the main switch entity that connects the car heater to the power socket.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Car heater power consumption<\/strong><\/h4>\n\n\n\n<p><em>entity_id: sensor.car_heater_power<\/em><\/p>\n\n\n\n<p>This is the power consumption sensor used to verify, that the power cable is physically connected.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Temperature sensor<\/strong><\/h4>\n\n\n\n<p><em>entity_id: weather.home.attributes.temperature<\/em><\/p>\n\n\n\n<p>Outside temperature sensor that is used to calculate proper heating times. This can be used from local weather service integration or some separate temperature sensor.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Notification entity<\/strong><\/h4>\n\n\n\n<p>service: notify.mobile_app_samsung_s10<\/p>\n\n\n\n<p>Service id to send notification, if the power cable is unplugged.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>&#8230;and restarting<\/strong><\/h4>\n\n\n\n<p>Finally after changing entities and devices it&#8217;s time to verify the config and restart the Home Assistant configuration interface.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example UI<\/h2>\n\n\n\n<p>For the UI, I&#8217;m trying make it as simple as possible. In stock Home Assistant there&#8217;s not a very usable time picker car so with this UI I&#8217;m using a custom card called <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/GeorgeSG\/lovelace-time-picker-card\" data-type=\"URL\" data-id=\"https:\/\/github.com\/GeorgeSG\/lovelace-time-picker-card\" target=\"_blank\">time-picker-card<\/a> (also installable using HACS).<\/p>\n\n\n\n<p>Example UI has time picker for scheduled departure, enable only weekdays switch, enabling\/disabling the scheduler, manually controllable car heating plug, run time length and start time. Also some status information along with current outside temperature.<\/p>\n\n\n\n<p>Example UI can be also downloaded directly from GitHub: <a href=\"https:\/\/github.com\/kotope\/ha_car_heater\/blob\/main\/sample_lovelace_ui.yaml\">https:\/\/github.com\/kotope\/ha_car_heater\/blob\/main\/sample_lovelace_ui.yaml<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"406\" height=\"478\" src=\"https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2021\/10\/Screenshot-2021-10-23-at-9.24.57.png\" alt=\"\" class=\"wp-image-789\"\/><\/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-97da4800-b620-4432-a397-172611778771\">\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>Winter is coming once again and pre-heating car is needed when the temperature drops below five degrees. This automation is something that I wrote to&hellip;<\/p>\n","protected":false},"author":1,"featured_media":791,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[100],"tags":[105,142,145,7,143,144,140],"class_list":["post-769","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-home-assistant","tag-automation","tag-car-heater","tag-departure","tag-home-assistant","tag-lovelace-ui","tag-time-picker","tag-winter","has-post-thumbnail-archive"],"acf":[],"featured_image_src":"https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2021\/10\/20211023_093920.jpg","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\/769","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=769"}],"version-history":[{"count":28,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/posts\/769\/revisions"}],"predecessor-version":[{"id":2511,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/posts\/769\/revisions\/2511"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/media\/791"}],"wp:attachment":[{"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/media?parent=769"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/categories?post=769"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/tags?post=769"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}