Guide: Samsung A/C to Home Assistant

For few days I’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 ‘proper’ way to do it. So here are the instructions how I did it.

This guide is targeted for Samsung AC devices that uses port 8888. So if your AC device uses e.g. 2878 this guide might not work for you.

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.

Most of the details info was found from Home Assistant climate_ip community project thread

Finding the corresponding port and ip

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.

Next thing to do is to find the port of your machine. In linux or windows environment you could try e.g. ‘telnet 192.168.1.xxx 8888’ (make sure you enter correct ip). If you get a reply like “Escape character is ‘^]’.” you’ve found the correct port that in this case is 8888.

Getting the token

The most difficult part was to fetch out the access token from the AC machine. So here’s step-by-step guide how I eventually managed to get it:

1. SSH & Web Terminal

SSH & Web Terminal add-on

Install ‘SSH & Web Terminal‘ from Supervisor -> Home Assistant Add-on Store. Note that this ‘SSH & Web Terminal’ is NOT the standard SSH server, but enhanced version of it that grants you access to the HA core system.

Configure SSH & Web Terminal add-on to run e.g. in port 2222 and setup your username & password through it. After fully configured it, start the add-on. I personally disable this add-on every time I don’t need it for security reasons. I don’t want run extra services if they are not required in daily basis.

Now SSH into your new SSH server (port 2222) that you’ve just installed.

2. Get the token fetch software

Download the token software from this google drive folder. 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.

Copy these three files to your Home Assistant machines you just SSH’d into. You can use something like scp (secure copy) or any other file transfer protocols of your choice.

3. Configure the token fetch software

Next is to setup your AC IP address into the fetch software. So edit actest.py and insert your IP instead of SAMSUNG.IP field in line number 4.

4. Turn off your AC

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’t power it off permanently, just switch off from the remote).

5. Start the software

First we need to start server software that will receive the token when AC is being started. Run ‘python3 server.py‘ in your SSH client.

Next thing to do is “tell” 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 ‘python3 actest.py‘.

6. Get the token

Now after all this is done, only one step is remaining.

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:

----- Request Start ----->

Request path: /devicetoken/response
Content Length: 0
Request headers: Host: 192.168.1.100:8889
Accept: */*

X-API-Version : v1.0.0
Content-Type: application/json
Content-Length: 28


Request payload: b'{"DeviceToken":"abCD12ABv5"}'
Body: <__main__.RequestHandler object at 0x7f4e034ec490>
<----- Request End -----

And as you can notice, the Request payload in the log contains your token. Copy the token somewhere for later use.

You can now stop the server by pressing ctrl+c in terminal window and exit SSH clients. Also you can now shutdown your ‘SSH & Web Terminal’ add-on. And if you wish, you can also delete it, if you don’t need it in any other purposes.

Installing custom component

The Home Assistant component you need is called climate_ip. You can either download it directly to custom_components folder in Home Assistant or use HACS.

I’d recommend using HACS so you can get latest updates automatically without polling the repositories yourself. If using HACS try to find ‘samsungrac’ component from HACS interface and install it.

Configuration

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.

Edit configuration.yaml file and add following information below climate -section:

climate:
  - platform: climate_ip
    config_file: 'samsungrac.yaml'
    ip_address: 'YOUR_SAMSUNG_IP'
    token: 'TOKEN'
    cert: 'ac14k_m.pem'
    name: "Samsung Heat Pump"

Make sure to set your ip_address, token and name. Others you most probably don’t need to change if having AC with port 8888.

Last thing is to restart your Home Assistant and add thermostat card in Lovelace UI.

Conclusion

Hopefully this guide will help other people a bit so they don’t have to use as many hours to fight to get the token. I’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.

9 Replies to “Guide: Samsung A/C to Home Assistant”

    1. Hi!

      That’s ‘only’ a warning that can be ignored, does not affect the outcome. 🙂

      For more specific:
      Warning tells you that the requests made are not secure enough.
      In normal case you should not continue forward, but since we’re only using insecure certificates in our local network and not through internet it can be ignored.

    1. Unfortunately I have no idea.

      It might work if it responds to port 8888. Does it?

      1. no 🙁 telnet doesn’t work on port 8888 nor 2878
        nmap found only 29584/tcp opened

        1. That’s too bad 🙁

          This guide then definately won’t work with your AC.
          Sorry I can’t help you more, you could try to search from Home Assistant forums for example.

          Hope you will find a solution eventually!

          1. thanks, I think use of SmartThings API is solution but HASS can’t get all data
            nvm thanks for your quick reaction 🙂

  1. Thank you for your how to, it worked like charm.

    This is my aditional steps:

    Client part supress warning:
    export PYTHONWARNINGS=”ignore:Unverified HTTPS request”

    In CentOS 8 by default use TLS1.2, so openssl can use TLS1.0 after command.

    export OPENSSL_CONF=~openssl_allow_tls1.0.cnf

    1. Hi,

      It’s good to hear this blog post did help someone 🙂
      …and thanks for your input for ignoring unnecessary warnings!

Leave a Reply

Your email address will not be published. Required fields are marked *