Samsung Air Conditioner

@seBuZet,

after rebooting one of the AC’s that was constantly dropping the connection, seems the system is pretty much stable with your last code version. Although the min\max temperatures keep not working as well the velocity options. Some questions:

  1. What do you mean by dev-template to show all the info from the device? Sorry mate, I have been exploring HA for only 1month :slight_smile:
  2. When we speak about the min\max temperatures not working, I see we have two types, temperature (min\max) and target_temp_high and low. This values, although I have changed them on samsungrac.yaml to 19/25, on HA, they show 16/30. From where this values come?

temperature: 24
target_temp_high: 30
target_temp_low: 16
current_temperature: 25
min_temp: 19
max_temp: 25
filter_time: 2055

If you see on the Thermostat feature, the values are incorrect and I cant really use the sliders to adjust, it always return to the same values (16\30):

image

  1. I do understand that under samsungrac.yaml you just enumerate all the attributes you want to show and you prepare the PUT requests. But how do I know that for instance to control a the wind speed I need actually to send or while speaking about the attributes how do I get this code .options8[11] ? I suppose is how you say with the Dev-template can you help a bit more here?

status_template: ‘{{ device_state.Devices.0.Mode.options.8[11:]}}’

Thanks for your effort here

This is a good news for start

Try this button on HA web page:


There is a template editor. You need to read about jinja2 templates.
I’m new to HASS also. This is my fourth month :slight_smile:
In case of temperatures there are few declared in YAML.

  • min_temp and max_temp are something like your device capabilities - minimum and maximum temperature accepted by your device. My device accepts temps in range 16-32. Checked with RCU :slight_smile:. You can set whatever you decide. You can also remove this from YAML if you are not sure about this. If you try to set temp which is not accepted by your device it will probably be ignored.

  • Those values comes from your device - from json retrieved from your device. In this json you can find something like this:

    “Temperatures”: [{“current”: 22.0, “desired”: 22.0, “id”: “0”, “maximum”: 30, “minimum”: 16, “unit”: “Celsius”}]

    Where “current” is current_temperature attribute, “desired” is temperature, “maximum” is target_temp_high and “minimum” is target_temp_low. Those values are taken from json using status_template from YAML file.

That’s correct.

This is the hardest part :wink: I found this information in this thread. Some part I figured out trying to do similar things.

You really need to check what jinja2 templates are. In short, this particular example:

status_template: ‘{{ device_state.Devices.0.Mode.options.8[11:]}}’

Is “saying”: get device json (device_state), find node called Devices, get first element from this node (0), within this element find element called Mode, within this find element called options, get 8th element from this (8) and extract every character starting from 11th ([11:]). You can put your json device to some beautifier then it will be easier to understand.

@SebuZet

was able to costumize a bit more the samsungrac.yaml and right now is working like pretty nice:)
Now I was thinking on doing some automations\scripts. Was wondering if I can run a kind of request to turn it on\on and other command some seconds after to define some parameters:

was trying to do some tests with the curl.exe

curl.exe curl -s -X PUT -d ‘{“direction”: “Fix”}’ -k -H “Content-Type: application/json” -H “Authorization: Bearer mytoke” --cert ‘./ac14k_m.pem’ --insecure https://192.168.1.135:8888/devices/0/winds/0/wind

but this doesn’t work and claims I’m not sending the certificate. I guess, that I’m failling to understand how I point where the .pem is. Wondering if you can help here if the file would be on c:\tem\ack14k.pm how the path would be on curl ?

By other side this was just to drop some requests directly. From a HA prespective, how do you think would be the best way to do it? I bet you already created some automations\scripts to turn on the AC for instance if the temperature reach a specific value:)

Any input would be welcome!
Thank you

That’s great :slight_smile:

You can set all parameters at once by using service added by my component.
This service is called climate.climate_ip_set_property and you can set as many parameters as you want. See below for an example for data passed to the service:

{
“entity_id” : “climate.salon_ac”,
“power” : “on”,
“purify” : “on”,
“operation_mode” : “heat”,
“special_mode” : “comfort”
}
Such dataset will turn device on, set purify mode on, switch to heat mode and set comfort special mode at once :wink: This is the way how I did automation.
You can try this service using dev-service panel in HASS web page (first icon from left :wink: in the same place where template panel is)


Try this out and let me know if it is working.

