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
73.17k stars 30.57k forks source link

[mitemp_bt] Exception found for Xiaomi BLE Temperature sensor #33889

Closed duhow closed 4 years ago

duhow commented 4 years ago

The problem

Just found an exception while starting Home Assistant, regarding this component. Using Intel Wireless 3168-AC + Bluetooth 4.2 M2 embedded.

Environment

Problem-relevant configuration.yaml

device_tracker:
  - platform: bluetooth_tracker
  - platform: bluetooth_le_tracker

sensors:
- platform: mitemp_bt
  mac: '58:2D:34:00:00:00'
  name: Termometro Cocina
  force_update: true
  timeout: 12
  retries: 3
  median: 2

Traceback/Error logs

2020-04-09 12:55:41 DEBUG (SyncWorker_0) [mitemp_bt.mitemp_bt_poller] Filling cache with new sensor data.
2020-04-09 12:55:42 DEBUG (SyncWorker_0) [mitemp_bt.mitemp_bt_poller] Received result for handle 36: b'00.00.66'
--- Logging error ---
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/logging/__init__.py", line 1025, in emit
    msg = self.format(record)
  File "/usr/local/lib/python3.7/logging/__init__.py", line 869, in format
    return fmt.format(record)
  File "/usr/local/lib/python3.7/site-packages/colorlog/colorlog.py", line 123, in format
    message = super(ColoredFormatter, self).format(record)
  File "/usr/local/lib/python3.7/logging/__init__.py", line 608, in format
    record.message = record.getMessage()
  File "/usr/local/lib/python3.7/logging/__init__.py", line 369, in getMessage
    msg = msg % self.args
TypeError: %d format: a number is required, not bytes
Call stack:
  File "/usr/local/lib/python3.7/threading.py", line 890, in _bootstrap
    self._bootstrap_inner()
  File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 80, in _worker
    work_item.run()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/mitemp_bt/sensor.py", line 157, in update
    data = self.poller.parameter_value(self.parameter)
  File "/usr/local/lib/python3.7/site-packages/mitemp_bt/mitemp_bt_poller.py", line 126, in parameter_value
    self.fill_cache()
  File "/usr/local/lib/python3.7/site-packages/mitemp_bt/mitemp_bt_poller.py", line 59, in fill_cache
    self.firmware_version()
  File "/usr/local/lib/python3.7/site-packages/mitemp_bt/mitemp_bt_poller.py", line 96, in firmware_version
    _HANDLE_READ_BATTERY_LEVEL, res_battery)
Message: 'Received result for handle %s: %d'
Arguments: (24, b'8')
--- Logging error ---
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/logging/__init__.py", line 1025, in emit
    msg = self.format(record)
  File "/usr/local/lib/python3.7/logging/__init__.py", line 869, in format
    return fmt.format(record)
  File "/usr/local/lib/python3.7/logging/__init__.py", line 608, in format
    record.message = record.getMessage()
  File "/usr/local/lib/python3.7/logging/__init__.py", line 369, in getMessage
    msg = msg % self.args
TypeError: %d format: a number is required, not bytes
Call stack:
  File "/usr/local/lib/python3.7/threading.py", line 890, in _bootstrap
    self._bootstrap_inner()
  File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 80, in _worker
    work_item.run()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/mitemp_bt/sensor.py", line 157, in update
    data = self.poller.parameter_value(self.parameter)
  File "/usr/local/lib/python3.7/site-packages/mitemp_bt/mitemp_bt_poller.py", line 126, in parameter_value
    self.fill_cache()
  File "/usr/local/lib/python3.7/site-packages/mitemp_bt/mitemp_bt_poller.py", line 59, in fill_cache
    self.firmware_version()
  File "/usr/local/lib/python3.7/site-packages/mitemp_bt/mitemp_bt_poller.py", line 96, in firmware_version
    _HANDLE_READ_BATTERY_LEVEL, res_battery)
Message: 'Received result for handle %s: %d'
Arguments: (24, b'8')
2020-04-09 12:55:43 DEBUG (SyncWorker_0) [mitemp_bt.mitemp_bt_poller] Received new data from sensor: Temp=23.8, Humidity=54.5
2020-04-09 12:55:43 DEBUG (SyncWorker_3) [mitemp_bt.mitemp_bt_poller] Using cache (0:00:00.009100 < 0:05:00)

Additional information

stale[bot] commented 4 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.