devbis / ble2mqtt

Bluetooth to MQTT bridge, add your bluetooth-capable (including controllable) devices to your smart home
MIT License
151 stars 27 forks source link

Redmond Kettle G2XX auth problem #8

Closed MSITETOP closed 3 years ago

MSITETOP commented 3 years ago

Hi, I try to connect , but it crashes with an error

INFO:ble2mqtt.ble2mqtt:Connected to localhost
INFO:ble2mqtt.devices.base:Connected to DE:39:B7:1D:85:42
INFO:ble2mqtt.protocols.redmond:Enable BLE notifications from [DE:39:B7:1D:85:42]
ERROR:ble2mqtt.ble2mqtt:Root task has raised an exception
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/ble2mqtt/ble2mqtt.py", line 556, in _run_device_tasks
  File "/usr/lib/python3.7/site-packages/ble2mqtt/ble2mqtt.py", line 402, in manage_device
  File "/usr/lib/python3.7/site-packages/ble2mqtt/devices/kettle_redmond.py", line 80, in get_device_data
  File "/usr/lib/python3.7/site-packages/ble2mqtt/protocols/redmond.py", line 225, in login
  File "/usr/lib/python3.7/site-packages/ble2mqtt/protocols/redmond.py", line 166, in _check_success
ble2mqtt.protocols.redmond.RedmondError: Not logged in
INFO:ble2mqtt.ble2mqtt:Disconnected
Traceback (most recent call last):
  File "/usr/bin/ble2mqtt", line 11, in <module>
    load_entry_point('ble2mqtt==0.1.0a11', 'console_scripts', 'ble2mqtt')()
  File "/usr/lib/python3.7/site-packages/ble2mqtt/__main__.py", line 61, in main
  File "/usr/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
  File "/usr/lib/python3.7/site-packages/ble2mqtt/ble2mqtt.py", line 115, in close
  File "/usr/lib/python3.7/site-packages/ble2mqtt/ble2mqtt.py", line 107, in stop_task
  File "/usr/lib/python3.7/site-packages/ble2mqtt/ble2mqtt.py", line 556, in _run_device_tasks
  File "/usr/lib/python3.7/site-packages/ble2mqtt/ble2mqtt.py", line 402, in manage_device
  File "/usr/lib/python3.7/site-packages/ble2mqtt/devices/kettle_redmond.py", line 80, in get_device_data
  File "/usr/lib/python3.7/site-packages/ble2mqtt/protocols/redmond.py", line 225, in login
  File "/usr/lib/python3.7/site-packages/ble2mqtt/protocols/redmond.py", line 166, in _check_success
ble2mqtt.protocols.redmond.RedmondError: Not logged in
devbis commented 3 years ago

Could you try to put your kettle in the pairing mode? Ble2mqtt has to set a key to access the kettle to control it.

MSITETOP commented 3 years ago

