question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't concat bool to bytearray

See original GitHub issue

With Home Assistant I had added a Xiaomi Bedside Lamp 2 through Homekit Controller. When I want to control the light I get the following errors:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/websocket_api/commands.py", line 148, in handle_call_service
    connection.context(msg))
  File "/usr/local/lib/python3.7/site-packages/homeassistant/core.py", line 1133, in async_call
    self._execute_service(handler, service_call))
  File "/usr/local/lib/python3.7/site-packages/homeassistant/core.py", line 1155, in _execute_service
    await handler.func(service_call)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_component.py", line 188, in handle_service
    self._platforms.values(), func, call, service_name
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 278, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 292, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/homekit_controller/light.py", line 137, in turn_off
    self.put_characteristics(characteristics)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/homekit_controller/__init__.py", line 310, in put_characteristics
    self._accessory.pairing.put_characteristics(chars)
  File "/usr/local/lib/python3.7/site-packages/homekit/controller.py", line 439, in put_characteristics
    response = self.session.put('/characteristics', data)
  File "/usr/local/lib/python3.7/site-packages/homekit/controller.py", line 647, in put
    return self.sec_http.put(url, body, content_type)
  File "/usr/local/lib/python3.7/site-packages/homekit/http_impl/secure_http.py", line 72, in put
    return self._handle_request(data)
  File "/usr/local/lib/python3.7/site-packages/homekit/http_impl/secure_http.py", line 92, in _handle_request
    return self._read_response()
  File "/usr/local/lib/python3.7/site-packages/homekit/http_impl/secure_http.py", line 159, in _read_response
    response.parse(decrypted)
  File "/usr/local/lib/python3.7/site-packages/homekit/http_impl/response.py", line 38, in parse
    self._raw_response += part
TypeError: can't concat bool to bytearray
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 220, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 348, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/homekit_controller/__init__.py", line 262, in update
    new_values_dict = pairing.get_characteristics(self._chars_to_poll)
  File "/usr/local/lib/python3.7/site-packages/homekit/controller.py", line 375, in get_characteristics
    response = self.session.get(url)
  File "/usr/local/lib/python3.7/site-packages/homekit/controller.py", line 637, in get
    return self.sec_http.get(url)
  File "/usr/local/lib/python3.7/site-packages/homekit/http_impl/secure_http.py", line 66, in get
    return self._handle_request(data)
  File "/usr/local/lib/python3.7/site-packages/homekit/http_impl/secure_http.py", line 92, in _handle_request
    return self._read_response()
  File "/usr/local/lib/python3.7/site-packages/homekit/http_impl/secure_http.py", line 159, in _read_response
    response.parse(decrypted)
  File "/usr/local/lib/python3.7/site-packages/homekit/http_impl/response.py", line 38, in parse
    self._raw_response += part
TypeError: can't concat bool to bytearray

I have already posted an issue on the Home Assistant Github page, https://github.com/home-assistant/home-assistant/issues/21793. As far as I can read Traceback calls it looks like an issue with the Homekit Python module.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rgruyterscommented, Mar 11, 2019

How do I force home assistant to require 0.12.3?

You have to copy the component from homassistant/components/homekit_controller folder and copy it to custom_components folder. Update the REQUIREMENTS statement in __init__.py, and restart your environment.

0reactions
jlusiardicommented, Mar 11, 2019

Hi @evisser4,

since this is not an issue with homekit_python I can’t really help you. Perhaps you should ask the folks from homeassistant in their project?

Joachim

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: can't concat bytes to int - Stack Overflow
You are trying to concatenate the result of file.read() with the result of round(time.time() * 1000)) , which is an integer.
Read more >
[Solved]Exception typeerror: can't concat int to bytes in Python
My code throw an exception typeerror: can't concat int to bytes in Python 3.x when I was trying to concat some bytes with...
Read more >
TypeError: can't concat str to bytes in Python | bobbyhadz
The Python "TypeError: can't concat str to bytes" occurs when we try to concatenate a bytes object and a string. To solve the...
Read more >
2. Built-in Functions - Python 3.7.0a2 documentation
The bool class is a subclass of int (see Numeric Types — int, float, complex). ... See also Binary Sequence Types — bytes,...
Read more >
Built-in Types — Python 3.11.1 documentation
Operations and built-in functions that have a Boolean result always return ... Instances of a class cannot be ordered with respect to other...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found