Samsung AC Support, help needed

Hi @SebuZet,

I’ll give it a go tonight.

ps. I’ve been attempting to build a server to mimic the AC. Once that’s build, you could test you component against that. (I’m using the nodejs client implementation build the server against.) Haven’t got very far though…

@Nick2 Great, updated version is available. If it doesn’t work you can try to modify the code to make communication working. When it starts to work I will put it into my component and we will have working component for old AC unit

Hi @SebuZet,

I’ve made some good progress tonight. After some adjustment of your code and disabling SSL verification, I’ve got it to connect to my AC.

What I’m not sure how to do is loop correctly to get the responses from the AC. (like the while loops in your code)

You’ll see I’ve included the server responses in comments.

Hopefully this is a good start

Here’s my code: https://drive.google.com/open?id=17a0nLfIWkR-E8JZ7xP7ne8IcEY-F8gFz

Hi @Nick2 This is very good start. This is almost finish :wink: I’ll try to integrate this into component and let you know.

Hi @Nick2, we can make next step in testing new solution. If you want to test new component please get it from my GitHub dev branch. Please make ‘climate_ip’ folder in your config/custom_components folder and copy all files.
In configuration of your HASS put section:

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

Next, open ‘/config/custom_components/climate_ip/samsung_2878_2.yaml’ file and change config data (host, token, duid) and restart HA.
If you want to make same code modification you can go to connection_s2878.py file and look at execute method :wink:

Let me know what we have to fix :smiley:

@SebuZet

Error while setting up platform climate_ip
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/climate_ip/climate.py”, line 75, in async_setup_platform
device_controller = create_controller(‘yaml’, config, _LOGGER)
File “/config/custom_components/climate_ip/controller.py”, line 58, in create_controller
if c.initialize():
File “/config/custom_components/climate_ip/controller_yaml.py”, line 116, in initialize
self.update_state()
File “/config/custom_components/climate_ip/controller_yaml.py”, line 132, in update_state
self._state_getter.update_state(self._state_getter.value, debug)
File “/config/custom_components/climate_ip/properties.py”, line 129, in update_state
device_state = self.get_connection(None).execute(None, None)
File “/config/custom_components/climate_ip/connection_s2878.py”, line 120, in execute
sslSocket = self.ssl_wrap_socket(clientSocket)
File “/config/custom_components/climate_ip/connection_s2878.py”, line 36, in ssl_wrap_socket
return sslContext.wrap_socket(sock, server_side=False, server_hostname=HOST)
NameError: name ‘HOST’ is not defined

@Modrica My mistake. I was too quick. Please try new version.

@SebuZet

Error while setting up platform climate_ip
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/climate_ip/climate.py”, line 75, in async_setup_platform
device_controller = create_controller(‘yaml’, config, _LOGGER)
File “/config/custom_components/climate_ip/controller.py”, line 58, in create_controller
if c.initialize():
File “/config/custom_components/climate_ip/controller_yaml.py”, line 116, in initialize
self.update_state()
File “/config/custom_components/climate_ip/controller_yaml.py”, line 138, in update_state
op.update_state(device_state, debug)
File “/config/custom_components/climate_ip/properties.py”, line 109, in update_state
v = self.status_template.render(device_state=device_state)
File “/usr/local/lib/python3.7/site-packages/jinja2/asyncsupport.py”, line 76, in render
return original_render(self, *args, **kwargs)
File “/usr/local/lib/python3.7/site-packages/jinja2/environment.py”, line 1008, in render
return self.environment.handle_exception(exc_info, True)
File “/usr/local/lib/python3.7/site-packages/jinja2/environment.py”, line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File “/usr/local/lib/python3.7/site-packages/jinja2/_compat.py”, line 37, in reraise
raise value.with_traceback(tb)
File “”, line 1, in top-level template code
File “/usr/local/lib/python3.7/site-packages/jinja2/environment.py”, line 430, in getattr
return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: ‘dict object’ has no attribute ‘Response’

Interesting blog about Samsung AC 2878

Thanks but without device it won’t help me. I need help from someone who can write python code (connection part) and have such device at home. Maybe @Nick2 will find a little time to test and fix connection part.

1 Like

@SebuZet,

I’ve just take a look at your dev branch. Wow you’ve done some work there!

I’m keen to try it out over the next few nights. I’ll let you know how I go.

Is there a way to test a component outside of HA so I can run it through a debugger?