Yes, I do ` INFO:ble2mqtt.ble2mqtt:Connected to localhost INFO:ble2mqtt.devices.base:Connected to de:39:b7:1d:85:42 INFO:ble2mqtt.protocols.redmond:Enable BLE notifications from [de:39:b7:1d:85:42] INFO:ble2mqtt.devices.base:Client de:39:b7:1d:85:42 disconnected, device=Redmond_de39b71d8542 ERROR:ble2mqtt.ble2mqtt:Cannot get initial info device=Redmond_de39b71d8542 Traceback (most recent call last): File "/usr/lib/python3.7/site-packages/ble2mqtt/ble2mqtt.py", line 402, in manage_device File "/usr/lib/python3.7/site-packages/ble2mqtt/devices/kettle_redmond.py", line 80, in get_device_data File "/usr/lib/python3.7/site-packages/ble2mqtt/protocols/redmond.py", line 224, in login File "/usr/lib/python3.7/site-packages/ble2mqtt/protocols/redmond.py", line 213, in send_command File "/usr/lib/python3.7/asyncio/tasks.py", line 449, in wait_for concurrent.futures._base.TimeoutError INFO:ble2mqtt.devices.base:Connected to de:39:b7:1d:85:42 INFO:ble2mqtt.protocols.redmond:Enable BLE notifications from [de:39:b7:1d:85:42] ERROR:ble2mqtt.ble2mqtt:Root task has raised an exception Traceback (most recent call last): File "/usr/lib/python3.7/site-packages/ble2mqtt/ble2mqtt.py", line 556, in _run_device_tasks File "/usr/lib/python3.7/site-packages/ble2mqtt/ble2mqtt.py", line 402, in manage_device File "/usr/lib/python3.7/site-packages/ble2mqtt/devices/kettle_redmond.py", line 80, in get_device_data File "/usr/lib/python3.7/site-packages/ble2mqtt/protocols/redmond.py", line 225, in login File "/usr/lib/python3.7/site-packages/ble2mqtt/protocols/redmond.py", line 166, in _check_success ble2mqtt.protocols.redmond.RedmondError: Not logged in INFO:ble2mqtt.ble2mqtt:Disconnected Traceback (most recent call last): File "/usr/bin/ble2mqtt", line 11, in load_entry_point('ble2mqtt==0.1.0a11', 'console_scripts', 'ble2mqtt')() File "/usr/lib/python3.7/site-packages/ble2mqtt/main.py", line 61, in main File "/usr/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete File "/usr/lib/python3.7/site-packages/ble2mqtt/ble2mqtt.py", line 115, in close File "/usr/lib/python3.7/site-packages/ble2mqtt/ble2mqtt.py", line 107, in stop_task File "/usr/lib/python3.7/site-packages/ble2mqtt/ble2mqtt.py", line 556, in _run_device_tasks File "/usr/lib/python3.7/site-packages/ble2mqtt/ble2mqtt.py", line 402, in manage_device File "/usr/lib/python3.7/site-packages/ble2mqtt/devices/kettle_redmond.py", line 80, in get_device_data File "/usr/lib/python3.7/site-packages/ble2mqtt/protocols/redmond.py", line 225, in login File "/usr/lib/python3.7/site-packages/ble2mqtt/protocols/redmond.py", line 166, in _check_success ble2mqtt.protocols.redmond.RedmondError: Not logged in

`

devbis commented 3 years ago

What kettle model do you have?

MSITETOP commented 3 years ago

RK-201S

MSITETOP commented 3 years ago

This component on HA working https://github.com/mavrikkk/ha_kettler But I had to give it up. I switched from raspberry pi to xiaomi gateways (OpenWrt)

dack64 commented 3 years ago

same on redmond RK-216S

devbis commented 3 years ago

Is it possible that you use both software to connect to the kettle? "Not logged in" error means that the kettle doesn't accept your key on authorization. It can be (I assume) in case when it is not in pairing mode.

Maybe it is possible to extract the key(password) for the kettle from SkyKettle app or from HA component and add the parameter to ble2mqtt.json config.

dack64 commented 3 years ago

The kettle is in pairing mode. As soon as ble2mqtt connects to it, the pairing indicators go out and after a while an error appears that was dropped above. how should a config file with a password look like? I'll try to pull it out of the application

devbis commented 3 years ago

The entry with a kettle should be like

        {
            "address": "11:22:33:aa:bb:cc",
            "type": "redmond200",
            "key": "0011223344556677"
        },

Where key is 8 bytes, 16 characters in hex format

Another approach is to comment out the check for auth response in installed library in /usr/lib/...../ble2mqtt/protocols/redmond.py. Maybe it send 0 on successful authorization too. https://github.com/devbis/ble2mqtt/blob/2a16df4a2a85b8b614862f3e4155ab4a851f37be/ble2mqtt/protocols/redmond.py#L270

I made the integration based on my G214S kettle

MSITETOP commented 3 years ago

new problem

root@OpenWrt:~# ble2mqtt

INFO:ble2mqtt.ble2mqtt:Connected to localhost

INFO:ble2mqtt.devices.base:Connected to de:39:b7:1d:85:42

