AirCon icon indicating copy to clipboard operation
AirCon copied to clipboard

Homeassistant integration with Humidifier

Open acansmart opened this issue 4 years ago • 7 comments

I am able to run the server, and get the values of different attributes from tau tronics (sun-home) humidifier. However, not able to control it.

curl -ik 'http://192.168.0.168:8888/hisense/status' works fine and returns the values.

{"devices": [{"ip": "192.168.0.193", "props": {"humi": 0, "mist": "MIDDLE", "mistSt": "OFF", "realhumi": 30, "remain": 0, "switch": "OFF", "temp": 81, "timer": 0, "water": "OK", "workmode": "NORMAL"}}]}

However, when trying to run

curl -ik 'http://192.168.0.168:8888/hisense/command?property=switch&value=ON'

it doesnt work. Need to understand what is going wrong here.

acansmart avatar Dec 31 '20 14:12 acansmart

Could you try running the server with --log_level DEBUG and paste the generated syslog in https://gist.github.com?

deiger avatar Jan 04 '21 15:01 deiger

I just upgraded to the latest release, and configured aircon by adding it to the repository in homeassistant. It is able to discover the humidifier, and when I run the below command it works

curl -ik 'http://192.168.0.168:8888/hisense/status' HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 Content-Length: 202 Date: Wed, 13 Jan 2021 22:28:09 GMT Server: Python/3.7 aiohttp/3.6.2

{"devices": [{"ip": "192.168.0.193", "props": {"humi": 0, "mist": "MIDDLE", "mistSt": "OFF", "realhumi": 36, "remain": 0, "switch": "OFF", "temp": 81, "timer": 0, "water": "OK", "workmode": "NORMAL"}}]}

But when I run the command

curl -ik 'http://192.168.0.168:8888/hisense/command?property=switch&value=ON' HTTP/1.1 500 Internal Server Error Content-Type: text/plain; charset=utf-8 Content-Length: 55 Date: Wed, 13 Jan 2021 22:28:31 GMT Server: Python/3.7 aiohttp/3.6.2 Connection: close

500 Internal Server Error

Server got itself in trouble

Below is the error that comes:-

Jan 13 22:28:31 dev 2e5815763538[1008]: Traceback (most recent call last): Jan 13 22:28:31 dev 2e5815763538[1008]: File "/app/aircon/query_handlers.py", line 113, in queue_command_handler Jan 13 22:28:31 dev 2e5815763538[1008]: device.queue_command(request.query['property'], request.query['value']) Jan 13 22:28:31 dev 2e5815763538[1008]: File "/app/aircon/aircon.py", line 152, in queue_command Jan 13 22:28:31 dev 2e5815763538[1008]: if name != 't_control_value' and self.get_property('t_control_value'): Jan 13 22:28:31 dev 2e5815763538[1008]: File "/app/aircon/aircon.py", line 99, in get_property Jan 13 22:28:31 dev 2e5815763538[1008]: return getattr(self._properties, name) Jan 13 22:28:31 dev 2e5815763538[1008]: AttributeError: 'HumidifierProperties' object has no attribute 't_control_value' Jan 13 22:28:31 dev 2e5815763538[1008]: E0113 17:28:31.469 web_protocol.py:355] Error handling request Jan 13 22:28:31 dev 2e5815763538[1008]: Traceback (most recent call last): Jan 13 22:28:31 dev 2e5815763538[1008]: File "/app/aircon/query_handlers.py", line 113, in queue_command_handler Jan 13 22:28:31 dev 2e5815763538[1008]: device.queue_command(request.query['property'], request.query['value']) Jan 13 22:28:31 dev 2e5815763538[1008]: File "/app/aircon/aircon.py", line 152, in queue_command Jan 13 22:28:31 dev 2e5815763538[1008]: if name != 't_control_value' and self.get_property('t_control_value'): Jan 13 22:28:31 dev 2e5815763538[1008]: File "/app/aircon/aircon.py", line 99, in get_property Jan 13 22:28:31 dev 2e5815763538[1008]: return getattr(self._properties, name) Jan 13 22:28:31 dev 2e5815763538[1008]: AttributeError: 'HumidifierProperties' object has no attribute 't_control_value' Jan 13 22:28:31 dev 2e5815763538[1008]: Jan 13 22:28:31 dev 2e5815763538[1008]: During handling of the above exception, another exception occurred: Jan 13 22:28:31 dev 2e5815763538[1008]: Jan 13 22:28:31 dev 2e5815763538[1008]: Traceback (most recent call last): Jan 13 22:28:31 dev 2e5815763538[1008]: File "/usr/local/lib/python3.7/site-packages/aiohttp-3.6.2-py3.7-linux-x86_64.egg/aiohttp/web_protocol.py", line 418, in start Jan 13 22:28:31 dev 2e5815763538[1008]: resp = await task Jan 13 22:28:31 dev 2e5815763538[1008]: File "/usr/local/lib/python3.7/site-packages/aiohttp-3.6.2-py3.7-linux-x86_64.egg/aiohttp/web_app.py", line 458, in _handle Jan 13 22:28:31 dev 2e5815763538[1008]: resp = await handler(request) Jan 13 22:28:31 dev 2e5815763538[1008]: File "/app/aircon/query_handlers.py", line 116, in queue_command_handler Jan 13 22:28:31 dev 2e5815763538[1008]: raise web.HTTPBadRequest(f'Failed to queue command:\n{ex!r}') Jan 13 22:28:31 dev 2e5815763538[1008]: TypeError: init() takes 1 positional argument but 2 were given Jan 13 22:28:31 dev 2e5815763538[1008]: I0113 17:28:31.474 web_log.py:233] 192.168.0.168 [13/Jan/2021:22:28:31 +0000] "GET /hisense/command?property=switch&value=ON HTTP/1.1" 500 244 "-" "curl/7.68.0"

