Samsung AC Support, help needed

try execute it with python 2.7

edit: updated the script to work with python 3 too

@jackdalma 2.7 is working , same output as you got … tnx

@jackdalma Home Assistant is working on python 3.5 so we have to do the same.
It looks like every device is different.
I will prepare new script and we will check if it will be enough. I’ll try to do this on the late evening.
@Modrica on other thread I have put the same script. Can you share whole output - at least ssl version?

@Modrica Can you check with python 3?

i tried with python3, same output as before.

@SebuZet here is response from 2.7

#####################################################################################
#  Checking ssl for: 3
#####################################################################################
wrap socket test (ctx: 3)...
TEST, connecting
TEST, response: 'DPLUG-1.6

'
TEST, response: '<?xml version="1.0" encoding="utf-8" ?><Update Type="InvalidateAccount"/>

'
TEST, connected
TEST, authenticating...
TEST, response: '<?xml version="1.0" encoding="utf-8" ?><Response Type="AuthToken" Status="Okay" StartFrom="2019-03-14/16:10:17"/>

'
TEST, gettings status...
TEST, response: '<?xml version="1.0" encoding="utf-8" ?><Response Type="DeviceState" Status="Okay"><DeviceState><Device DUID="__DUID__" GroupID="AC" ModelID="AC" ><Attr ID="AC_FUN_ENABLE" Type="RW" Value="Enable"/><Attr ID="AC_FUN_POWER" Type="RW" Value="On"/><Attr ID="AC_FUN_OPMODE" Type="RW" Value="Heat"/><Attr ID="AC_FUN_TEMPSET" Type="RW" Value="23"/><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="24"/><Attr ID="AC_FUN_SLEEP" Type="RW" Value="0"/><Attr ID="AC_FUN_WINDLEVEL" Type="RW" Value="High"/><Attr ID="AC_FUN_DIRECTION" Type="RW" Value="Fixed"/><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="240"/><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="55"/><Attr ID="AC_COOL_CAPABILITY" Type="R" Value="25"/><Attr ID="AC_WARM_CAPABILITY" Type="R" Value="32"/><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="73"/><Attr ID="AC_SG_MACMID" Type="W" Value="124"/><Attr ID="AC_SG_MACLOW" Type="W" Value="153"/><Attr ID="AC_SG_VENDER01" Type="W" Value="248"/><Attr ID="AC_SG_VENDER02" Type="W" Value="4"/><Attr ID="AC_SG_VENDER03" Type="W" Value="46"/><Attr ID="AC_ADD2_PANEL_VERSION" Type="R" Value="150203"/><Attr ID="AC_ADD2_OUT_VERSION" Type="R" Value="1311745"/><Attr ID="AC_FUN_MODEL" Type="R" Value="6"/><Attr ID="AC_ADD2_OPTIONCODE" Type="R" Value="54714"/><Attr ID="AC_ADD2_USEDPOWER" Type="R" Value="22934"/><Attr ID="AC_ADD2_USEDTIME" Type="R" Value="138500"/><Attr ID="AC_ADD2_CLEAR_POWERTIME" Type="RW" Value="254"/><Attr ID="AC_ADD2_FILTERTIME" Type="RW" Value="300"/><Attr ID="AC_ADD2_FILTER_USE_TIME" Type="R" Value="3050"/></Device></DeviceState></Response>

@SebuZet Here is 3 :frowning:

#####################################################################################
#  Checking ssl for: 3
#####################################################################################
wrap socket test (ctx: 3)...
TEST, connecting
TEST, response: 'DPLUG-1.6

'
TEST, response: '<?xml version="1.0" encoding="utf-8" ?><Update Type="InvalidateAccount"/>

'
TEST, connected
TEST, authenticating...
TEST: exception:
Traceback (most recent call last):
  File "ac_connection_test2.py", line 68, in <module>
    sslSocket.sendall(message)
  File "/usr/lib/python3.5/ssl.py", line 899, in sendall
    v = self.send(data[count:])
  File "/usr/lib/python3.5/ssl.py", line 869, in send
    return self._sslobj.write(data)
  File "/usr/lib/python3.5/ssl.py", line 594, in write
    return self._sslobj.write(data)
TypeError: a bytes-like object is required, not 'str'

@Modrica @jackdalma @Nick2 Ok, I hope that this is the last one :slight_smile:
Latest version script