WARNING:ble2mqtt.ble2mqtt:Error while connecting to Redmond_RK-G201S_de39b71d8542, 'BleakClientBlueZDBus' object has no attribute '_properties' AttributeError("'BleakClientBlueZDBus'               object has no attribute '_properties'"), failure_count=1
devbis commented 3 years ago

Update to the latest version of ble2mqtt and bleak, please.

pip3 install -U ble2mqtt
MSITETOP commented 3 years ago

I'm using the latest version from github

devbis commented 3 years ago

What about the latest bleak version? pip3 install bleak==0.11.0

devbis commented 3 years ago

Can you please enable

"log_level": "DEBUG" in the config file and to reduce output comment out three lines: https://github.com/devbis/ble2mqtt/blob/30499b671c9dfee7516e7220807ab3241ee22c5d/ble2mqtt/ble2mqtt.py#L645-L646 https://github.com/devbis/ble2mqtt/blob/30499b671c9dfee7516e7220807ab3241ee22c5d/ble2mqtt/ble2mqtt.py#L654

It will print information that is transmitted in the log.

dack64 commented 3 years ago
root@OpenWrt:~# ble2mqtt
INFO:ble2mqtt.ble2mqtt:Connected to localhost
DEBUG:ble2mqtt.ble2mqtt:Wait for network interruptions...
DEBUG:ble2mqtt.ble2mqtt:Start managing device=Redmond_e22bb96f2995
DEBUG:ble2mqtt.ble2mqtt:[Redmond_e22bb96f2995] Check for lock
DEBUG:bleak.backends.bluezdbus.client:Connecting to device @ e2:2b:b9:6f:29:95 with hci0
DEBUG:bleak.backends.bluezdbus.scanner:cached devices: {'/org/bluez/hci0/dev_43_2A_F4_75_3F_A0': {'Address': '43:2A:F4:75:3F:A0', 'AddressType': 'random', 'Alias': '43-2A-F4-75-3F-A0', 'Paired': False, 'Trusted': False, 'Blocked': False, 'LegacyPairing': False, 'Connected': False, 'UUIDs': [], 'Adapter': '/org/bluez/hci0', 'ManufacturerData': {76: b'\x10\x05q\x1c\xf3o6'}, 'ServicesResolved': False}, '/org/bluez/hci0/dev_28_39_5E_26_99_38': {'Address': '28:39:5E:26:99:38', 'AddressType': 'public', 'Alias': '28-39-5E-26-99-38', 'Paired': False, 'Trusted': False, 'Blocked': False, 'LegacyPairing': False, 'Connected': False, 'UUIDs': [], 'Adapter': '/org/bluez/hci0', 'ManufacturerData': {117: b'B\x04\x01 O\x17\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}, 'ServicesResolved': False}, '/org/bluez/hci0/dev_9C_8C_6E_0F_DF_20': {'Address': '9C:8C:6E:0F:DF:20', 'AddressType': 'public', 'Alias': '9C-8C-6E-0F-DF-20', 'Paired': False, 'Trusted': False, 'Blocked': False, 'LegacyPairing': False, 'Connected': False, 'UUIDs': [], 'Adapter': '/org/bluez/hci0', 'ManufacturerData': {117: b'B\x04\x01\x01o\x9c\x8cn\x0f\xdf \x9e\x8cn\x0f\xdf\x1f$\xe6\x00\x00\x00\x00\x00'}, 'ServicesResolved': False}, '/org/bluez/hci0/dev_E2_2B_B9_6F_29_95': {'Address': 'E2:2B:B9:6F:29:95', 'AddressType': 'random', 'Name': 'RK-M216S', 'Alias': 'RK-M216S', 'Paired': False, 'Trusted': False, 'Blocked': False, 'LegacyPairing': False, 'Connected': False, 'UUIDs': ['00001800-0000-1000-8000-00805f9b34fb', '00001801-0000-1000-8000-00805f9b34fb', '0000180a-0000-1000-8000-00805f9b34fb', '6e400001-b5a3-f393-e0a9-e50e24dcca9e'], 'Adapter': '/org/bluez/hci0', 'ManufacturerData': {450: b'@\x00\x95)o\xb9+\xe2'}, 'ServicesResolved': False}}
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0): ['org.bluez.Adapter1', {'Discovering': <dbus_next.signature.Variant ('b', True)>}, []]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_E2_2B_B9_6F_29_95): ['org.bluez.Device1', {'RSSI': <dbus_next.signature.Variant ('n', -72)>}, []]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesAdded (/): ['/org/bluez/hci0/dev_09_46_8E_77_83_37', {'org.freedesktop.DBus.Introspectable': {}, 'org.bluez.Device1': {'Address': <dbus_next.signature.Variant ('s', 09:46:8E:77:83:37)>, 'AddressType': <dbus_next.signature.Variant ('s', random)>, 'Alias': <dbus_next.signature.Variant ('s', 09-46-8E-77-83-37)>, 'Paired': <dbus_next.signature.Variant ('b', False)>, 'Trusted': <dbus_next.signature.Variant ('b', False)>, 'Blocked': <dbus_next.signature.Variant ('b', False)>, 'LegacyPairing': <dbus_next.signature.Variant ('b', False)>, 'RSSI': <dbus_next.signature.Variant ('n', -94)>, 'Connected': <dbus_next.signature.Variant ('b', False)>, 'UUIDs': <dbus_next.signature.Variant ('as', [])>, 'Adapter': <dbus_next.signature.Variant ('o', /org/bluez/hci0)>, 'ManufacturerData': <dbus_next.signature.Variant ('a{qv}', {6: <dbus_next.signature.Variant ('ay', b'\x01\t \x02\xfb\n^dl\xc6r+\xcd\x9c+\xe4\x12gjn\x0eH9\x01z\xd7\r')>})>, 'ServicesResolved': <dbus_next.signature.Variant ('b', False)>}, 'org.freedesktop.DBus.Properties': {}}]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_09_46_8E_77_83_37): ['org.bluez.Device1', {}, ['RSSI']]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesRemoved (/): ['/org/bluez/hci0/dev_09_46_8E_77_83_37', ['org.freedesktop.DBus.Properties', 'org.freedesktop.DBus.Introspectable', 'org.bluez.Device1']]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0): ['org.bluez.Adapter1', {'Discovering': <dbus_next.signature.Variant ('b', False)>}, []]
DEBUG:bleak.backends.bluezdbus.scanner:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_E2_2B_B9_6F_29_95): ['org.bluez.Device1', {}, ['RSSI']]
DEBUG:bleak.backends.bluezdbus.client:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_E2_2B_B9_6F_29_95): ['org.bluez.Device1', {'Connected': <dbus_next.signature.Variant ('b', True)>}, []]
DEBUG:bleak.backends.bluezdbus.client:Connection successful (/org/bluez/hci0/dev_E2_2B_B9_6F_29_95)
DEBUG:bleak.backends.bluezdbus.client:Waiting for ServicesResolved (/org/bluez/hci0/dev_E2_2B_B9_6F_29_95)
DEBUG:bleak.backends.bluezdbus.client:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_E2_2B_B9_6F_29_95): ['org.bluez.Device1', {'ServicesResolved': <dbus_next.signature.Variant ('b', True)>}, []]
INFO:ble2mqtt.devices.base:Connected to e2:2b:b9:6f:29:95
DEBUG:ble2mqtt.protocols.redmond:Enable BLE notifications from [e2:2b:b9:6f:29:95]
DEBUG:bleak.backends.bluezdbus.client:Write Characteristic 6e400002-b5a3-f393-e0a9-e50e24dcca9e | /org/bluez/hci0/dev_E2_2B_B9_6F_29_95/service0009/char000d: bytearray(b'\x01\x00')
DEBUG:bleak.backends.bluezdbus.client:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_E2_2B_B9_6F_29_95/service0009/char000a): ['org.bluez.GattCharacteristic1', {'Notifying': <dbus_next.signature.Variant ('b', True)>}, []]
DEBUG:ble2mqtt.protocols.redmond:logging in...
DEBUG:ble2mqtt.protocols.redmond:... send cmd 00ff [ffffffffffffffff] 55 00 ff ff ff ff ff ff ff ff ff aa
DEBUG:bleak.backends.bluezdbus.client:received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_E2_2B_B9_6F_29_95): ['org.bluez.Device1', {'ServicesResolved': <dbus_next.signature.Variant ('b', False)>, 'Connected': <dbus_next.signature.Variant ('b', False)>}, []]
DEBUG:bleak.backends.bluezdbus.client:Device disconnected (/org/bluez/hci0/dev_E2_2B_B9_6F_29_95)
DEBUG:bleak.backends.bluezdbus.client:_remove_signal_handlers(/org/bluez/hci0/dev_E2_2B_B9_6F_29_95)
DEBUG:bleak.backends.bluezdbus.client:Write Characteristic 6e400002-b5a3-f393-e0a9-e50e24dcca9e | /org/bluez/hci0/dev_E2_2B_B9_6F_29_95/service0009/char000d: bytearray(b'U\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xaa')
DEBUG:bleak.backends.bluezdbus.client:_disconnect_message_bus(/org/bluez/hci0/dev_E2_2B_B9_6F_29_95)
DEBUG:ble2mqtt.devices.base:Client e2:2b:b9:6f:29:95 disconnected, device=Redmond_e22bb96f2995
ERROR:ble2mqtt.ble2mqtt:[Redmond_e22bb96f2995] connection problem, attempts=1
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/ble2mqtt/ble2mqtt.py", line 368, in manage_device
    await device.get_device_data()
  File "/usr/lib/python3.7/site-packages/ble2mqtt/devices/kettle_redmond.py", line 81, in get_device_data
    await self.login(self._key)
  File "/usr/lib/python3.7/site-packages/ble2mqtt/protocols/redmond.py", line 269, in login
    resp = await self.send_command(Command.AUTH, key, True)
  File "/usr/lib/python3.7/site-packages/ble2mqtt/protocols/redmond.py", line 265, in send_command
    return await aio.wait_for(cmd.answer, timeout)
  File "/usr/lib/python3.7/asyncio/tasks.py", line 449, in wait_for
