home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.55k stars 29.47k forks source link

Homekit_controller: Update for cover.garage_door fails: TypeError: can't concat bool to bytearray #20763

Closed rudgr closed 5 years ago

rudgr commented 5 years ago

Home Assistant release with the issue: 0.8.3

Last working Home Assistant release (if known): unknown

Operating environment (Hass.io/Docker/Windows/etc.): Hass.io/Raspberry Pi 3 Model B

Component/platform: https://www.home-assistant.io/components/homekit_controller/

Description of problem:

Every now and then errors, like the one reported below, keep appearing in home-assistant log. Sometimes my homekit enabled garage door keeps functioning, sometimes it looks like the home-assistant UI Cover state gets out of sync with the actual state of the garage door (and therefore open/close commands don't work anymore). Usually, restart of home-assistant "fixes" the errors from log, but after some time they start appearing again.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

# Discover some devices automatically
discovery:
  enable:
    - homekit

Traceback (if applicable):

Tue Feb 05 2019 14:53:13 GMT+0100 (Central European Standard Time)

Update for cover.garage_door fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 204, in update
    data = pairing.list_accessories_and_characteristics()
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 273, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 573, in get
    return self.sec_http.get(url)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 65, in get
    return self._handle_request(data)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 89, in _handle_request
    return self._read_response()
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 154, in _read_response
    response.parse(decrypted)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/response.py", line 38, in parse
    self._raw_response += part
TypeError: can't concat bool to bytearray

Additional information: NA

sgrimm-sg commented 5 years ago

Seeing the same behavior with motorized blinds, so this isn't specific to garage doors. My HomeKit device is a VELUX Active Gateway (model KIX 300).

sgrimm-sg commented 5 years ago

Looks like this is https://github.com/jlusiardi/homekit_python/issues/89

Jc2k commented 5 years ago

Hi Guys

The good news is this is a dupe of #20760, and that error should hopefully not occur in the just released 0.87 tag.

Possible bad news - if you upgrade and still have issues theres a good chance its #20800 and the fix for that is waiting to be reviewed + merged.

If you have any other homekit_controller problems and i'm not tagged in the GH issue already, feel free to @ me.

rudgr commented 5 years ago

great, will give it a try, tx!

rudgr commented 5 years ago

updated to home assistant 0.87.0, error seems gone (for the moment at least), but now my Cover UI element displays a warning/error:

entity not available cover.garage_door

image

Jc2k commented 5 years ago

Any exceptions in your logs? There is a known regression that should be fixed in 0.87.1 that is probably what this is but if you post the exception I can check.

Is there some way to contact you directly? I’d like to capture some logs to help add more realistic tests for this component and don’t want to litter github.

rudgr commented 5 years ago

tx for the reply @Jc2k

deps/lib/python3.6/site-packages/homekit/protocol/init.py (ERROR)

Sun Feb 10 2019 18:26:35 GMT+0100 (Central European Standard Time)
Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 362, in discovery_dispatch
    device = HKDevice(hass, host, port, model, hkid, config_num, config)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 98, in __init__
    self.accessory_setup()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 112, in accessory_setup
    data = self.pairing.list_accessories_and_characteristics()
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 272, in list_accessories_and_characteristics
    self.session = Session(self.pairing_data)
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 604, in __init__
    c2a_key, a2c_key = get_session_keys(conn, pairing_data)
  File "/config/deps/lib/python3.6/site-packages/homekit/protocol/__init__.py", line 247, in get_session_keys
    ios_key = x25519.X25519PrivateKey.generate()
  File "/usr/local/lib/python3.6/site-packages/cryptography/hazmat/primitives/asymmetric/x25519.py", line 39, in generate
    _Reasons.UNSUPPORTED_EXCHANGE_ALGORITHM
cryptography.exceptions.UnsupportedAlgorithm: X25519 is not supported by this version of OpenSSL.
Jc2k commented 5 years ago

Argh no anything but that...

HASS.io uses a version of OpenSSL that is too old and busted for the version of homekit that has the fixes in, and we are stuck until the HASS.io team switch from Alpine 3.8 to 3.9.

(I’m just a user, but have raised a HASS.io ticket and asked on discord. It will happen but not clear when yet. But this has bitten a bunch of users so I’m going to see if I can come up with a workaround in the mean time).

rudgr commented 5 years ago

haha, ok, tx for raising the ticket!

rudgr commented 5 years ago

FYI: updating to home assistant 0.87.1 did indeed not fix this issue.

https://github.com/home-assistant/hassio/issues/903 is the hass.io issue you are referring to?

Jc2k commented 5 years ago

Indeed it is

Jc2k commented 5 years ago

@rudgr I just saw a PR land in hass.io that might be related. Hopefully nearly there with this issue!

Jc2k commented 5 years ago

The UnsupportedAlgorithm exception should be gone for HASS.io users now 0.88.0 is out - AIUI HASS.io has moved to Alpine 3.9. See 903 and 914, between this and the earlier fix for connection dropouts this issue should now be resolved.

🎉

rudgr commented 5 years ago

ah great, will test and let you know ;-)

rudgr commented 5 years ago

Tested and seems to work, Tx! :)