rgerganov / py-air-control

Command line app for controlling Philips air purifiers
MIT License
266 stars 53 forks source link

Connect to AC2939? #65

Closed michaelschefczyk closed 4 years ago

michaelschefczyk commented 4 years ago

Dear All,

Trying to connect to an AC2939, I did install the code from this repository and https://github.com/Tanganelli/CoAPthon3@89d5173 on a raspi running fhem. I am able to ping my AC2939, but when I curl it (http without specifying a port), it does return "Connection refused."

Similarly, your code does return this:

root@fhems10:~# airctrl --ipaddr 192.168.7.114 Exchanging secret key with the device ... Traceback (most recent call last): File "/usr/lib/python3.7/urllib/request.py", line 1324, in do_open encode_chunked=req.has_header('Transfer-encoding')) File "/usr/lib/python3.7/http/client.py", line 1244, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/lib/python3.7/http/client.py", line 1290, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/lib/python3.7/http/client.py", line 1239, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/lib/python3.7/http/client.py", line 1026, in _send_output self.send(msg) File "/usr/lib/python3.7/http/client.py", line 966, in send self.connect() File "/usr/lib/python3.7/http/client.py", line 938, in connect (self.host,self.port), self.timeout, self.source_address) File "/usr/lib/python3.7/socket.py", line 727, in create_connection raise err File "/usr/lib/python3.7/socket.py", line 716, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/bin/airctrl", line 10, in sys.exit(main()) File "/usr/local/lib/python3.7/dist-packages/pyairctrl/airctrl.py", line 444, in main c = HTTPAirCli(device["ip"]) File "/usr/local/lib/python3.7/dist-packages/pyairctrl/airctrl.py", line 100, in init self._client = HTTPAirClient(host, debug) File "/usr/local/lib/python3.7/dist-packages/pyairctrl/http_client.py", line 108, in init self.load_key() File "/usr/local/lib/python3.7/dist-packages/pyairctrl/http_client.py", line 156, in load_key self._get_key() File "/usr/local/lib/python3.7/dist-packages/pyairctrl/http_client.py", line 119, in _get_key with urllib.request.urlopen(req) as response: File "/usr/lib/python3.7/urllib/request.py", line 222, in urlopen return opener.open(url, data, timeout) File "/usr/lib/python3.7/urllib/request.py", line 525, in open response = self._open(req, data) File "/usr/lib/python3.7/urllib/request.py", line 543, in _open '_open', req) File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain result = func(*args) File "/usr/lib/python3.7/urllib/request.py", line 1352, in http_open return self.do_open(http.client.HTTPConnection, req) File "/usr/lib/python3.7/urllib/request.py", line 1326, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [Errno 111] Connection refused> root@fhems10:~#

May I request any advice regarding what this means, please? Is the AC2939 incompatible?

Regards,

Michael Schefczyk

rgerganov commented 4 years ago

Try switching the protocol to coap or plain_coap:

# airctrl --ipaddr 192.168.7.114 --protocol coap
# airctrl --ipaddr 192.168.7.114 --protocol plain_coap
michaelschefczyk commented 4 years ago

Thank you very much --protocol coap does work!