ble2mqtt icon indicating copy to clipboard operation
ble2mqtt copied to clipboard

LifeControl MCLH-09 (type: mclh09) problem

Open lehanspb opened this issue 11 months ago • 1 comments

Only at the first launch, ble2mqtt gave readings from the MCLH-09 sensor. Nothing further.

What am I doing wrong?

I've also tried to pair via bluetoothctl (pair is ok). Then unpair and remove. Nothing...

2024-03-03 18:12:53 ERROR: [LifeControl_kitchen-soil] connection problem, attempts=1
2024-03-03 18:13:12 INFO: Connected to 00:1B:DC:4B:16:89
2024-03-03 18:13:12 ERROR: Cannot connect to device LifeControl_MCLH-09_kitchen-soil
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/ble2mqtt/devices/base.py", line 145, in _read_with_timeout
    result = await aio.wait_for(
             ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/tasks.py", line 479, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/bleak/__init__.py", line 711, in read_gatt_char
    return await self._backend.read_gatt_char(char_specifier, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/bleak/backends/bluezdbus/client.py", line 728, in read_gatt_char
    raise BleakError(
bleak.exc.BleakError: Characteristic with UUID 00002a26-0000-1000-8000-00805f9b34fb could not be found!
2024-03-03 18:13:12 ERROR: Cannot connect to device LifeControl_MCLH-09_kitchen-soil
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/ble2mqtt/devices/base.py", line 145, in _read_with_timeout
    result = await aio.wait_for(
             ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/tasks.py", line 479, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/bleak/__init__.py", line 711, in read_gatt_char
    return await self._backend.read_gatt_char(char_specifier, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/bleak/backends/bluezdbus/client.py", line 728, in read_gatt_char
    raise BleakError(
bleak.exc.BleakError: Characteristic with UUID 00002a19-0000-1000-8000-00805f9b34fb could not be found!
2024-03-03 18:13:12 ERROR: Cannot connect to device LifeControl_MCLH-09_kitchen-soil
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/ble2mqtt/devices/base.py", line 145, in _read_with_timeout
    result = await aio.wait_for(
             ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/tasks.py", line 479, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/bleak/__init__.py", line 711, in read_gatt_char
    return await self._backend.read_gatt_char(char_specifier, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/bleak/backends/bluezdbus/client.py", line 728, in read_gatt_char
    raise BleakError(
bleak.exc.BleakError: Characteristic with UUID 55482920-eacb-11e3-918a-0002a5d5c51b could not be found!
2024-03-03 18:13:12 ERROR: LifeControl_MCLH-09_kitchen-soil problem with reading values
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/ble2mqtt/devices/flower_mclh09.py", line 135, in do_active_loop
    await aio.wait_for(self.read_state(), 5)
  File "/usr/lib/python3.11/asyncio/tasks.py", line 479, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/ble2mqtt/devices/flower_mclh09.py", line 126, in read_state
    self._state = SensorState.from_data(data, battery)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/ble2mqtt/devices/flower_mclh09.py", line 69, in from_data
    temp_raw, moisture_raw, illuminance_raw = struct.unpack('<HxxHH', data)
                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: a bytes-like object is required, not 'NoneType'
2024-03-03 18:14:50 ERROR: [LifeControl_MCLH-09_kitchen-soil] connection problem, attempts=4
2024-03-03 18:14:54 WARNING: Error while connecting to LifeControl_MCLH-09_kitchen-soil, failed to discover services, device disconnected BleakError('failed to discover services, device disconnected'), failure_count=5
2024-03-03 18:14:54 WARNING: Restarting bluetoothd...
Restarting bluetooth (via systemctl): bluetooth.service.
2024-03-03 18:15:02 WARNING: Restarting bluetoothd finished
2024-03-03 18:15:06 ERROR: [org.bluez.Error.NotReady] Resource Not Ready
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/ble2mqtt/ble2mqtt.py", line 214, in scan_devices_task
    await scanner.stop()
  File "/usr/local/lib/python3.11/dist-packages/bleak/__init__.py", line 202, in stop
    await self._backend.stop()
  File "/usr/local/lib/python3.11/dist-packages/bleak/backends/bluezdbus/scanner.py", line 197, in stop
    await stop()
  File "/usr/local/lib/python3.11/dist-packages/bleak/backends/bluezdbus/manager.py", line 454, in stop
    assert_reply(reply)
  File "/usr/local/lib/python3.11/dist-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.NotReady] Resource Not Ready
2024-03-03 18:15:12 ERROR: [LifeControl_MCLH-09_kitchen-soil] connection problem, attempts=5
2024-03-03 18:15:12 WARNING: Error while connecting to LifeControl_MCLH-09_kitchen-soil, failed to discover services, device disconnected BleakError('failed to discover services, device disconnected'), failure_count=1

lehanspb avatar Mar 03 '24 16:03 lehanspb

Pairing is not required. But it is weird that it can read in the beginning and not later on. You can use nRF Connect mobile app to connect to the sensor and verify that required characteristic is still there. Only one char is used for the sensor: https://github.com/devbis/ble2mqtt/blob/main/ble2mqtt/devices/flower_mclh09.py#L81

devbis avatar Mar 08 '24 07:03 devbis