Open quadcube opened 5 years ago
Are you able to try with this PR at all?
https://github.com/ikalchev/HAP-python/pull/198/files
The homekit client in homeassistant (which is not pyhap) sees pyhap as a HTTP/1.0 server and without this change and closes the TCP connection part way through pairing. The official apple client is more forgiving and forces HTTP/1.1 regardless of what the server says.
Note that homeassistant has other known issues with homebridge, but you should go to the homeassistant issue tracker if you have problems with that.
Are you able to try with this PR at all?
https://github.com/ikalchev/HAP-python/pull/198/files
The homekit client in homeassistant (which is not pyhap) sees pyhap as a HTTP/1.0 server and without this change and closes the TCP connection part way through pairing. The official apple client is more forgiving and forces HTTP/1.1 regardless of what the server says.
will test it now.. give me a couple of minutes
Seems like setting it to HTTP/1.1 is okay since the log did not show the error caused by the closed TCP session. However, I wasn't able to complete the pairing due to zeroconf non-unique name exception. Tried removing the accessory.state file and restarted the device but still it wasn't able to resolve the zeroconf issues.
@quadcube Is everything working as expected with 0.110?
Setup both HAP-Python (2.6.0) and homeassistant (0.99.3) on my Mac mini. homeassistant was unable to pair with the HAP-Python bridge (Mac mini Bridge).
homeassistant was able to pair with Homebridge though.
Error from HAP-Python `Or enter this code in your HomeKit app on your iOS device: 706-85-442 [hap_server] Got connection with ('192.168.88.196', 50298). [hap_server] 192.168.88.196 - "POST /pair-setup HTTP/1.1" 200 - [hap_server] Got connection with ('192.168.88.196', 50337). [hap_server] 192.168.88.196 - "POST /pair-setup HTTP/1.1" 200 - [hap_server] Got connection with ('192.168.88.196', 50338). [accessory_driver] Paired with 7bdb735e-7ac6-4042-b1c9-a6a633dcf16a. [hap_server] 192.168.88.196 - "POST /pair-setup HTTP/1.1" 200 - [hap_server] Got connection with ('192.168.88.196', 50341). [hap_server] 192.168.88.196 - "POST /pair-verify HTTP/1.1" 200 - [hap_server] Got connection with ('192.168.88.196', 50342).
Exception happened during processing of request from ('192.168.88.196', 50342) Traceback (most recent call last): File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 650, in process_request_thread self.finish_request(request, client_address) File "/usr/local/lib/python3.7/site-packages/pyhap/hap_server.py", line 853, in finish_request self, self.accessory_handler) File "/usr/local/lib/python3.7/site-packages/pyhap/hap_server.py", line 143, in init super(HAPServerHandler, self).init(sock, client_addr, server) File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 720, in init self.handle() File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/server.py", line 426, in handle self.handle_one_request() File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/server.py", line 414, in handle_one_request method() File "/usr/local/lib/python3.7/site-packages/pyhap/hap_server.py", line 204, in dispatch getattr(self, self.HANDLERS[self.command][path])() File "/usr/local/lib/python3.7/site-packages/pyhap/hap_server.py", line 389, in handle_pair_verify self._pair_verify_two(tlv_objects) File "/usr/local/lib/python3.7/site-packages/pyhap/hap_server.py", line 439, in _pair_verify_two cipher = CHACHA20_POLY1305(self.enc_context["pre_session_key"], "python") TypeError: 'NoneType' object is not subscriptable
[hap_server] Got connection with ('192.168.88.196', 50345). [hap_server] 192.168.88.196 - "POST /pair-verify HTTP/1.1" 200 - [hap_server] Got connection with ('192.168.88.196', 50346).
Exception happened during processing of request from ('192.168.88.196', 50346) Traceback (most recent call last): File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 650, in process_request_thread self.finish_request(request, client_address) File "/usr/local/lib/python3.7/site-packages/pyhap/hap_server.py", line 853, in finish_request self, self.accessory_handler) File "/usr/local/lib/python3.7/site-packages/pyhap/hap_server.py", line 143, in init super(HAPServerHandler, self).init(sock, client_addr, server) File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 720, in init self.handle() File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/server.py", line 426, in handle self.handle_one_request() File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/server.py", line 414, in handle_one_request method() File "/usr/local/lib/python3.7/site-packages/pyhap/hap_server.py", line 204, in dispatch getattr(self, self.HANDLERS[self.command][path])() File "/usr/local/lib/python3.7/site-packages/pyhap/hap_server.py", line 389, in handle_pair_verify self._pair_verify_two(tlv_objects) File "/usr/local/lib/python3.7/site-packages/pyhap/hap_server.py", line 439, in _pair_verify_two cipher = CHACHA20_POLY1305(self.enc_context["pre_session_key"], "python") TypeError: 'NoneType' object is not subscriptable ---------------------------------------`
Error from Hass.io
2019-09-29 11:52:48 INFO (SyncWorker_5) [homeassistant.util.package] Attempting install of homekit[IP]==0.15.0 2019-09-29 11:53:31 ERROR (MainThread) [homeassistant.components.homekit_controller.config_flow] Pairing attempt failed with an unhandled exception Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/homeassistant/components/homekit_controller/config_flow.py", line 251, in async_step_pair return await self._entry_from_accessory(pairing) File "/usr/local/lib/python3.7/site-packages/homeassistant/components/homekit_controller/config_flow.py", line 324, in _entry_from_accessory pairing.list_accessories_and_characteristics File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/Users/quadcube/.homeassistant/deps/lib/python/site-packages/homekit/controller/ip_implementation.py", line 73, in list_accessories_and_characteristics self.session = IpSession(self.pairing_data) File "/Users/quadcube/.homeassistant/deps/lib/python/site-packages/homekit/controller/ip_implementation.py", line 441, in __init__ c2a_key, a2c_key = get_session_keys(conn, pairing_data, write_fun) File "/Users/quadcube/.homeassistant/deps/lib/python/site-packages/homekit/protocol/__init__.py", line 392, in get_session_keys response_tlv = write_fun(request_tlv, step3_expectations) File "/Users/quadcube/.homeassistant/deps/lib/python/site-packages/homekit/protocol/__init__.py", line 80, in write_http resp = connection.getresponse() File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1321, in getresponse response.begin() File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 296, in begin version, status, reason = self._read_status() File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 265, in _read_status raise RemoteDisconnected("Remote end closed connection without" http.client.RemoteDisconnected: Remote end closed connection without response 2019-09-29 11:53:31 ERROR (MainThread) [homeassistant.components.homekit_controller.config_flow] Pairing attempt failed with an unhandled exception Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/homeassistant/components/homekit_controller/config_flow.py", line 278, in async_step_pair start_pairing, self.hkid, self.hkid File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/Users/quadcube/.homeassistant/deps/lib/python/site-packages/homekit/controller/controller.py", line 374, in start_pairing raise AlreadyPairedError('Alias "{a}" is already paired.'.format(a=alias)) homekit.exceptions.AlreadyPairedError: Alias "5E:CE:4B:EC:44:F0" is already paired.