{"id":524,"date":"2021-06-09T11:35:56","date_gmt":"2021-06-09T11:35:56","guid":{"rendered":"https:\/\/www.creatingsmarthome.com\/?p=524"},"modified":"2021-07-05T13:08:42","modified_gmt":"2021-07-05T13:08:42","slug":"guide-samsung-a-c-to-home-assistant","status":"publish","type":"post","link":"https:\/\/www.creatingsmarthome.com\/index.php\/2021\/06\/09\/guide-samsung-a-c-to-home-assistant\/","title":{"rendered":"Guide: Samsung A\/C to Home Assistant"},"content":{"rendered":"\n<p>For few days I&#8217;ve been looking a way to integrate my summer home Samsung A\/C unit into Home Assistant. After numerous amounts of failures I finally found a &#8216;proper&#8217; way to do it. So here are the instructions how I did it.<\/p>\n\n\n\n<p>This guide is targeted for Samsung AC devices that uses port <strong>8888<\/strong>. So if your AC device uses e.g. 2878 this guide might not work for you. <\/p>\n\n\n\n<p>Also you should be running Home Assistant supervised for the Add-ons to be available. If not, you might have to use some another ways to access into HA core.<\/p>\n\n\n\n<p>Most of the details info was found from <a rel=\"noreferrer noopener\" href=\"https:\/\/community.home-assistant.io\/t\/climate-ip-climatedevice-for-ip-based-units-not-only-samsung-ac\/106510\" target=\"_blank\">Home Assistant climate_ip community project <\/a>thread<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Finding the corresponding port and ip<\/h2>\n\n\n\n<p>First of all the AC device need to have a static IP, so if your router is assigning an IP through DHCP make sure it leases a static IP for the AC device. More information how to set the static IP should be found from your router manual and internet. Make sure to save your AC device IP address to somewhere. You will need it later many times.<\/p>\n\n\n\n<p>Next thing to do is to find the port of your machine. In linux or windows environment you could try e.g. &#8216;telnet 192.168.1.xxx 8888&#8217; (make sure you enter correct ip). If you get a reply like &#8220;Escape character is &#8216;^]&#8217;.&#8221; you&#8217;ve found the correct port that in this case is 8888.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Getting the token<\/h2>\n\n\n\n<p>The most difficult part was to fetch out the access token from the AC machine. So here&#8217;s step-by-step guide how I eventually managed to get it:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. SSH &amp; Web Terminal<\/h3>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"143\" src=\"https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-09-at-13.52.03.png\" alt=\"\" class=\"wp-image-525\"\/><figcaption>SSH &amp; Web Terminal add-on<\/figcaption><\/figure>\n\n\n\n<p>Install &#8216;<em>SSH &amp; Web Terminal<\/em>&#8216; from Supervisor -&gt; Home Assistant Add-on Store. Note that this &#8216;SSH &amp; Web Terminal&#8217; is NOT the standard SSH server, but enhanced version of it that grants you access to the HA core system.<\/p>\n\n\n\n<p>Configure SSH &amp; Web Terminal add-on to run e.g. in port 2222 and setup your username &amp; password through it. After fully configured it, start the add-on. I personally disable this add-on every time I don&#8217;t need it for security reasons. I don&#8217;t want run extra services if they are not required in daily basis.<\/p>\n\n\n\n<p>Now SSH into your new SSH server (port 2222) that you&#8217;ve just installed.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Get the token fetch software<\/h3>\n\n\n\n<p>Download the token software from <a rel=\"noreferrer noopener\" href=\"https:\/\/drive.google.com\/drive\/folders\/12AFaXaJDrnoMr4MwnY6NUTWH3_afNdJr\" data-type=\"URL\" data-id=\"https:\/\/drive.google.com\/drive\/folders\/12AFaXaJDrnoMr4MwnY6NUTWH3_afNdJr\" target=\"_blank\">this google drive folder<\/a>. I went through the code before running it just to make sure it was safe and did not contain anything suspicious. So at least at the time of writing this post it is safe to use.<\/p>\n\n\n\n<p>Copy these three files to your Home Assistant machines you just SSH&#8217;d into. You can use something like scp (secure copy) or any other file transfer protocols of your choice.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Configure the token fetch software<\/h3>\n\n\n\n<p>Next is to setup your AC IP address into the fetch software. So edit <em>actest.py <\/em>and insert your IP instead of SAMSUNG.IP field in line number 4.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. Turn off your AC<\/h3>\n\n\n\n<p>This one is VERY important step. Turn off your AC before proceeding forward. This is because access token is sent to the server software AFTER starting the AC unit. (Don&#8217;t power it off permanently, just switch off from the remote).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. Start the software<\/h3>\n\n\n\n<p>First we need to start server software that will receive the token when AC is being started. Run &#8216;<em>python3 server.py<\/em>&#8216; in your SSH client.<\/p>\n\n\n\n<p>Next thing to do is &#8220;tell&#8221; Samsung AC to connect your server after on boot. Make another connection to your HA SSH port 2222 from another terminal window. Enter the directory you copied the files and run &#8216;<em>python3 actest.py<\/em>&#8216;. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">6. Get the token<\/h3>\n\n\n\n<p>Now after all this is done, only one step is remaining.<\/p>\n\n\n\n<p>Switch back to the first terminal that is running your server.py and start your AC unit. After few seconds you should see something like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>----- Request Start -----&gt;\n\nRequest path: \/devicetoken\/response\nContent Length: 0\nRequest headers: Host: 192.168.1.100:8889\nAccept: *\/*\n\nX-API-Version : v1.0.0\nContent-Type: application\/json\nContent-Length: 28\n\n\nRequest payload: b'{\"DeviceToken\":\"abCD12ABv5\"}'\nBody: &lt;__main__.RequestHandler object at 0x7f4e034ec490&gt;\n&lt;----- Request End -----\n<\/code><\/pre>\n\n\n\n<p>And as you can notice, the Request payload in the log contains your token. Copy the token somewhere for later use. <\/p>\n\n\n\n<p>You can now stop the server by pressing ctrl+c in terminal window and exit SSH clients. Also you can now shutdown your &#8216;SSH &amp; Web Terminal&#8217; add-on. And if you wish, you can also delete it, if you don&#8217;t need it in any other purposes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing custom component<\/h2>\n\n\n\n<p>The Home Assistant component you need is called <a href=\"https:\/\/github.com\/atxbyea\/samsungrac\" data-type=\"URL\" data-id=\"https:\/\/github.com\/atxbyea\/samsungrac\" target=\"_blank\" rel=\"noreferrer noopener\">climate_ip<\/a>. You can either download it directly to custom_components folder in Home Assistant or use <a rel=\"noreferrer noopener\" href=\"https:\/\/hacs.xyz\" data-type=\"URL\" data-id=\"https:\/\/hacs.xyz\" target=\"_blank\">HACS<\/a>.<\/p>\n\n\n\n<p>I&#8217;d recommend using HACS so you can get latest updates automatically without polling the repositories yourself. If using HACS try to find &#8216;samsungrac&#8217; component from HACS interface and install it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Configuration<\/h2>\n\n\n\n<p>At the moment of writing this post only way to configure the climate_ip component is the configuration.yaml file in Home Assistant configuration folder. Hopefully it will be migrated to config flow sooner or later.<\/p>\n\n\n\n<p>Edit configuration.yaml file and add following information below climate -section:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>climate:\n  - platform: climate_ip\n    config_file: 'samsungrac.yaml'\n    ip_address: 'YOUR_SAMSUNG_IP'\n    token: 'TOKEN'\n    cert: 'ac14k_m.pem'\n    name: \"Samsung Heat Pump\"\n<\/code><\/pre>\n\n\n\n<p>Make sure to set your ip_address, token and name. Others you most probably don&#8217;t need to change if having AC with port 8888.<\/p>\n\n\n\n<p>Last thing is to restart your Home Assistant and add thermostat card in Lovelace UI.<\/p>\n\n\n\n<figure class=\"wp-block-gallery columns-2 is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\"><ul class=\"blocks-gallery-grid\"><li class=\"blocks-gallery-item\"><figure><img loading=\"lazy\" decoding=\"async\" width=\"409\" height=\"577\" src=\"https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-09-at-14.16.54.png\" alt=\"\" data-id=\"527\" data-link=\"https:\/\/www.creatingsmarthome.com\/?attachment_id=527#main\" class=\"wp-image-527\"\/><figcaption class=\"blocks-gallery-item__caption\">Samsung Heat Pump details<\/figcaption><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><img loading=\"lazy\" decoding=\"async\" width=\"494\" height=\"320\" src=\"https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-09-at-14.16.49.png\" alt=\"\" data-id=\"528\" data-link=\"https:\/\/www.creatingsmarthome.com\/?attachment_id=528#main\" class=\"wp-image-528\"\/><figcaption class=\"blocks-gallery-item__caption\">Samsung Heat Pump Thermostat Lovelace Card<\/figcaption><\/figure><\/li><\/ul><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Hopefully this guide will help other people a bit so they don&#8217;t have to use as many hours to fight to get the token. I&#8217;ve tried numerous of different software and also tried to install few virtual machines to have older SSL that the Samsung AC is still using without any luck.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For few days I&#8217;ve been looking a way to integrate my summer home Samsung A\/C unit into Home Assistant. After numerous amounts of failures I&hellip;<\/p>\n","protected":false},"author":1,"featured_media":538,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3],"tags":[98,17,78,7,95,94,97,99],"class_list":["post-524","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-guide","tag-climate_ip","tag-guide","tag-heating","tag-home-assistant","tag-samsung","tag-samsung-ac","tag-smartthings","tag-thermostat","has-post-thumbnail-archive"],"acf":[],"featured_image_src":"https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2021\/06\/Screenshot-2021-06-09-at-14.22.06.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\/524","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=524"}],"version-history":[{"count":16,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/posts\/524\/revisions"}],"predecessor-version":[{"id":547,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/posts\/524\/revisions\/547"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/media\/538"}],"wp:attachment":[{"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/media?parent=524"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/categories?post=524"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/tags?post=524"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}