Samsung AC

This log is ok, I have to removed it. Error code 204 means ‘No data in response’ but request was processed successful. What is not working?
I’ve to fix status updating but generally it works in my HA. In my case, first I need to turn on AC unit and next I can switch configuration. If i change order then unit is not reporting correct status. It looks like bug/feature in AC unit :slight_smile:

Thanks for this, it’s great to finally get my AC working through HA. It works well enough! It sometimes seems to get in to the wrong state (reporting as on when it is off), but better than nothing!

@Jayphen I know there are some issues with current state. In my unit, if I change state (eg. mode) when unit is turned off, then device is sending old status. I’m working on it and I hope I will resolve this problem.
I will let you know when it will be fixed.

1 Like

@miklosandras @wachux @Jayphen
New version is available on GitHub. Problems with status should be resolved

2 Likes

Yes, this version is working fine with the status updates :slight_smile: Thank you!

@miklosandras Did you try to control Purify and GoodSleep modes?

Yeeees, both are working fine, just tried with automation :slight_smile: I like this component :wink:

@SebuZet I’m not sure if my AC does REST. I can get some control using openssl and xml. Does the below reveal anything?

after I have run…

openssl s_client -connect 192.168.1.38:2878 -cert cert.pem -cipher ‘HIGH:!DH:!aNULL’

AC responds

DPLUG-1.6
<?xml version="1.0" encoding="utf-8" ?><Update Type="InvalidateAccount"/>

I respond with

> <Request Type="AuthToken"><User Token="fdd3429a-fda5-4312-8837-1c34ed42f3d1" /></Request>

AC Responds

<?xml version="1.0" encoding="utf-8" ?><Response Type="AuthToken" Status="Okay" StartFrom="2019-02-28/22:44:12"/>

I respond with

<Request Type="DeviceState" DUID="144125b5ed61" /></Request>

AC Responds

> <?xml version="1.0" encoding="utf-8" ?>
   <Response Type="DeviceState" Status="Okay">
> <DeviceState>
> <Device DUID="144125b5ed61" GroupID="AC" ModelID="AC" >
> <Attr ID="AC_FUN_ENABLE" Type="RW" Value="Enable"/>
> <Attr ID="AC_FUN_POWER" Type="RW" Value="Off"/>
> <Attr ID="AC_FUN_OPMODE" Type="RW" Value="Cool"/>
> <Attr ID="AC_FUN_TEMPSET" Type="RW" Value="24"/ >
> <Attr ID="AC_FUN_COMODE" Type="RW" Value="Off"/>
> <Attr ID="AC_FUN_ERROR" Type="RW" Value="NULL"/>
> <Attr ID="AC_FUN_TEMPNOW" Type="R" Value="23"/>
> <Attr ID="AC_FUN_SLEEP" Ty pe="RW" Value="0"/>
> <Attr ID="AC_FUN_WINDLEVEL" Type="RW" Value="Auto"/>
> <Attr ID="AC_FUN_DIRECTION" Type="RW" Value="SwingLR"/>
> <Attr ID="AC_ADD_AUTOCLEAN" Type="RW" Value="Off "/>
> <Attr ID="AC_ADD_SETKWH" Type="RW" Value="255"/>
> <Attr ID="AC_ADD_CLEAR_FILTER_ALARM" Type="RW" Value="0"/>
> <Attr ID="AC_ADD_APMODE_END" Type="W" Value="0"/>
> <Attr ID="AC_ADD_STARTWPS" Type="RW" Value="Default"/>
> <Attr ID="AC_ADD_SPI" Type="RW" Value="Off"/>
> <Attr ID="AC_OUTDOOR_TEMP" Type="R" Value="78"/>
> <Attr ID="AC_COOL_CAPABILITY" Type="R" Value="70"/>
> <Attr ID="AC_WARM_CAPABILITY" Type="R" Value="80"/>
> <Attr ID="AC_SG_WIFI" Type="W" Value="Connected"/>
> <Attr ID="AC_SG_INTERNET" Type="W" Value="Connected"/>
> <Attr ID="AC_ADD2_USEDWATT" Type="R" Value="65024"/>
> <Attr ID="AC_ADD2_VERSION" Type="RW" Value="65024"/>
> <Attr ID="AC_SG_MACHIGH" Type="W" Value="85"/>
> <Attr ID="AC_SG_MACMID" Type="W" Value="234"/>
> <Attr ID="AC_SG_MACLOW" Type="W" Value="100"/>
> <Attr ID="AC_SG_VENDER01" Type="W" Value="20"/>
> <Attr ID="AC_SG_VENDER02" Type="W" Value="73"/>
> <Attr ID="AC_SG_VENDER03" Type="W" Value="224"/>
> <Attr ID="AC_ADD2_PANEL_VERSION" Type="R" Value="130814"/>
> <Attr ID="AC_ADD2_OUT_VERSION" Type="R" Value="1246985"/>
> <Attr ID="AC_FUN_MODEL" Type="R" Value="6"/>
> <Attr ID="AC_ADD2_OPTIONCODE" Type="R" Value="63162"/>
> <Attr ID="AC_ADD2_USEDPOWER" Type="R" Value="27521"/>
> <Attr ID="AC_ADD2_USEDTIME" Type="R" Value="23860"/>
> <Attr ID="AC_ADD2_CLEAR_POWERTIME" Type="RW" Value="254"/>
> <Attr ID="AC_ADD2_FILTERTIME" Type="RW" Value="180"/>
> <Attr ID="AC_ADD2_FILTER_USE_TIME" Type="R" Value="4980"/>
</Device></DeviceState></Response>

@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.