Samsung AC Support, help needed

@SebuZet there are progress but there is another error:

2019-03-15 16:15:01 INFO (MainThread) [custom_components.climate_ip.climate] climate_ip: async setup platform
2019-03-15 16:15:04 ERROR (MainThread) [custom_components.climate_ip.climate] Socket error
2019-03-15 16:15:04 ERROR (MainThread) [custom_components.climate_ip.climate] climate_ip: error while creating controller!
2019-03-15 16:15:04 ERROR (MainThread) [homeassistant.components.climate] Error while setting up platform climate_ip
Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/custom_components/climate_ip/samsung_2878.py", line 154, in execute
    sslSocket.sendall(message.encode('utf-8'))
  File "/usr/lib/python3.5/ssl.py", line 903, in sendall
    return socket.sendall(self, data, flags)
OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/lib/python3.5/asyncio/tasks.py", line 400, in wait_for
    return fut.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/home/homeassistant/.homeassistant/custom_components/climate_ip/climate.py", line 75, in async_setup_platform
    device_controller = create_controller('yaml', config, _LOGGER)
  File "/home/homeassistant/.homeassistant/custom_components/climate_ip/controller.py", line 58, in create_controller
    if c.initialize():
  File "/home/homeassistant/.homeassistant/custom_components/climate_ip/controller_yaml.py", line 125, in initialize
    self.update_state()
  File "/home/homeassistant/.homeassistant/custom_components/climate_ip/controller_yaml.py", line 155, in update_state
    self._state_getter.update_state(self._state_getter.value, debug)
  File "/home/homeassistant/.homeassistant/custom_components/climate_ip/samsung_2878.py", line 190, in update_state
    device_state = conn.execute(self._connection_template, None)
  File "/home/homeassistant/.homeassistant/custom_components/climate_ip/samsung_2878.py", line 162, in execute
    sslSocket.shutdown(SHUT_RDWR)
  File "/usr/lib/python3.5/ssl.py", line 975, in shutdown
    socket.shutdown(self, how)
OSError: [Errno 9] Bad file descriptor

@jackdalma Can you try one more time…

Nice job @SebuZet it connect and show up on Home assistant.
I’m not home to check if it is really on, but status show me it is :stuck_out_tongue:

Just missing some function. there is only Power, temperature and operation mode.

Thank you :smiley:

@jackdalma Can you paste your xml (status response)? You can add entry debug: true in configuration.yaml and check it is dev-panel or use script.
What functionality is missing?

@jackdalma You can edit file samsung_2878.yaml and modify as you want.
Good point to start is removing line validate_properties: True
Generally, you can add any functionality supported by your unit by editing this file.
You should be able to change defined by you options using service climate.climate_ip_samsungac_set_property with proper params :wink:

edit: which file are you using samsung_2878.yaml or the old one samsung_2878_2.yaml

YES :slight_smile:

and all commands are testet ok :slight_smile: on/off, operation and temperature (+/- and current) … great work @SebuZet

@SebuZet I’m using samsung_2878.yaml
removed the validate_properties: True and now showing all the function at least on the dev panel.
but on the card still missing purify - auto_clean - specialwind.

the attributes will auto-update after a while or only after sending a command?

the status xml:

<?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="Auto"/>	
			<Attr ID="AC_FUN_TEMPSET" Type="RW" Value="25"/>
			<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="20"/>
			<Attr ID="AC_FUN_SLEEP" Type="RW" Value="0"/>
			<Attr ID="AC_FUN_WINDLEVEL" Type="RW" Value="Auto"/>
			<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="73"/>
			<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

with validate_properties: False

Let’s start from the beginning: HA by default supports only:

  • power on/off
  • operation mode (cool, heat, fan_only, auto etc)
  • swing mode (up_down, left_right etc)
  • fan speed
  • set/get target temp
  • set/get target max temp
  • set/get target min temp
  • get current temp

Only those functions will be available from card.

If you want more options you need to define them in YAML file. I’ve added few extra options (using @jackdalma status xml) and you can see them in dev-panel.
You can remove or modify them freely or you can add new one.