concurrent.futures._base.TimeoutError
DEBUG:ble2mqtt.ble2mqtt:Sleep for 30 secs to reconnect to device=Redmond_e22bb96f2995
ERROR:ble2mqtt.protocols.redmond:Redmond_e22bb96f2995 raise an error in handle_queue, ignore it
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/ble2mqtt/protocols/redmond.py", line 188, in handle_queue
    timeout=command.timeout,
  File "/usr/lib/python3.7/asyncio/tasks.py", line 449, in wait_for
concurrent.futures._base.TimeoutError
^CINFO:ble2mqtt.__main__:Received exit signal SIGINT...
INFO:ble2mqtt.__main__:Closing ble2mqtt service
INFO:ble2mqtt.__main__:Cancelling 7 outstanding tasks
DEBUG:ble2mqtt.protocols.redmond:Redmond_e22bb96f2995 handle_queue is cancelled!
WARNING:ble2mqtt.ble2mqtt:Error on MQTT  disconnecting: ConnectionClosedError()
INFO:ble2mqtt.__main__:Bye.
MSITETOP commented 3 years ago

1 Install bleak 0.11.0 from github 2 install dbus_next from github 3 change key from config 4 set kettle pairing mode

I's work

dack64 commented 3 years ago

3 change key from config

what does it mean? Were you able to get the key from the ready4sky app?

MSITETOP commented 3 years ago

you don't need a key from the app. you need any random key, for example "key": "1234567890123456" or "key": "1122334455667788" run ble2mqtt you get Errorr: Not logged in set kettle pairing mode

you must be authorized

dack64 commented 3 years ago

you don't need a key from the app. you need any random key, for example "key": "1234567890123456" or "key": "1122334455667788" run ble2mqtt you get Errorr: Not logged in set kettle pairing mode

you must be authorized

thanks, your advice helped. Everything works

devbis commented 3 years ago

I added a note about the key to readme. https://github.com/devbis/ble2mqtt/commit/d0c627e53f86e3ff7c0ce114c30a72e6e1435064

Thanks for debugging!