acansmart avatar Jan 13 '21 22:01 acansmart

@deiger I put the logs in gist also.

https://gist.github.com/acansmart/852ace385b51715ec2677f1d9a140d9e

acansmart avatar Jan 13 '21 22:01 acansmart

OK, I hope I fixed that. Can you retry?

deiger avatar Jan 14 '21 10:01 deiger

Thanks it works now.

root@dev:/usr/share/AirCon# curl -ik 'http://192.168.0.168:8888/hisense/command?property=switch&value=OFF' HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 Content-Length: 22 Date: Thu, 14 Jan 2021 12:50:39 GMT Server: Python/3.8 aiohttp/3.7.3

{"queued_commands": 1}

But while starting the server, it gives the below prompt.

root@dev:/usr/share/AirCon# python3.8 -m aircon --log_level DEBUG run --port 8888 --type humidifier --config config_humidifier.json --mqtt_host localhost --mqtt_port 1883 --mqtt_client_id humidifier --mqtt_topic hisense_ac --mqtt_user user:passwd /usr/share/AirCon/aircon/aircon.py:252: SyntaxWarning: "is" with a literal. Did you mean "=="? if name == 't_temp_heatcold' and value is 'ON':

I am fairly new to Home Assistant, but with the new properties property=switch&value=OFF is it possible to control it from HA ? or does that support only predefined properties like t_power_on and others ?

acansmart avatar Jan 14 '21 12:01 acansmart

Fixed that one as well. It can be supported, but there is no predefined MQTT integration for Humidifiers, like there is for HVAC. I can define it as a switch, though that won't reflect most of the data available from the humidifier.

deiger avatar Jan 14 '21 13:01 deiger

I still get the same error on version 0.3.14, what am I doing wrong?

E0723 10:19:55.124 query_handlers.py:119] Failed to queue command. Traceback (most recent call last): File "/app/aircon/query_handlers.py", line 117, in queue_command_handler device.queue_command(request.query['property'], request.query['value']) File "/app/aircon/aircon.py", line 153, in queue_command if self._properties.get_read_only(name): File "/app/aircon/properties.py", line 160, in get_read_only return cls._get_metadata(attr)['read_only'] File "/app/aircon/properties.py", line 144, in _get_metadata return cls.dataclass_fields[attr].metadata KeyError: 't_power' E0723 10:19:55.126 web_protocol.py:393] Error handling request Traceback (most recent call last): File "/app/aircon/query_handlers.py", line 117, in queue_command_handler device.queue_command(request.query['property'], request.query['value']) File "/app/aircon/aircon.py", line 153, in queue_command if self._properties.get_read_only(name): File "/app/aircon/properties.py", line 160, in get_read_only return cls._get_metadata(attr)['read_only'] File "/app/aircon/properties.py", line 144, in _get_metadata return cls.dataclass_fields[attr].metadata KeyError: 't_power'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/aiohttp-3.7.4-py3.10-linux-x86_64.egg/aiohttp/web_protocol.py", line 422, in _handle_request resp = await self._request_handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp-3.7.4-py3.10-linux-x86_64.egg/aiohttp/web_app.py", line 499, in _handle resp = await handler(request) File "/app/aircon/query_handlers.py", line 120, in queue_command_handler raise web.HTTPBadRequest(f'Failed to queue command:\n{ex!r}') TypeError: HTTPException.init() takes 1 positional argument but 2 were given I0723 10:19:55.129 web_log.py:206] 127.0.0.1 [23/Jul/2023:10:19:55 +0000] "GET /hisense/command?property=t_power&value=ON HTTP/1.1" 500 245 "-" "curl/7.68.0"

janv67 avatar Jul 23 '23 10:07 janv67