If you want to have Purify switch you have to add proper switch template in HA and use service mentioned by me few posts above. You can find an example in readme in master branch.

Attributes will be updated after changing something. I can add pooling if it is needed.

@SebuZet understood!

about update, yeah, i think is better to add pooling.
it’s possible to add a friendly name too?

Thank you again for all your support :smiley:

@SebuZet

I got it working too with your latest code and disabling the cert validation.

Maybe you can update the code to only do validation if a cert is set in samsung_2878.yaml?

It’s also working with apple homekit.

Good work!

ps. I noticed the settings are showing in Celsius but the current temp is showing in Fahrenheit

Great to hear :slight_smile:

Done, new version on repo

Polling added, friendly name also

Did anyone try to use service to eg. turn purify on/off?

@SebuZet.

You cert validation change is working, thanks!

Looks like my AC is returning deg F for AC_FUN_TEMPNOW even though the other setting are coming back in deg C.

I hacked the template for AC_FUN_TEMPNOW to convert to deg C:

 status_template: '{% for a in device_state.Response.children.0.DeviceState.Device.children %}{% if a.Attr.attributes.ID == "AC_FUN_TEMPNOW" %}{{(a.Attr.attributes.Value - 32) * 5/9 }}{% endif %}{% endfor %}'

Now it’s displaying the current temp in deg C :smiley:

Is there a variable somewhere to know whether or not to do the above conversion?

hi @jackdalma, @Modrica,

Have either of you experienced any instability with HA using this @SebuZet’s AC component?

I upgraded to the HA 0.89.2 prior to installing the component.

After installing the component, my HA worked for a while(maybe 30 min) before dying. I had to reboot the hassio host to bring it back each time.

After disabling the AC component it’s been stable since.

I haven’t had a chance to check any logs yet, but was wondering if either of you experience similar?

Thanks

Can you try latest version? Now, component is working on already created connection. Last version was opening socket connection every time when status was updated or command executed.

I’ve noticed that looking at you xml but I don’t think I can do something with that. Generally, I’ll add ‘temperature_unit’ into component configuration but it will have impact to all temp values.

If your device is not consistent then approach with customizing template is the best in my opinion. That’s why I’ve used templates - to make customization easy.

:+1: will do. I’ll let you know.

I just checked your last commit. If I could suggest an enhancement to your execute method, you could test the socket with an AuthToken request before sending the command. EG: send

<Request Type=“AuthToken”><User Token=“XXXXXXXXX” /></Request>
<?xml version=“1.0” encoding=“utf-8” ?><Response Type=“AuthToken” Status=“Okay” StartFrom=“2017-01-30/12:17:31”/>

if the socket is dead it should throw an exception and you can reconnect. If you get a response you can validate the token by checking for Status=Okay.

:+1: Cool, the template worked well

Any comments are welcome :slight_smile: I’m new to python and HA. This is my first project in python and the way how I’m learning. I will add such improvement.

EDIT: @Nick2 suggestion applied. Feedback is welcome :wink:

@SebuZet

Latest dev version broke something on my AC:
2019-03-18 10:26:14 ERROR (MainThread) [custom_components.climate_ip.climate] Socket error

 File "/usr/local/lib/python3.7/site-packages/homeassistant/components/climate/__init__.py", line 216, in state_attributes
    self.precision),
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/temperature.py", line 26, in display_temp
    temperature, temperature_unit, ha_unit)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/util/temperature.py", line 25, in convert
    from_unit, TEMPERATURE))
ValueError: None is not a recognized temperature unit.
2019-03-18 10:25:44 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 352, in _async_add_entity
    await entity.async_update_ha_state()
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 225, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 255, in _async_write_ha_state
    attr = self.state_attributes or {}
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/climate/__init__.py", line 216, in state_attributes

Can you turn debugs on and show output?

Hey @SebuZet,

I thought it might be a bit cheeky to suggest implementing keepalive as well :slight_smile:

Just tested commit 7aa84ac. Getting many validating connection errors but it is working

2019-03-18 21:34:08 ERROR (MainThread) [custom_components.climate_ip.climate] Error while validating connecting, send error