@Nick2 To be honest, I have no idea how to debug under HA. I was developing it outside HA and after all I’ve added imports from HA.

Without connection everything looks good. If you edit connection_s2878.py file you can remove comments in lines 117, 118, 141 and restart HA. You will see climate device with data taken by you from your device (hardcoded xml).

So the last thing to do is to add communication with device.
You can print variables init_message and message from execute method to see what data will be send to device. In my system in logs everything looks good. We only need to communicate with device :wink:

To make it easy we can extract communication to separate file and test/debug it. Unfortunately I don’t have device to play with :frowning:

@SebuZet @Nick2 I removed comments and are getting this error:

Somthing with ssl handshake failure

Thu Mar 14 2019 13:20:59 GMT+0100 (Central European Standard Time)
Error while setting up platform climate_ip
Traceback (most recent call last):
File “/config/custom_components/climate_ip/connection_s2878.py”, line 123, in execute
sslSocket.connect((self._host, self._port))
File “/usr/local/lib/python3.7/ssl.py”, line 1150, in connect
self._real_connect(addr, False)
File “/usr/local/lib/python3.7/ssl.py”, line 1141, in _real_connect
self.do_handshake()
File “/usr/local/lib/python3.7/ssl.py”, line 1117, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:1056)

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/climate_ip/climate.py”, line 75, in async_setup_platform
device_controller = create_controller(‘yaml’, config, _LOGGER)
File “/config/custom_components/climate_ip/controller.py”, line 58, in create_controller
if c.initialize():
File “/config/custom_components/climate_ip/controller_yaml.py”, line 116, in initialize
self.update_state()
File “/config/custom_components/climate_ip/controller_yaml.py”, line 132, in update_state
self._state_getter.update_state(self._state_getter.value, debug)
File “/config/custom_components/climate_ip/properties.py”, line 129, in update_state
device_state = self.get_connection(None).execute(None, None)
File “/config/custom_components/climate_ip/connection_s2878.py”, line 136, in execute
sslSocket.shutdown(SHUT_RDWR)
File “/usr/local/lib/python3.7/ssl.py”, line 1090, in shutdown
super().shutdown(how)
OSError: [Errno 107] Socket not connected
Connection lost. Reconnecting…

@Modrica Thanks (removing comment (#) from lines 118 and 141 will comment out all communication stuff.
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

@SebuZet I have som issue I need to solve her, I think it is just my os installation not your code… Need to solve python-openssl

%Run ac_connection_test.py
Traceback (most recent call last):
File “/usr/share/hassio/homeassistant/custom_components/climate_ip/ac_connection_test.py”, line 14, in
ssl.PROTOCOL_TLS_CLIENT,
AttributeError: module ‘ssl’ has no attribute ‘PROTOCOL_TLS_CLIENT’

@Modrica It looks like it depends on system/python version etc… Just remove this line ( or change to -1) and try again

@SebuZet I changed it to -1 and here is result: :frowning:

#####################################################################################
#  Checking ssl for: -1
#####################################################################################
wrap socket test (ctx: -1)...
TEST FAILED, skipping
#####################################################################################
#  Checking ssl for: 3
#####################################################################################
wrap socket test (ctx: 3)...
TEST FAILED, skipping
#####################################################################################
#  Checking ssl for: 4
#####################################################################################
wrap socket test (ctx: 4)...
TEST FAILED, skipping
#####################################################################################
#  Checking ssl for: 5
#####################################################################################
wrap socket test (ctx: 5)...
TEST FAILED, skipping
#####################################################################################
#  Checking ssl for: 2
#####################################################################################
wrap socket test (ctx: 2)...
TEST FAILED, skipping
#####################################################################################
#  Checking ssl for: None
#####################################################################################
wrap socket test (ctx: None)...
TEST FAILED, skipping

@SebuZet I am following your another thread (Samsung AC) and I am getting this response from AC

 <?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="22915"/>
<Attr ID="AC_ADD2_USEDTIME" Type="R" Value="138480"/>
<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="3030"/>
</Device>
</DeviceState>
</Response>

Hi,
thank you for your work SebuZet. i tried your script, and i made some fix to get che output
script

here is the response:

 #####################################################################################
#  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/14:05:38"/>
'
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="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>

@jackdalma

with your code I am getting this error:

#####################################################################################
#  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 "/usr/share/hassio/homeassistant/custom_components/climate_ip/ac_connection_test.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'