Samsung AC

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

OK, still failing. Getting closer though?

##########################################################

Checking ssl for: 2

##########################################################
wrap socket test (ctx: 2)…
TEST, connecting
TEST: exception:
Traceback (most recent call last):
File “testac3.py”, line 59, in
sslSocket.connect((HOST, eval(PORT)))
File “/usr/lib/python3.5/ssl.py”, line 1027, in connect
self._real_connect(addr, False)
File “/usr/lib/python3.5/ssl.py”, line 1018, in _real_connect
self.do_handshake()
File “/usr/lib/python3.5/ssl.py”, line 996, in do_handshake
self._sslobj.do_handshake()
File “/usr/lib/python3.5/ssl.py”, line 641, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:720)

@Jman I too have the older Samsung AC which appears to use port 2878, I’ve tried following the guides above to get the token, however I cannot seem to get a hold of the token, did you have to do anything different ? I see the actest.py acript uses port 8888 by default etc.

Also thanks to @SebuZet for putting effort into this, I really appreciate the work

Anyone with old unit (working on port 2878) can try dev version of my component.
Can someone confirm if it is working or not?
I cannot help you with token acquisition, you can try openhab to get the token :slight_smile:

Instructions:

  1. Create climate_ip folder in your /config/custom_components/ directory
  2. Download all files from GitHub into this directory
  3. Edit file /config/custom_components/climate_ip/samsung_2878.yaml to meet your configuration (host, token, mac or duid)
  4. Edit configuration.yaml file and add section like below:
    climate:
      platform: climate_ip
      config_file: '/config/custom_components/climate_ip/samsung_2878.yaml'
    
  5. Restart HA

2019-03-16 09:08:43 ERROR (MainThread) [custom_components.climate_ip.climate] Error creating socket
2019-03-16 09:08:45 ERROR (MainThread) [custom_components.climate_ip.climate] Error creating socket

It appears in HA, but all values are Unknown

@atxbyea Can you add entry
debug: True
To configuration.yaml
And restart HA

Like this ?

climate:
  platform: climate_ip
  config_file: '/home/homeassistant/.homeassistant/custom_components/climate_ip/samsung_2878.yaml'
  debug: true

Didn’t give me any more output in the home-assistant.log atleast, tried with both capital and lowercase t in true.

Added debug to the logger and grepped for climate, then I saw it didn’t resolve the path for the certificate correctly, if I hardcoded the path in all the files of the custom component it works perfectly :slight_smile:

@atxbyea Yes, looks good (debug: true should work). Try latest version from repo. There should be more debugs.
And make sure that path to cert file is correct. My exam ple will worku if you are using HA in docker.

Yeah, I am running in venv, I did change the path in the 2878.yaml file, but that didn’t appear to be enough, so I had to change the path in all the files where it was mentioned.

Component appears to be working perfectly so far here since that.

@atxbyea Good to hear that. Can you tell me which files have you modified? After all turn debugs off to remove additional attributes.

1 Like