Samsung AC

@SebuZet I get error while setting up platform samsungrac.
Here is the log

Error while setting up platform samsungrac
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 159, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 80, in create_connection
raise err
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 70, in create_connection
sock.connect(sa)
TimeoutError: [Errno 110] Operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn
conn.connect()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 301, in connect
conn = self._new_conn()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 168, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x72d1fdd0>: Failed to establish a new connection: [Errno 110] Operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='192.178.1.209', port=8888): Max retries exceeded with url: /devices (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x72d1fdd0>: Failed to establish a new connection: [Errno 110] Operation timed out'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
return fut.result()
  File "/config/custom_components/samsungrac/climate.py", line 335, in async_setup_platform
rac.initialize()
  File "/config/custom_components/samsungrac/climate.py", line 438, in initialize
j = self.get_device_json()
  File "/config/custom_components/samsungrac/climate.py", line 418, in get_device_json
resp = session.request('GET', url=self.host + url, headers=self.extra_headers, verify=False, cert=self.cert, data=json.dumps({ 'sebu' : 'zet' }))
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='192.178.1.209', port=8888): Max retries exceeded with url: /devices (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x72d1fdd0>: Failed to establish a new connection: [Errno 110] Operation timed out'))

At settings you have to include https too like this:

host: https://192.178.1.200:8888

Thank you. It works now.

From now on schema ‘https://’ is automatically added if user passed only ip/host

I’m fairly new to ha but have one of these aircon I want to integrate. How do I get access token. I’ve tried to follow the link you provide but don’t understand python very well. Any help would be great.

@joelFORCE
So to get the “access token” follow these steps:
1- Download files from here: FILES and put them in a easy accessible folder from terminal.
2- Open the file “actest.py” with a editor and change the SAMSUNG.IP to your AC ip adress and save the file.
3- Power off your AC Device. IMPORTANT STEP!
4- Open a terminal and navigate to the folder where you have the (previously downloaded) files.
5- Execute: python3 server.py keep this terminal open.
6- Open another terminal and navigate to the same folder as in step 4.
7- Execute: python3 actest.py in this second terminal.
8- Go to your first terminal and check the output there you should have something like: “DeviceToken”:“XXXXXXXXXX” where the “XXXXXXX” is your token.
9- Save your token somewhere save, like a text file (for later). Now you can close both terminals.

Hope this helps.

1 Like

Cheers for ya help but just found out it uses port 2878.
It uses the mim-h02 controller. Don’t think this method works for it.

1 Like

@Jman I need few days to finish what I have started. After that I can try to do something with your AC but I cannot promise anything

Thankyou @SebuZet, that’s very kind. I am pretty sure now my AC does not have REST.

Im using AIM-H03N(similar with mim-h03 / mim-h03n)
I cant find out the way

server.py , actest.py show me nothing :frowning:

curl -XPOST -H “Content-Type: text/xml” -d “<?xml version=\"1.0\" encoding=\"utf-8\" ?><Request Type=“GetToken” />” --cert /home/pi/actest/cert.pem “https://192.168.1.148:8888/capability” --insecure
{“errorCode”:“1008”,“errorDescription”:“Token is not Valid”}

Received packet from (‘192.168.1.148’, 36044):
b’HTTP/1.1 200 OK
CACHE-CONTROL: max-age = 600
DATE: Sun, 03 Mar 2019 04:18:44 GMT
EXT:
LOCATION: https://192.168.1.148:8888/capability
SERVER: Linux SHP/1.0 Air_Conditioner/1.0 deviceSubType/System_Air_Conditioner modelID/AIM-H03N
ST: uuid:abcdefgh-ijkl-0000-0000-000000000000
USN: uuid:abcdefgh-ijkl-0000-0000-000000000000

Received packet from (‘192.168.1.148’, 49630):
b’HTTP/1.1 200 OK
CACHE-CONTROL: max-age = 600
DATE: Sun, 03 Mar 2019 04:18:44 GMT
EXT:
LOCATION: https://192.168.1.148:8888/capability
SERVER: Linux SHP/1.0 Air_Conditioner/1.0 deviceSubType/System_Air_Conditioner modelID/AIM-H03N
ST: urn:SmartHomeAlliance-org:device:Air_Conditioner:1
USN: uuid:abcdefgh-ijkl-0000-0000-000000000000::urn:SmartHomeAlliance-org:device:Air_Conditioner:1

openssl s_client -connect 192.168.1.148:8888

depth=3 C = KR, O = Samsung Electronics, CN = ROOTCA
verify error:num=19:self signed certificate in certificate chain
write:errno=0

Certificate chain
** 0 s:/C=KR/O=Samsung Electronics/CN=DA_SET/[email protected]**
** i:/C=KR/O=Samsung Electronics/CN=DeviceCA/[email protected]**
** 1 s:/C=KR/O=Samsung Electronics/CN=DeviceCA/[email protected]**
** i:/C=KR/O=Samsung Electronics/CN=CECA**
** 2 s:/C=KR/O=Samsung Electronics/CN=RemoteAccessCA(CE)**
** i:/C=KR/O=Samsung Electronics/CN=CECA**
** 3 s:/C=KR/O=Samsung Electronics/CN=CECA**
** i:/C=KR/O=Samsung Electronics/CN=ROOTCA**
** 4 s:/C=KR/O=Samsung Electronics/CN=ROOTCA**
** i:/C=KR/O=Samsung Electronics/CN=ROOTCA**

Server certificate
-----BEGIN CERTIFICATE-----
MIIDNzCCAh+gAwIBAgIBATANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJLUjEc
MBoGA1UECgwTU2Ftc3VuZyBFbGVjdHJvbmljczERMA8GA1UEAwwIRGV2aWNlQ0Ex
IzAhBgkqhkiG9w0BCQEWFERldmljZUNBQHNhbXN1bmcuY29tMCIYDzE5NjAwMTAx
MDAwMDAwWhgPMjA2MDAxMDEwMDAwMDBaMF4xCzAJBgNVBAYTAktSMRwwGgYDVQQK
DBNTYW1zdW5nIEVsZWN0cm9uaWNzMQ8wDQYDVQQDDAZEQV9TRVQxIDAeBgkqhkiG
9w0BCQEWEVN5c0FDQHNhbXN1bmcuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB
iQKBgQC+UUAhTdCWZSSxsMNECvu7h4BOx+c2WFMSJJ4Zh31pitfVBhubn8kDlAXs
Mt3xy06y4QQruuqC906bQHw36VJrFemzuNuvQEDrJ+IAMn68gLlaSx1bY/bIXZP5
hJyZFoTb6JICTln0fFb70daJSm3i4j0rj59Ye5ulv1xK2JlRVQIDAQABo3sweTAJ
BgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0
aWZpY2F0ZTAdBgNVHQ4EFgQUS29nAk4bJEHVm67YJJkDDjrlBAswHwYDVR0jBBgw
FoAUzdaNnyY92WoDVtTwod3SBJ4DoywwDQYJKoZIhvcNAQELBQADggEBAD8j5cUI
l/O/qOpIelhmFgqKOnqo8A9GdUprODbVZWi1zL6XI1Mo40+iIXF3PGy7mCDpA4GY
0ibEZweuurR5Zjk07GQ8GNBjk5QAtEQ0dBruf034hzrjPuh35XWRBhknbkMbhUac
CnLkEQwSGG5UZKjLQtVmzbHd9dvgulOeRJ/m7fnOg8aRnNPDR231cShI5mleyoUQ
B7s8KGqqiFNxZOjJkCyV3oym5l+z1L2KeLreV07KJgtpSMt7ELI75mxqdGpU+6yz
a3uJUid0+EKUE1DHgg+3UGno5D8Gp4UDx+UOO1u1gysBLHCKAhzYduLcsqF52NGT
B9O4HvS0AtYDSos=
-----END CERTIFICATE-----
subject=/C=KR/O=Samsung Electronics/CN=DA_SET/[email protected]
issuer=/C=KR/O=Samsung Electronics/CN=DeviceCA/[email protected]

No client certificate CA names sent
Client Certificate Types: RSA sign, DSA sign, ECDSA sign

SSL handshake has read 4383 bytes and written 386 bytes
Verification error: self signed certificate in certificate chain

New, SSLv3, Cipher is AES256-SHA
Server public key is 1024 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
** Protocol : TLSv1**
** Cipher : AES256-SHA**
** Session-ID:**
** Session-ID-ctx:**
** Master-Key: abc**
** PSK identity: None**
** PSK identity hint: None**
** SRP username: None**
** Start Time: 1551589926**
** Timeout : 7200 (sec)**
** Verify return code: 19 (self signed certificate in certificate chain)**
** Extended master secret: no**

New version for HA v0.89+ is available.

Anyone know how to get token for mim-h02 controller port 2878? Need instructions as I’m not very good with code.

Sorry for going quiet for so long, my lounge room aircon blew up and the bedroom one has decided to stop getting on the network.

But today I present progress:

I have no idea how I’ll modularise this and or support other devices but it’s almost something I can github

edit: ran into a new roadblock

@Jman Can you try this python script if it is working or not? I don’t have such unit and cannot test by myself. Please modify parameters at the beginning to meet your device/settings.

OK. I will give it a go now

i get an error

wrap socket 1 test…
Traceback (most recent call last):
File “testac.py”, line 45, in
if sslSocket is None:
NameError: name ‘sslSocket’ is not defined

@Jman Ok, thanks for trying. I’ve put updated version. If you have a minute please try this one. If we get it working I will be able to make component working with old units.

Thanks @Jman, Can you show me an example how can you turn device on/off, set temperature using openssl? I can connect to device but have to figure out what messages should be send.

Got this error…

Traceback (most recent call last):
File “testac2.py”, line 18, in
ssl.PROTOCOL_SSLv3,
AttributeError: ‘module’ object has no attribute ‘PROTOCOL_SSLv3’

To control device…

<Request Type="AuthToken"><User Token="fdd4444a-fda5-4312-8837-1c34ed42f444" /></Request>
<Request Type="DeviceControl"><Control CommandID="12345" DUID="1449e055ea64"><Attr ID="AC_FUN_POWER" Value="On" /></Control></Request>

To get a list of Attributes…

<<Request Type="DeviceState" DUID="1449e055ea64"></Request>>

@Jman Thanks.
Can you please download and check this script and share output

EDIT: of course you have to change variables HOST, certfile, token, duid to meet your configuration