Samsung AC Binding

Hi Guys!

I’m struggling with connecting Samsung AC OpenHAB2. I installed the AC Binding from Binding section of paper UI but there are no item inside Inbox>Choose Item section.

Is it not fully developed?

Hi every one

We need a complete step by step guide to get this binding working.
I will past all useful information(openhab1) from:

I notice there is a bug on this binding and they are trying to solve it ( https://github.com/openhab/openhab/issues/2863#issuecomment-192738255 )

According to ( https://github.com/openhab/openhab/wiki/Samsung-AC-binding ) we need to fill 4 things in the configurations file so we will be able to communicate with the AC:

  • the IP address
  • the MAC
  • token
  • certificate

ip and mac address:
I am facing a problem on this command to get the ip and the mac

java -cp addons/org.openhab.binding.samsungac_1.9.0.SNAPSHOT.jar org.binding.openhab.samsungac.communicator.SsdpDiscovery

this what they say in the guide (If you do not know your Samsung Air Conditioners IP- or Mac-address you can download the jar, and run the following command. Then the details of
the FIRST discovered air conditioner will be printed:) they did not mention what to do to run it correctly

So I have tried 3 things to run this command with no use

  • change the version of snapshot in the command text from 1.6.0 to 1.9.0
  • I change the directory to openhab folder where the .jar file located ( cd …/openhab2) and run the command there
  • I run it under debug mode
    (Error: Could not find or load main class org.binding.openhab.samsungac.communicator.SsdpDiscovery)

I guss is it java problem, openhab2 run under JDK8 and SsdpDiscovery class is found in old version of java I do not know how to solve this problem. So please help

certificate:
I notice while I am reading that to get the token we have to have extract certificate file from Samsung smart air condition mobile app first to avoid the ssl handshake error

I will past the guide here

These are the complete steps I took yesterday, in case anyone wants to reproduce them it should be fairly easy:

I used Apktool (https://ibotpeaches.github.io/Apktool/) to disassemble the Smart Air apk (java -jar apktool_2.0.3.jar d com.samsung.rac-1.2.78.apk). I suppose any other disassembling tool for Android would work.
From the extracted directory I took the file assets/AC14K_M_KeyStore.bks, which is the keystore in BouncyCastle format containing the certificate and the private key. I also searched for references to that file in the disassembled code in order to find the password to access the private key, and fortunately this was quite easy: it's only referenced in smali/com/samsung/rac/framework/service/SSLSocketFactoryHelper.smali, and the string containing the password is totally evident ;)
I then installed a BouncyCastle provider (https://www.bouncycastle.org/latest_releases.html) . Take into account that it has to be installed in lib/ext in your Java runtime installation, as keytool doesn't take into account the CLASSPATH env
I converted the bks keystore to a pkcs12 keystore with this command:

keytool -importkeystore -srckeystore AC14K_M_KeyStore.bks -srcstoretype BKS -provider org.bouncycastle.jce.provider.BouncyCastleProvider -srcstorepass ‘<the_password_in_the_code>’ -destkeystore ac14k_m.p12 -deststoretype PKCS12 -deststorepass 123456 -destkeypass 123456 -alias ac14k_m

I finally created a .pem certificate+key from the .p12 certificate with the usual openssl command:

openssl pkcs12 -in ac14k_m.p12 -passin pass:123456 -out ac14k_m.pem -passout pass: -nodes

I hope it helps… I didn’t want to put the password or the pem certificate here as I’m not sure about the legal implications. But it should be easy for anyone to obtain it :wink:

And also this guide to create the certificate file

Getting your Samsung Smart Air Conditioner to work with OpenHAB

Samsung Smart Airconditioners from July 2015 on have a different way of working. You will need to adjust the certificates. Here is how to.

Step 1. Extract the ac’s certificate and let your computer trust it
The first thing to do is to extract the root certificate from your ac. Root certificates are usualy signed by Certification Authorities like VeriSign. The certificated is however not signed by a Certification Authority, but by Samsung itself. This self sifgned certicificate needs to be added to the Java truststore to be trusted by OpenHAB.

Extract the certificate like this, mind entering the correct ip address for your ac unit in the command:

echo -n | openssl s_client -connect 192.168.1.136:2878 | sed -ne ‘/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p’ > samsungcert.crt

Don’t mind the error message, it is part of the deal. Now we need to find the location of your Java cacerts:

sudo find / | grep cacerts

The output will tell you the correct path. Now add the key to your trusted certificates with the keytool utility:

sudo keytool -import -trustcacerts -keystore /usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/lib/security/cacerts -storepass changeit -noprompt -alias mycert -file samsungcert.crt

Step 2. Download or extract the keyfile from the app to supply to the OpenHAB binding
There is a long version of this and a short one. The short one is downloading it here http://pastebin.com/MKTbFnK5 Prepare the file like this:

base64 -d < pasted.txt > cert.pem

The long one is extracting it from the app, To follow.

Step 3. Using the keyfile in OpenHAB
Here is an example openhab.cfg configuration for the Samsung ac binding:

samsungac:Woon.host=192.168.1.145
samsungac:Woon.mac=BC8CAA7226CF
samsungac:Woon.token=6acb7452-bb3f-429c-912c-72bfbb5bf052
samsungac:Woon.certificate=/home/domorino/ac/cert.pem

Step 4. Download adjusted binding
Get the beta-test binding, it was not yet in 18.2 from http://bit.ly/20Dabae

token:

When you have entered the host(IP) and mac details in the configuration, you will still need to retrieve a token from the air conditioner. During first connection attempt, you do not have a token, so pay attention to the log. It will ask you to switch on and off the air conditioner within 30 seconds. You will then receive a token printed in the log. Keep it and put it in openhab.cfg.

Procedure:

Turn AC on. Comment the line containing token like:
# samsungac:Livingroom.token=
Start openHAB in debug mode with:
./start_debug.sh
Watch the logs from a (different) console and look at AirConditioner messages:
tail -f openHAB.log | grep AirConditioner
You will find the messsage:
WARN  o.b.o.s.c.AirConditioner[:179]- NO TOKEN SET! Please switch off and on the air conditioner within 30 seconds  
Switch AC off and then on (be quick, you really have 20 seconds), you will then find your token in the logfile:
WARN  o.b.o.s.c.AirConditioner[:175]- Received TOKEN from AC: 'e56a6def-1ecf-47d4-bc5d-9c818eaec76d'  
Copy the token to openhab.cfg and uncomment the line

Please can any one help I really want this binding to work

Regards

Hi, so far i was not able to get this working.
If i understand it correctly, i need the certificates first.
So i tried: echo -n | openssl s_client -connect 192.168.x.x:2878 | sed -ne ‘/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p’ > samsungcert.crt
connect: Connection refused
connect:errno=111

I found somewhere the ports maybe have changed?
I have two units, AR07KSWNAWKNEU, AR09KSWNAWKNET, about year old.
I tried the certificates on the link, but they seems to be for different model.
It seems like without correct certificate, i cannot get the token.
Also, these units work only with Samsung Smart Home app, not with the older AC only app.