Samsung AC

I would like to see Samsung AC integrated into HA, I can see some work was done on it but looks like it has been disabled. Can we please get this implemented or a way to manually enable the feature if it already exists ?

I reviewed github.com code that disabled Samsung AC and undid all the changes. The result was that half of my previously discovered devices stopped being discovered and neither did it successfully find my Samsung AirCon.

I think the net result from my test suggests that the previous Samsung AC changes never worked anyway. So I changed code back to disable the Samsung AirCon. I’m using Hassbian on a raspberry pi 3.

I do wish it’d work too. If you’d like to try also look here https://github.com/home-assistant/netdisco/pull/67/files and restore all the code changes in RED and give it a go.

I gave up trying to get this working. I’ve worked around it by buying a Broadlink RM mini 3 (very cheap ir blaster) and placed it near the AC.

I can now send the relevant IR signals via HASS to turn on and off the AC.

I’ve never gone past the first discovery, there is a key that can be extracted from android app, but I’ve never been able to estabilish a connection.
I’m still interested in getting it to work without relaying on an IR blaster, maybe I’ll give it a second try

Keep us posted if you succeed. Thanks

Sure, first stop is SSL
the units use SSLv3 cyphers which are right now deprecated in openssl, so if I try to interrogate it using curl I get back

3069289680:error:14082174:SSL routines:SSL3_CHECK_CERT_AND_ALGORITHM:dh key too small:s3_clnt.c:3435:

Ok most of my informations come from here:


I don’t know the status of the home-assistant component, so I start from the basic.

The first problem is that the AC uses a weak DH key, so in order to communicate we need to use the correct cipher, after some trial I’ve been able to ko past the dh key too small error with those:
-cipher 'HIGH:!DH:!aNULL'

so for curl:
curl -k --cert cert.pem https://192.168.1.166:2878 --ciphers 'HIGH:!DH:!aNULL'
and openssl:
openssl s_client -connect 192.168.1.166:2878 -cert cert.pem -cipher 'HIGH:!DH:!aNULL'

after I got an xml response now I have to understand how to request the token to authenticate

another little progress, by using the ruby code I found here:
https://bitbucket.org/CloCkWeRX/samsung-remote
made by some people hacking on samsung ACs

I’ve been able to see token exchange, still got a lot of errors, but at least I’ve been able to communicate with the AC
The only modification needed is to add this line of code:
context.ciphers = 'HIGH:!DH:!aNULL'
in lib/samsung.rb, after:
context = OpenSSL::SSL::SSLContext.new

to force ruby to not expose DH key exchange methods, which are deprecated in modern SSL libraries

now the next task is to port all of this to python, and see how to integrate with home-assistant, I have to see if there is still some code that is already in place

EDIT
Today I retried using openssl s_client command, and instead of immediately close the session this time I can send commands, so using:

openssl s_client -connect 192.168.1.202:2878 -cipher 'HIGH:!DH:!aNULL'
(differently from what stated in the openhab link the app certificate is not needed)
and pasting

after
DRC-1.00
<?xml version="1.0" encoding="utf-8" ?><Update Type="InvalidateAccount"/>

I get the token back

`<?xml version="1.0" encoding="utf-8" ?><Response Type="GetToken" Status="Ready"/>`
`<?xml version="1.0" encoding="utf-8" ?><Update Type="GetToken" Status="Completed" Token="33965903-XXXX-XXXX-XXXX-373832354144"/>`

and sending the request with token:
<Request Type="AuthToken"><User Token="33965903-XXXX-XXXX-XXXX-373832354144" /></Request>
I can authenticate
<?xml version="1.0" encoding="utf-8" ?><Response Type="AuthToken" Status="Okay" StartFrom="2017-05-15/15:10:39"/>

and check for status or turn on the AC
<Request Type="DeviceState" DUID="XXXXXXXXXXXX"></Request>

Here there is a node version of the connection code:


The best thing is that there are defined command names.
So here is my checklist:
  • Port the basic auth and send command code to python (this should be fairly easy to do)

  • Implement this as a hass component (this is a little bit harder)

  • Code the autodiscovery part (this is supported from the unit, but for me it’s already difficult code the component part)

2 Likes

Any updates on this ?

Hi, How’s it going.

I’m the guy that originally broke the reliance on samsung servers back in 2014 with Daniel O’Connor, and I’ve been pretty quiet on that front ever since (I’ve simply been content to ssh into my server and run the 3 commands I need against my AC)

But now I’m back, I’ve discovered Hass (and am using it, in fact about half way though the house rewire), and MQTT.

I’m not the greatest fan of Python any more, but I’m thinking about making a MQTT bridge to cover the basic functions like on, off, mode, temperature select.

Depending on how I go, I might make a direct connector for HASS (would probably still require an external daemon)

Would anyone be interested in such a diversion?

I should add, that initially I will only be coding up support for my units, but that in theory should give us quite a bit of compatibility, as far as I know the protocol hasn’t changed much tho the handshake might have.

3 Likes

Hi Freman. I have a Samsung F-AR24FSSSBWK1 wi-fi AC (uses https://www.samsungsmartappliance.com).

I am interested to try your solution!

id be very keen @Freman

Hi,
I have my key, how can I control the air conditioner?

Thanks

Until not officially integrated Samsung Air Conditioner (new protocol, port 8888). Here is my solution for that:

  1. Get your AC’s token. Follow this instructions: https://community.openhab.org/t/newgen-samsung-ac-protocol/33805/6

  2. Create a file control_samsungac.sh in HA config directory, and paste the following content:
    http://mieletunkhosting.com/control_samsungac.txt

  3. Replace the followings:
    a: 192.168.1.XX to your AC ip address
    b: rXXXXXXXXc to your token key
    c: /var/packages/homeassistant/target/var/cert.pem to your exactly path of the cert file

  4. Add this to configuration.yaml:
    configuration.yaml (1.5 KB)
    Change this /var/packages/homeassistant/target/var/control_samsungac.sh to your real path of your control_samsungac.sh

  5. Add this into automations.yaml:

automations.yaml (1.4 KB)

  1. And finally Group it via groups.yaml:

groups.yaml (239 Bytes)

And finally you get the following:

samsung_ac

Enjoy! If you have question, let me know!

3 Likes

HI,

Where should take those files: server.py, actest.py from ?

This is require only one time, so you can take anywhere. After you got the token key, you can delete them.

I meant where from should i take them :slight_smile: What script should them contain ?

As this is in the Openhab link:
actest.py:
http://mieletunkhosting.com/actest.py

Replace the AC IP and the cert file real path.

server.py:
http://mieletunkhosting.com/server.py

Replace the cert file real path.

If you need the cert file too, then: http://mieletunkhosting.com/cert.pem

:wink:

Do i also need the “test.py” ?

I see, so the test.py is the equal with the server.py :slight_smile:

  1. step: turn off your Samsung AC
  2. step: first terminal: python3 server.py
  3. step: second terminal: python3 actest.py
  4. step: power on the Samsung AC

first terminal output look like:

root@DS214Plus:/volume1/homes/admin# python3 server.py
Listening on localhost:8889

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

Request path: /devicetoken/response
Content Length: 0
Request headers: Host: 192.168.1.XXX:8889
Accept: /

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

Request payload: b’{“DeviceToken”:“rXXXXXXXXc”}’
Body: <main.RequestHandler object at 0x2b360c30>
<----- Request End -----

192.168.1.XX - - [08/Jan/2019 14:44:23] “POST /devicetoken/response HTTP/1.1” 200 -