after adding \n on line 32 after < /Request > :smiley:
this is the response:

TEST, creating context
TEST, load verify location
TEST, set ciphers
TEST, load cert chain
TEST, wrapping ssl
TEST, connecting
DPLUG-1.6

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

TEST, athenticating
response: <?xml version="1.0" encoding="utf-8" ?><Response Type="AuthToken" Status="Okay" StartFrom="2019-03-15/08:56:07"/>

TEST, Error creating socket

@jackdalma Thanks, can you try latest version. I hope it will work

thank you but unfortunately same response.

My mistake. Can you try one more time?

ok, got it this time.

TEST, creating context
TEST, load verify location
TEST, set ciphers
TEST, load cert chain
TEST, wrapping ssl
TEST, connecting
DPLUG-1.6

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

TEST, athenticating
response: <?xml version="1.0" encoding="utf-8" ?><Response Type="AuthToken" Status="Okay" StartFrom="2019-03-15/09:20:03"/>

TEST, getting status
TEST, receiving
TEST, got it, printing
<?xml version="1.0" encoding="utf-8" ?><Response Type="DeviceState" Status="Okay"><DeviceState><Device DUID="duid" 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="Wind"/><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="19"/><Attr ID="AC_FUN_SLEEP" Type="RW" Value="0"/><Attr ID="AC_FUN_WINDLEVEL" Type="RW" Value="High"/><Attr ID="AC_FUN_DIRECTION" Type="RW" Value="Rotation"/><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="68"/><Attr ID="AC_COOL_CAPABILITY" Type="R" Value="35"/><Attr ID="AC_WARM_CAPABILITY" Type="R" Value="40"/><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="183"/><Attr ID="AC_SG_MACMID" Type="W" Value="161"/><Attr ID="AC_SG_MACLOW" Type="W" Value="253"/><Attr ID="AC_SG_VENDER01" Type="W" Value="188"/><Attr ID="AC_SG_VENDER02" Type="W" Value="140"/><Attr ID="AC_SG_VENDER03" Type="W" Value="205"/><Attr ID="AC_ADD2_PANEL_VERSION" Type="R" Value="140315"/><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="54458"/><Attr ID="AC_ADD2_USEDPOWER" Type="R" Value="2060"/><Attr ID="AC_ADD2_USEDTIME" Type="R" Value="2440"/><Attr ID="AC_ADD2_CLEAR_POWERTIME" Type="RW" Value="254"/><Attr ID="AC_ADD2_FILTERTIME" Type="RW" Value="500"/><Attr ID="AC_ADD2_FILTER_USE_TIME" Type="R" Value="2440"/></Device></DeviceState></Response>

@SebuZet , working greate with 3.5 too :slight_smile:

TEST, creating context
TEST, load verify location
TEST, set ciphers
TEST, load cert chain
TEST, wrapping ssl
TEST, connecting
DPLUG-1.6


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


TEST, athenticating
response: <?xml version="1.0" encoding="utf-8" ?><Response Type="AuthToken" Status="Okay" StartFrom="2019-03-15/09:25:33"/>


TEST, getting status
TEST, receiving
TEST, got it, printing
<?xml version="1.0" encoding="utf-8" ?><Response Type="DeviceState" Status="Okay"><DeviceState><Device DUID="__DUID__" GroupID="AC" ModelID="AC" ><Attr ID="AC_FUN_ENABLE" Type="RW" Value="Enable"/><Attr ID="AC_FUN_POWER" Type="RW" Value="On"/><Attr ID="AC_FUN_OPMODE" Type="RW" Value="Heat"/><Attr ID="AC_FUN_TEMPSET" Type="RW" Value="23"/><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" Type="RW" Value="0"/><Attr ID="AC_FUN_WINDLEVEL" Type="RW" Value="High"/><Attr ID="AC_FUN_DIRECTION" Type="RW" Value="Fixed"/><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="240"/><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="55"/><Attr ID="AC_COOL_CAPABILITY" Type="R" Value="25"/><Attr ID="AC_WARM_CAPABILITY" Type="R" Value="32"/><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="73"/><Attr ID="AC_SG_MACMID" Type="W" Value="124"/><Attr ID="AC_SG_MACLOW" Type="W" Value="153"/><Attr ID="AC_SG_VENDER01" Type="W" Value="248"/><Attr ID="AC_SG_VENDER02" Type="W" Value="4"/><Attr ID="AC_SG_VENDER03" Type="W" Value="46"/><Attr ID="AC_ADD2_PANEL_VERSION" Type="R" Value="150203"/><Attr ID="AC_ADD2_OUT_VERSION" Type="R" Value="1311745"/><Attr ID="AC_FUN_MODEL" Type="R" Value="6"/><Attr ID="AC_ADD2_OPTIONCODE" Type="R" Value="54714"/><Attr ID="AC_ADD2_USEDPOWER" Type="R" Value="23029"/><Attr ID="AC_ADD2_USEDTIME" Type="R" Value="138670"/><Attr ID="AC_ADD2_CLEAR_POWERTIME" Type="RW" Value="254"/><Attr ID="AC_ADD2_FILTERTIME" Type="RW" Value="300"/><Attr ID="AC_ADD2_FILTER_USE_TIME" Type="R" Value="3220"/></Device></DeviceState></Response>