try something like this:

curl.exe curl -s -X PUT -d ‘{“direction”: “Fix”}’ -k -H “Content-Type: application/json” -H “Authorization: Bearer mytoke” --cert ‘c:\tem\ack14k.pm’ --insecure https://192.168.1.135:8888/devices/0/winds/0/wind

Is it correct extension (pm) or it’s just a typo?

Thank you @SebuZet

seems I have some invalid JSON here, but I don’t see really why:

If I try to use insteadl ip_set_property, if I use climate.turn_on, works fine:

image

please make sure that you are using ". In second example I can see different " than in first one :wink:

By bad, I just copy pasted the content from the page and seems some non printable characters were being added there. It’s woking now :slight_smile: Last question, what should be the right parameter to call, if I want to set a desired operational temperature? I see “temperature” is sent on increments of 1 unit, if I want to set(for instances 25º) a desired temperature which attribute do I need to send?

image

Some editors are changing letters " to different one for opening and different for closing.
In this service you can add any attribute which can be set as first parameter and desired value as second. So in your case it will be:
“temperature” : 25
For numbers you don’t use " characters - only numbers. If you put number as string (between " characters) device will ignore it.
Can you share your configuration YAML, I can add this to repo with your device’s model name as reference. You can also make PR on GitHub if you want to be visible in repository as author :slight_smile:

check the error message. If I set 1 it works, but anything higher gives the error message you see below.

Got it. Fixed. Please update component to latest version.

properties.py updated and now works fine :wink: Thank you!
Where can I edit the content of this card? I would like to had stuff like the special_mode, beep etc:

Hello @SebuZet!! I’m trying to configure this AC feature, but when i try to get the TOKEN, as you teach, i got an error on the actest.py script… Can you help me, please?!

Traceback (most recent call last):
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/connection.py”, line 159, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/util/connection.py”, line 80, in create_connection
raise err
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/util/connection.py”, line 70, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 600, in urlopen
chunked=chunked)
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 343, in _make_request
self._validate_conn(conn)
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 839, in _validate_conn
conn.connect()
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/connection.py”, line 301, in connect
conn = self._new_conn()
File “/Library/Frameworks/Python.framework/Versions/3.7/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 0x106acaf60>: Failed to establish a new connection: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/adapters.py”, line 449, in send
timeout=timeout
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File “/Library/Frameworks/Python.framework/Versions/3.7/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.168.86.97’, port=8888): Max retries exceeded with url: /devicetoken/request (Caused by NewConnectionError(’<urllib3.connection.VerifiedHTTPSConnection object at 0x106acaf60>: Failed to establish a new connection: [Errno 61] Connection refused’))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “actest.py”, line 4, in
resp = s.post(“https://192.168.86.97:8888/devicetoken/request”, data={“DeviceToken”:“xxxxxxxxxxx”}, headers=headers, stream=True, verify=False, cert=‘cert.pem’)
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/sessions.py”, line 581, in post
return self.request(‘POST’, url, data=data, json=json, **kwargs)
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/sessions.py”, line 533, in request
resp = self.send(prep, **send_kwargs)
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/sessions.py”, line 646, in send
r = adapter.send(request, **kwargs)
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/adapters.py”, line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host=‘192.168.86.97’, port=8888): Max retries exceeded with url: /devicetoken/request (Caused by NewConnectionError(’<urllib3.connection.VerifiedHTTPSConnection object at 0x106acaf60>: Failed to establish a new connection: [Errno 61] Connection refused’))

Hello @SebuZet!

I’m trying to configure but when i try to get the TOKEN got an error on the actest.py script.
Probably my AC is running on port 2878 so I’ve modified actest.py with IP adress and port 2878 but I’ve this error.

Can you help me, please?!

C:\Users\l.sartori\Desktop#SAMSUNG_AC>py actest.py
C:\Users\l.sartori\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecureRequestWarning)
Traceback (most recent call last):
File “C:\Users\l.sartori\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py”, line 603, in urlopen
chunked=chunked)
File “C:\Users\l.sartori\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py”, line 387, in _make_request
six.raise_from(e, None)
File “”, line 2, in raise_from
File “C:\Users\l.sartori\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py”, line 383, in _make_request
httplib_response = conn.getresponse()
File “C:\Users\l.sartori\AppData\Local\Programs\Python\Python37-32\lib\http\client.py”, line 1321, in getresponse
response.begin()
File “C:\Users\l.sartori\AppData\Local\Programs\Python\Python37-32\lib\http\client.py”, line 296, in begin
version, status, reason = self._read_status()
File “C:\Users\l.sartori\AppData\Local\Programs\Python\Python37-32\lib\http\client.py”, line 278, in _read_status
raise BadStatusLine(line)
http.client.BadStatusLine: DPLUG-1.6

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:\Users\l.sartori\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\adapters.py”, line 449, in send
timeout=timeout
File “C:\Users\l.sartori\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py”, line 641, in urlopen
_stacktrace=sys.exc_info()[2])
File “C:\Users\l.sartori\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\util\retry.py”, line 368, in increment
raise six.reraise(type(error), error, _stacktrace)
File “C:\Users\l.sartori\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\packages\six.py”, line 685, in reraise
raise value.with_traceback(tb)
File “C:\Users\l.sartori\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py”, line 603, in urlopen
chunked=chunked)
File “C:\Users\l.sartori\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py”, line 387, in _make_request
six.raise_from(e, None)
File “”, line 2, in raise_from
File “C:\Users\l.sartori\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py”, line 383, in _make_request
httplib_response = conn.getresponse()
File “C:\Users\l.sartori\AppData\Local\Programs\Python\Python37-32\lib\http\client.py”, line 1321, in getresponse
response.begin()
File “C:\Users\l.sartori\AppData\Local\Programs\Python\Python37-32\lib\http\client.py”, line 296, in begin
version, status, reason = self._read_status()
File “C:\Users\l.sartori\AppData\Local\Programs\Python\Python37-32\lib\http\client.py”, line 278, in _read_status
raise BadStatusLine(line)
urllib3.exceptions.ProtocolError: (‘Connection aborted.’, BadStatusLine(‘DPLUG-1.6\r\n’))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “actest.py”, line 4, in
resp = s.post(“https://192.168.178.101:2878/devicetoken/request”, data={“DeviceToken”:“xxxxxxxxxxx”}, headers=headers, stream=True, verify=False, cert=‘cert.pem’)
File “C:\Users\l.sartori\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\sessions.py”, line 581, in post
return self.request(‘POST’, url, data=data, json=json, **kwargs)
File “C:\Users\l.sartori\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\sessions.py”, line 533, in request
resp = self.send(prep, **send_kwargs)
File “C:\Users\l.sartori\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\sessions.py”, line 646, in send
r = adapter.send(request, **kwargs)
File “C:\Users\l.sartori\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\adapters.py”, line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: (‘Connection aborted.’, BadStatusLine(‘DPLUG-1.6\r\n’))

Hi @l.sartori,
I don’t have device working on port 2878 so I really cannot help you. Other people was using acdc tool to get token.

@rodrigowa
Those scripts was not created by me. I’ve just used them. You can try to ask in this thread. There is a lot of experienced people.

I followed instructions but when i run actest.py i get that error:

actest.py
Traceback (most recent call last):
File “C:\temp\actest.py”, line 1, in
import requests
ModuleNotFoundError: No module named ‘requests’

Can you help me please? i cant find my Token

Hello @SebuZet!
I’m trying to install your module on a Hass running inside a docker, and it’s complaining that it can’t find xmljson 0.2.0. Looking in home-assistant source, I see that indeed xmljson is not listed. Is it something that should be done?
Otherwise, I guess my only option at the moment is to build my own docker off the official one with the xmljson… or am I missing something?
Also, do you have plans to integrate into home-assistant upstream?

Thanks,
– Sasha

And yes, with my own forked docker image, I got it to work, but would be much better if it worked from the official image.

I’m trying to connect this to my new Samsung Windfree AC (OFC), this is using port 15911 (I’m able to connect using HTTPS on this port but only this, I cant get token or anything else)
Do any body know if it’s possible to connect to this unit directly? (even the Smart Air app can’t find, this unit connect only using SmarThings)

Thank you all!

Hi just got a Samsung windfree and I can’t register it on my WiFi using app SMART HOME or SMART AIR

The AP is created but both app do nothing when I try to add a new device.

Tried also to add the device while connected to the WiFi AP, but nothing.

EDIT the correct app to use is SmartThings.

OK now I wish to integrate it in HASS.

Any advice?