@Modrica @jackdalma @Nick2 Thanks for your help and testing connection scripts.
Is any one brave enough to check latest component from dev branch :smiley: ?

climate:
  platform: climate_ip
  config_file: '/config/custom_components/climate_ip/samsung_2878.yaml'

Next, open ‘/config/custom_components/climate_ip/samsung_2878.yaml’ file and change config data (host, token, mac or duid) and restart HA.

Let me know what we have to fix :smiley:

Hey guys,

Only way I can get it to work is to set

sslContext.verify_mode = ssl.CERT_NONE

I’ve tried the one from @SebuZet’s github dev branch: ac14k_m.pem
I’ve also tried getting the cert from my server using openssl using:

echo | openssl s_client -connect 192.168.1.106:2878 2>&1 | openssl x509 -outform pem

With both certs I get

TEST, Error creating socket

Traceback (most recent call last):
File “D:/ha/test.py”, line 35, in create_socket
sslSocket.connect((HOST, PORT))
File “D:\Python27\lib\ssl.py”, line 864, in connect
self._real_connect(addr, False)
File “D:\Python27\lib\ssl.py”, line 855, in _real_connect
self.do_handshake()
File “D:\Python27\lib\ssl.py”, line 828, in do_handshake
self._sslobj.do_handshake()
SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:727)

Can anyone confirm the cert they are using?

@SebuZet
i got this on log:

2019-03-15 12:48:21 INFO (MainThread) [custom_components.climate_ip.climate] climate_ip: async setup platform
2019-03-15 12:48:21 ERROR (MainThread) [custom_components.climate_ip.climate] Error creating socket

2019-03-15 12:48:23 INFO (MainThread) [custom_components.climate_ip.climate] <Request Type="AuthToken"><User Token="TOKEN" /></Request>

2019-03-15 12:48:23 INFO (MainThread) [custom_components.climate_ip.climate] <Request Type="DeviceState" DUID="DUID"></Request>

2019-03-15 12:48:23 ERROR (MainThread) [custom_components.climate_ip.climate] Error creating socket

@Nick2 i’m using the one from SebuZet’s github dev branch

I noticed your ACs are returning: DPLUG-1.6

Mine returns DRC-1.00…

TEST, creating context
TEST, load verify location
TEST, set ciphers
TEST, load cert chain
TEST, wrapping ssl
TEST, connecting
DRC-1.00

@SebuZet

I tried your dev branch with my HA. Got:

ModuleNotFoundError: No module named ‘xmljson’

I renamed climate.py to climate_ip.py restarted HA and renamed back and restarted again and no more complaints. not sure how that worked…

I now get Error creating socket same as @jackdalma

I tried updating samsung_2878.py to use CERT_NONE but still no luck

def create_socket(self, init_message):
    sslSocket = None
    try:
        sslContext = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
        #sslContext.verify_mode = ssl.CERT_REQUIRED
        sslContext.verify_mode = ssl.CERT_NONE
        sslContext.load_verify_locations(cafile = self._cert)
        sslContext.set_ciphers("HIGH:!DH:!aNULL")
        sslContext.load_cert_chain(self._cert)

Is deleting pycache folder enough to make my changes to samsung_2878.py take effect ?

I’ve updated files, @Modrica and @jackdalma it should work with your units.
@Nick2 If it will work for @Modrica and @jackdalma we will back to your configuration. Try latest version. If you modify my last script and use sslContext.verify_mode = ssl.CERT_NONE can you connect with your device?