hcoohb / hass-yeelightbt

Home assistant custom component for Yeelight bluetooth
50 stars 16 forks source link

Candela connected but not controllable #29

Open JunghaJungha opened 2 years ago

JunghaJungha commented 2 years ago

Light

Yeelight Candela

Home-assistant installation type

Home Assistant Operating System (HAOS)

Home-assistant version

2022.7.7

Describe the issue

Thanks for spending time on this.

I can find it and pair it, but not operate it. See logs for detail.

Koen

Debugging procedure followed:

Any additional comments

I am not sure if Passive BLE scanner interrupts, but previously it did work a short while with this integrations active.

Logs from the issue

Full logs 2022-08-02 11:35:59 WARNING (SyncWorker_8) [homeassistant.loader] We found a custom integration yeelight_bt which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2022-08-02 11:35:59 ERROR (SyncWorker_8) [homeassistant.loader] The custom integration 'yeelight_bt' does not have a version key in the manifest file and was blocked from loading. See https://developers.home-assistant.io/blog/2021/01/29/custom-integration-changes#versions for more details 2022-08-02 11:35:59 WARNING (SyncWorker_4) [homeassistant.loader] We found a custom integration yeelight_bt which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2022-08-02 11:37:59 DEBUG (MainThread) [custom_components.yeelight_bt.config_flow] Method selected: Scan 2022-08-02 11:38:00 DEBUG (MainThread) [custom_components.yeelight_bt.config_flow] Starting a scan for Yeelight Bt devices 2022-08-02 11:38:00 DEBUG (MainThread) [bleak.backends.bluezdbus.scanner] received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesAdded (/): ['/org/bluez/hci0/dev_F8_24_41_C4_4D_25', {'org.freedesktop.DBus.Introspectable': {}, 'org.bluez.Device1': {'Address': <dbus_next.signature.Variant ('s', F8:24:41:C4:4D:25)>, 'AddressType': <dbus_next.signature.Variant ('s', public)>, 'Name': <dbus_next.signature.Variant ('s', yeelight_ms)>, 'Alias': <dbus_next.signature.Variant ('s', yeelight_ms)>, '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', -60)>, 'Connected': <dbus_next.signature.Variant ('b', False)>, 'UUIDs': <dbus_next.signature.Variant ('as', ['0000fe87-0000-1000-8000-00805f9b34fb'])>, 'Adapter': <dbus_next.signature.Variant ('o', /org/bluez/hci0)>, 'ManufacturerData': <dbus_next.signature.Variant ('a{qv}', {356: <dbus_next.signature.Variant ('ay', b'd\x01%M\xc4A\x01\x00\x00%\x00yl_candela\x00\x00\x00\x00\x00\x00')>})>, 'ServicesResolved': <dbus_next.signature.Variant ('b', False)>}, 'org.freedesktop.DBus.Properties': {}}] 2022-08-02 11:38:28 INFO (MainThread) [custom_components.yeelight_bt.yeelightbt] found Candela with mac: F8:24:41:C4:4D:25, details:{'path': '/org/bluez/hci0/dev_F8_24_41_C4_4D_25', 'props': {'Address': 'F8:24:41:C4:4D:25', 'AddressType': 'public', 'Name': 'yeelight_ms', 'Alias': 'yeelight_ms', 'Paired': False, 'Trusted': False, 'Blocked': False, 'LegacyPairing': False, 'RSSI': -60, 'Connected': False, 'UUIDs': ['0000fe87-0000-1000-8000-00805f9b34fb'], 'Adapter': '/org/bluez/hci0', 'ManufacturerData': {356: b'd\x01%M\xc4A\x01\x00\x00%\x00yl_candela\x00\x00\x00\x00\x00\x00'}, 'ServicesResolved': False}} 2022-08-02 11:39:38 DEBUG (MainThread) [custom_components.yeelight_bt.config_flow] Yeelight UniqueID: f8:24:41:c4:4d:25 2022-08-02 11:39:38 DEBUG (MainThread) [custom_components.yeelight_bt] async setup. 2022-08-02 11:39:38 DEBUG (MainThread) [custom_components.yeelight_bt] List entries for domain: 2022-08-02 11:39:38 DEBUG (MainThread) [custom_components.yeelight_bt] [<homeassistant.config_entries.ConfigEntry object at 0x7f653da0c0>] 2022-08-02 11:39:39 DEBUG (MainThread) [custom_components.yeelight_bt] async setup entry: {'entry_id': '5fff2536532b47687a3cd47247a1e731', 'version': 2, 'domain': 'yeelight_bt', 'title': 'Candela', 'data': {'name': 'Candela', 'mac': 'F8:24:41:C4:4D:25'}, 'options': {}, 'pref_disable_new_entities': False, 'pref_disable_polling': False, 'source': 'user', 'unique_id': 'f8:24:41:c4:4d:25', 'disabled_by': None} 2022-08-02 11:39:40 DEBUG (MainThread) [custom_components.yeelight_bt.light] async_setup_entry:setting up the config entry Candela with data:{'name': 'Candela', 'mac': 'F8:24:41:C4:4D:25'} 2022-08-02 11:39:40 INFO (MainThread) [custom_components.yeelight_bt.light] Initializing YeelightBT Entity: Candela, F8:24:41:C4:4D:25 2022-08-02 11:39:40 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Initializing Yeelight Lamp F8:24:41:C4:4D:25 2022-08-02 11:39:40 DEBUG (MainThread) [custom_components.yeelight_bt.light] YEELIGHT: before first connection ---- 2022-08-02 11:39:40 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Initiating new connection 2022-08-02 11:39:41 DEBUG (MainThread) [bleak.backends.bluezdbus.scanner] received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesAdded (/): ['/org/bluez/hci0/dev_F8_24_41_C4_4D_25', {'org.freedesktop.DBus.Introspectable': {}, 'org.bluez.Device1': {'Address': <dbus_next.signature.Variant ('s', F8:24:41:C4:4D:25)>, 'AddressType': <dbus_next.signature.Variant ('s', public)>, 'Name': <dbus_next.signature.Variant ('s', yeelight_ms)>, 'Alias': <dbus_next.signature.Variant ('s', yeelight_ms)>, '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', -58)>, 'Connected': <dbus_next.signature.Variant ('b', False)>, 'UUIDs': <dbus_next.signature.Variant ('as', ['0000fe87-0000-1000-8000-00805f9b34fb'])>, 'Adapter': <dbus_next.signature.Variant ('o', /org/bluez/hci0)>, 'ManufacturerData': <dbus_next.signature.Variant ('a{qv}', {356: <dbus_next.signature.Variant ('ay', b'd\x01%M\xc4A\x01\x00\x00%\x00yl_candela\x00\x00\x00\x00\x00\x00')>})>, 'ServicesResolved': <dbus_next.signature.Variant ('b', False)>}, 'org.freedesktop.DBus.Properties': {}}] 2022-08-02 11:39:43 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Connected: True 2022-08-02 11:39:43 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Request Notify 2022-08-02 11:40:13 ERROR (MainThread) [custom_components.yeelight_bt.yeelightbt] Connection: BleakError: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Connection Rejected Due To Security Reasons) 2022-08-02 11:40:13 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Connect retry 1 2022-08-02 11:40:15 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Client with address F8:24:41:C4:4D:25 got disconnected! 2022-08-02 11:40:15 DEBUG (MainThread) [custom_components.yeelight_bt.light] Got state notification from the lamp 2022-08-02 11:40:15 DEBUG (MainThread) [bleak.backends.bluezdbus.scanner] received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_F8_24_41_C4_4D_25): ['org.bluez.Device1', {'RSSI': <dbus_next.signature.Variant ('n', -58)>, 'Name': <dbus_next.signature.Variant ('s', yeelight_ms)>, 'Alias': <dbus_next.signature.Variant ('s', yeelight_ms)>, 'ManufacturerData': <dbus_next.signature.Variant ('a{qv}', {356: <dbus_next.signature.Variant ('ay', b'd\x01%M\xc4A\x01\x00\x00%\x00yl_candela\x00\x00\x00\x00\x00\x00')>})>}, []] 2022-08-02 11:40:17 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Connected: True 2022-08-02 11:40:17 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Request Notify 2022-08-02 11:40:47 ERROR (MainThread) [custom_components.yeelight_bt.yeelightbt] Connection: BleakError: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Connection Rejected Due To Security Reasons) 2022-08-02 11:40:47 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Connect retry 2 2022-08-02 11:40:50 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Client with address F8:24:41:C4:4D:25 got disconnected! 2022-08-02 11:40:50 DEBUG (MainThread) [custom_components.yeelight_bt.light] Got state notification from the lamp 2022-08-02 11:40:50 DEBUG (MainThread) [bleak.backends.bluezdbus.scanner] received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_F8_24_41_C4_4D_25): ['org.bluez.Device1', {'RSSI': <dbus_next.signature.Variant ('n', -58)>, 'Name': <dbus_next.signature.Variant ('s', yeelight_ms)>, 'Alias': <dbus_next.signature.Variant ('s', yeelight_ms)>, 'ManufacturerData': <dbus_next.signature.Variant ('a{qv}', {356: <dbus_next.signature.Variant ('ay', b'd\x01%M\xc4A\x01\x00\x00%\x00yl_candela\x00\x00\x00\x00\x00\x00')>})>}, []] 2022-08-02 11:40:52 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Connected: True 2022-08-02 11:40:52 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Request Notify 2022-08-02 11:41:23 ERROR (MainThread) [custom_components.yeelight_bt.yeelightbt] Connection: BleakError: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Connection Rejected Due To Security Reasons) 2022-08-02 11:41:23 DEBUG (MainThread) [custom_components.yeelight_bt.light] YEELIGHT: after first connection ---- 2022-08-02 11:41:25 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Client with address F8:24:41:C4:4D:25 got disconnected! 2022-08-02 11:41:25 DEBUG (MainThread) [custom_components.yeelight_bt.light] Got state notification from the lamp 2022-08-02 11:41:53 DEBUG (MainThread) [custom_components.yeelight_bt.light] Requesting an update of the lamp status 2022-08-02 11:41:53 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Send Cmd: Get_state 2022-08-02 11:41:53 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Initiating new connection 2022-08-02 11:41:53 DEBUG (MainThread) [bleak.backends.bluezdbus.scanner] received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_F8_24_41_C4_4D_25): ['org.bluez.Device1', {'RSSI': <dbus_next.signature.Variant ('n', -56)>, 'Name': <dbus_next.signature.Variant ('s', yeelight_ms)>, 'Alias': <dbus_next.signature.Variant ('s', yeelight_ms)>, 'ManufacturerData': <dbus_next.signature.Variant ('a{qv}', {356: <dbus_next.signature.Variant ('ay', b'd\x01%M\xc4A\x01\x00\x00%\x00yl_candela\x00\x00\x00\x00\x00\x00')>})>}, []] 2022-08-02 11:41:55 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Connected: True 2022-08-02 11:41:55 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Request Notify 2022-08-02 11:42:25 ERROR (MainThread) [custom_components.yeelight_bt.yeelightbt] Connection: BleakError: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Connection Rejected Due To Security Reasons) 2022-08-02 11:42:25 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Connect retry 1 2022-08-02 11:42:28 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Client with address F8:24:41:C4:4D:25 got disconnected! 2022-08-02 11:42:28 DEBUG (MainThread) [custom_components.yeelight_bt.light] Got state notification from the lamp 2022-08-02 11:42:28 DEBUG (MainThread) [bleak.backends.bluezdbus.scanner] received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_F8_24_41_C4_4D_25): ['org.bluez.Device1', {'RSSI': <dbus_next.signature.Variant ('n', -56)>, 'Name': <dbus_next.signature.Variant ('s', yeelight_ms)>, 'Alias': <dbus_next.signature.Variant ('s', yeelight_ms)>, 'ManufacturerData': <dbus_next.signature.Variant ('a{qv}', {356: <dbus_next.signature.Variant ('ay', b'd\x01%M\xc4A\x01\x00\x00%\x00yl_candela\x00\x00\x00\x00\x00\x00')>})>}, []]

hcoohb commented 2 years ago

Thanks for the report @Koendejongh .

Did you say you could pair the lamp?? As in, did you see the pulsing effect on the lamp where you have to turn the top?

Because it seems from the log that it never reached that step....the light is connecting but then the connection is stopped after 30s before even having completed the request for notification...

(Also, it looks like you have an old version of this custom component also installed at the same time. It would not impact this issue as HA disable it anyway)

hcoohb commented 2 years ago

I have published a test version called v1.0.2-candelatest1 for candela as a beta, so you can install it through HACS if you select "re-download" > "show beta version". It does not change much but might confirm where the issue is for the candela. Would be great if you could give me the log for that one. (no need to reset the light, just enable the debug flags.)

JunghaJungha commented 2 years ago

I have installed the test1 version and connected the Candela. First time no success, but second attemp it succeeded. Now it is paired I believe (It is available, but not controllable (grey), unlike at the starting post, where it was registrated, but not available (yellow)).

I will check the old version remark later on.

Here is my log:

2022-08-02 15:47:30 WARNING (SyncWorker_5) [homeassistant.loader] We found a custom integration yeelight_bt which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2022-08-02 15:47:30 WARNING (SyncWorker_10) [homeassistant.loader] We found a custom integration yeelight_bt which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2022-08-02 15:47:30 ERROR (SyncWorker_10) [homeassistant.loader] The custom integration 'yeelight_bt' does not have a version key in the manifest file and was blocked from loading. See https://developers.home-assistant.io/blog/2021/01/29/custom-integration-changes#versions for more details 2022-08-02 15:50:30 DEBUG (MainThread) [custom_components.yeelight_bt.config_flow] Method selected: Scan 2022-08-02 15:50:32 DEBUG (MainThread) [custom_components.yeelight_bt.config_flow] Starting a scan for Yeelight Bt devices 2022-08-02 15:50:32 DEBUG (MainThread) [bleak.backends.bluezdbus.scanner] received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesAdded (/): ['/org/bluez/hci0/dev_F8_24_41_C4_4D_25', {'org.freedesktop.DBus.Introspectable': {}, 'org.bluez.Device1': {'Address': <dbus_next.signature.Variant ('s', F8:24:41:C4:4D:25)>, 'AddressType': <dbus_next.signature.Variant ('s', public)>, 'Name': <dbus_next.signature.Variant ('s', yeelight_ms)>, 'Alias': <dbus_next.signature.Variant ('s', yeelight_ms)>, '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', -55)>, 'Connected': <dbus_next.signature.Variant ('b', False)>, 'UUIDs': <dbus_next.signature.Variant ('as', ['0000fe87-0000-1000-8000-00805f9b34fb'])>, 'Adapter': <dbus_next.signature.Variant ('o', /org/bluez/hci0)>, 'ManufacturerData': <dbus_next.signature.Variant ('a{qv}', {356: <dbus_next.signature.Variant ('ay', b'd\x01%M\xc4A\x01\x00\x00%\x00yl_candela\x00\x00\x00\x00\x00\x00')>})>, 'ServicesResolved': <dbus_next.signature.Variant ('b', False)>}, 'org.freedesktop.DBus.Properties': {}}] 2022-08-02 15:50:37 INFO (MainThread) [custom_components.yeelight_bt.yeelightbt] found Candela with mac: F8:24:41:C4:4D:25, details:{'path': '/org/bluez/hci0/dev_F8_24_41_C4_4D_25', 'props': {'Address': 'F8:24:41:C4:4D:25', 'AddressType': 'public', 'Name': 'yeelight_ms', 'Alias': 'yeelight_ms', 'Paired': False, 'Trusted': False, 'Blocked': False, 'LegacyPairing': False, 'RSSI': -55, 'Connected': False, 'UUIDs': ['0000fe87-0000-1000-8000-00805f9b34fb'], 'Adapter': '/org/bluez/hci0', 'ManufacturerData': {356: b'd\x01%M\xc4A\x01\x00\x00%\x00yl_candela\x00\x00\x00\x00\x00\x00'}, 'ServicesResolved': False}} 2022-08-02 15:50:47 DEBUG (MainThread) [custom_components.yeelight_bt.config_flow] Yeelight UniqueID: f8:24:41:c4:4d:25 2022-08-02 15:50:47 DEBUG (MainThread) [custom_components.yeelight_bt] async setup. 2022-08-02 15:50:47 DEBUG (MainThread) [custom_components.yeelight_bt] List entries for domain: 2022-08-02 15:50:47 DEBUG (MainThread) [custom_components.yeelight_bt] [<homeassistant.config_entries.ConfigEntry object at 0x7f82783920>] 2022-08-02 15:50:47 DEBUG (MainThread) [custom_components.yeelight_bt] async setup entry: {'entry_id': 'ac283fef52538e0165f676f6801906d9', 'version': 2, 'domain': 'yeelight_bt', 'title': 'Candela', 'data': {'name': 'Candela', 'mac': 'F8:24:41:C4:4D:25'}, 'options': {}, 'pref_disable_new_entities': False, 'pref_disable_polling': False, 'source': 'user', 'unique_id': 'f8:24:41:c4:4d:25', 'disabled_by': None} 2022-08-02 15:50:47 DEBUG (MainThread) [custom_components.yeelight_bt.light] async_setup_entry:setting up the config entry Candela with data:{'name': 'Candela', 'mac': 'F8:24:41:C4:4D:25'} 2022-08-02 15:50:47 INFO (MainThread) [custom_components.yeelight_bt.light] Initializing YeelightBT Entity: Candela, F8:24:41:C4:4D:25 2022-08-02 15:50:47 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Initializing Yeelight Lamp F8:24:41:C4:4D:25 2022-08-02 15:50:47 DEBUG (MainThread) [custom_components.yeelight_bt.light] YEELIGHT: before first connection ---- 2022-08-02 15:50:47 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Initiating new connection 2022-08-02 15:50:47 DEBUG (MainThread) [bleak.backends.bluezdbus.scanner] cached devices: {'/org/bluez/hci0/dev_6A_43_18_01_42_58': {'Address': '6A:43:18:01:42:58', 'AddressType': 'random', 'Name': 'LE-Bose QC35 II', 'Alias': 'LE-Bose QC35 II', 'Paired': False, 'Trusted': False, 'Blocked': False, 'LegacyPairing': False, 'Connected': False, 'UUIDs': ['0000febe-0000-1000-8000-00805f9b34fb', '0000fdd2-0000-1000-8000-00805f9b34fb', '0000fe26-0000-1000-8000-00805f9b34fb', '0000fe03-0000-1000-8000-00805f9b34fb'], 'Adapter': '/org/bluez/hci0', 'ManufacturerData': {2305: b'q\x12\xef\x84\xee\xfe\x7f\xec{P\x03\nW'}, 'ServicesResolved': False}, '/org/bluez/hci0/dev_E7_2E_00_93_90_7D': {'Address': 'E7:2E:00:93:90:7D', 'AddressType': 'public', 'Name': 'LYWSD02', 'Alias': 'LYWSD02', 'Paired': False, 'Trusted': False, 'Blocked': False, 'LegacyPairing': False, 'Connected': False, 'UUIDs': ['0000181a-0000-1000-8000-00805f9b34fb', '0000fef5-0000-1000-8000-00805f9b34fb'], 'Adapter': '/org/bluez/hci0', 'ServiceData': {'0000fe95-0000-1000-8000-00805f9b34fb': b'p [\x04\xbb}\x90\x93\x00.\xe7\t\x04\x10\x02\xf9\x00'}, 'ServicesResolved': False}, '/org/bluez/hci0/dev_F8_24_41_C4_4D_25': {'Address': 'F8:24:41:C4:4D:25', 'AddressType': 'public', 'Name': 'yeelight_ms', 'Alias': 'yeelight_ms', 'Paired': False, 'Trusted': False, 'Blocked': False, 'LegacyPairing': False, 'Connected': False, 'UUIDs': ['0000fe87-0000-1000-8000-00805f9b34fb'], 'Adapter': '/org/bluez/hci0', 'ManufacturerData': {356: b'd\x01%M\xc4A\x01\x00\x00%\x00yl_candela\x00\x00\x00\x00\x00\x00'}, 'ServicesResolved': False}} 2022-08-02 15:50:50 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Connected: True 2022-08-02 15:50:50 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Request Notify 2022-08-02 15:51:20 ERROR (MainThread) [custom_components.yeelight_bt.yeelightbt] Connection: BleakError: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Connection Rejected Due To Security Reasons) 2022-08-02 15:51:20 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Connect retry 1 2022-08-02 15:51:21 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Client with address F8:24:41:C4:4D:25 got disconnected! 2022-08-02 15:51:21 DEBUG (MainThread) [custom_components.yeelight_bt.light] Got state notification from the lamp 2022-08-02 15:51:22 DEBUG (MainThread) [bleak.backends.bluezdbus.scanner] received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_F8_24_41_C4_4D_25): ['org.bluez.Device1', {'RSSI': <dbus_next.signature.Variant ('n', -57)>, 'Name': <dbus_next.signature.Variant ('s', yeelight_ms)>, 'Alias': <dbus_next.signature.Variant ('s', yeelight_ms)>, 'ManufacturerData': <dbus_next.signature.Variant ('a{qv}', {356: <dbus_next.signature.Variant ('ay', b'd\x01%M\xc4A\x01\x00\x00%\x00yl_candela\x00\x00\x00\x00\x00\x00')>})>}, []] 2022-08-02 15:51:23 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Connected: True 2022-08-02 15:51:23 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Request Notify 2022-08-02 15:51:49 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Received 0x434501010207080000000000000000000000 fron handle=33 2022-08-02 15:51:49 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] <Lamp F8:24:41:C4:4D:25 ON mode_None bri0 rgb(2, 7, 8) temp_0> 2022-08-02 15:51:49 DEBUG (MainThread) [custom_components.yeelight_bt.light] Got state notification from the lamp 2022-08-02 15:51:49 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Received 0x434501060207080000000000000000000000 fron handle=33 2022-08-02 15:51:49 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] <Lamp F8:24:41:C4:4D:25 ON mode_None bri0 rgb(2, 7, 8) temp_0> 2022-08-02 15:51:49 DEBUG (MainThread) [custom_components.yeelight_bt.light] Got state notification from the lamp 2022-08-02 15:51:49 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Received 0x434501140207080000000000000000000000 fron handle=33 2022-08-02 15:51:49 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] <Lamp F8:24:41:C4:4D:25 ON mode_None bri0 rgb(2, 7, 8) temp_0> 2022-08-02 15:51:49 DEBUG (MainThread) [custom_components.yeelight_bt.light] Got state notification from the lamp 2022-08-02 15:51:49 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Received 0x434501320207080000000000000000000000 fron handle=33 2022-08-02 15:51:49 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] <Lamp F8:24:41:C4:4D:25 ON mode_None bri0 rgb(2, 7, 8) temp_0> 2022-08-02 15:51:49 DEBUG (MainThread) [custom_components.yeelight_bt.light] Got state notification from the lamp 2022-08-02 15:51:53 ERROR (MainThread) [custom_components.yeelight_bt.yeelightbt] Connection: BleakError: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Connection Rejected Due To Security Reasons) 2022-08-02 15:51:53 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Connect retry 2 2022-08-02 15:51:56 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Client with address F8:24:41:C4:4D:25 got disconnected! 2022-08-02 15:51:56 DEBUG (MainThread) [custom_components.yeelight_bt.light] Got state notification from the lamp 2022-08-02 15:51:57 DEBUG (MainThread) [bleak.backends.bluezdbus.scanner] received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_F8_24_41_C4_4D_25): ['org.bluez.Device1', {'RSSI': <dbus_next.signature.Variant ('n', -62)>, 'Name': <dbus_next.signature.Variant ('s', yeelight_ms)>, 'Alias': <dbus_next.signature.Variant ('s', yeelight_ms)>, 'ManufacturerData': <dbus_next.signature.Variant ('a{qv}', {356: <dbus_next.signature.Variant ('ay', b'd\x01%M\xc4A\x01\x00\x00%\x00yl_candela\x00\x00\x00\x00\x00\x00')>})>}, []] 2022-08-02 15:52:00 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Connected: True 2022-08-02 15:52:00 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Request Notify 2022-08-02 15:52:05 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Client with address F8:24:41:C4:4D:25 got disconnected! 2022-08-02 15:52:05 DEBUG (MainThread) [custom_components.yeelight_bt.light] Got state notification from the lamp 2022-08-02 15:52:06 ERROR (MainThread) [custom_components.yeelight_bt.yeelightbt] Connection: BleakError: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Connection Rejected Due To Security Reasons) 2022-08-02 15:52:06 DEBUG (MainThread) [custom_components.yeelight_bt.light] YEELIGHT: after first connection ---- 2022-08-02 15:52:36 DEBUG (MainThread) [custom_components.yeelight_bt.light] Requesting an update of the lamp status 2022-08-02 15:52:36 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Send Cmd: Get_state 2022-08-02 15:52:36 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Initiating new connection 2022-08-02 15:52:36 DEBUG (MainThread) [bleak.backends.bluezdbus.scanner] received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesAdded (/): ['/org/bluez/hci0/dev_F8_24_41_C4_4D_25', {'org.freedesktop.DBus.Introspectable': {}, 'org.bluez.Device1': {'Address': <dbus_next.signature.Variant ('s', F8:24:41:C4:4D:25)>, 'AddressType': <dbus_next.signature.Variant ('s', public)>, 'Name': <dbus_next.signature.Variant ('s', yeelight_ms)>, 'Alias': <dbus_next.signature.Variant ('s', yeelight_ms)>, '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', -56)>, 'Connected': <dbus_next.signature.Variant ('b', False)>, 'UUIDs': <dbus_next.signature.Variant ('as', ['0000fe87-0000-1000-8000-00805f9b34fb'])>, 'Adapter': <dbus_next.signature.Variant ('o', /org/bluez/hci0)>, 'ManufacturerData': <dbus_next.signature.Variant ('a{qv}', {356: <dbus_next.signature.Variant ('ay', b'd\x01%M\xc4A\x01\x00\x00%\x00yl_candela\x00\x00\x00\x00\x00\x00')>})>, 'ServicesResolved': <dbus_next.signature.Variant ('b', False)>}, 'org.freedesktop.DBus.Properties': {}}] 2022-08-02 15:52:39 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Connected: True 2022-08-02 15:52:39 DEBUG (MainThread) [custom_components.yeelight_bt.yeelightbt] Request Notify

pgsylvestre commented 2 years ago

This error originated from a custom integration.

Logger: custom_components.yeelight_bt.yeelightbt Source: custom_components/yeelight_bt/yeelightbt.py:236 Integration: Yeelight bluetooth (documentation, issues) First occurred: 10:39:38 AM (51 occurrences) Last logged: 10:47:43 AM

Connection: BleakError: [org.bluez.Error.InProgress] Operation already in progress

jussapaavo commented 2 years ago

I tested this also. The integration seems to succesfully find my Candela and show the correct MAC address, however it doesn't initiate the pairing process with light pulsing on the Candela. And so the connection does not seem to go through in the end.

Here's my logs: https://pastebin.com/yA9jy9i8

matteos1 commented 2 years ago

Logger: custom_components.yeelight_bt.yeelightbt Source: custom_components/yeelight_bt/yeelightbt.py:151 Integration: Yeelight bluetooth (documentation, issues) First occurred: 09:26:57 (21 occurrences) Last logged: 09:31:16

Connection: BleakError: [org.bluez.Error.Failed] le-connection-abort-by-local Connection: BleakError: Device with address F8:24:41:C0:28:96 could not be found. Try increasing timeout value or moving the device closer.

yeahwangy commented 2 years ago

Save issue here. Full log https://pastebin.com/GRebm0kX

hcoohb commented 2 years ago

Thanks for the logs, I see at what step the issue is for the Candela now, I'll try to work out something soon.

Guys, if you don't enable the logging with the debug flag, reporting here does not give me any useful info on what coule be going on... so thanks for those taking the time.

Can I also ask that you please let me know your HA version, HA install type and which version of yeelight_bt you installed, otherwise, hard to keep track.

@yeahwangy , your log is great! thanks a lot. it outputs very verbosely all the bleak messages which really helped. At least I now know writing the pairing request works, it is just the lamp denying us access. Can I ask which HA version that was and are you using HAOS or HA docker or venv?

Thanks

yeahwangy commented 2 years ago

HAOS version 2022.7.7

robiecz commented 2 years ago

I have a question regarding this flow. With the new version of HASS 2022.8 comes "First-class Bluetooth support". Does it change the game somehow?

matteos1 commented 2 years ago

2022.8.1

hcoohb commented 2 years ago

I have a question regarding this flow. With the new version of HASS 2022.8 comes "First-class Bluetooth support". Does it change the game somehow?

@robiecz, yes and no. I am not sure I would describe it at "First-class Bluetooth support" just yet (given how much CPU it is taking on my system), but hey, got to start somewhere... Hopefully that means ble will stabilize a bit. Changing significantly the bluetooth landscape two month in a row without much warning was a bit painful. Had to adapt the code again to make it work nicely with the bluetooth integration. However the bluetooth integration does not support every scenario... it is mainly for receiving data from devices that emits ble advertisements. (The lamp we have do not). So it helps for the discovery of the lamp, but for the actual connection to the lamp, not really.

hcoohb commented 2 years ago

I released v1.1.0 version compatible with 2022.8.0+, with a few more tests for the Candela. @yeahwangy, @Koendejongh or anyone else , if you are on 2022.8, could you give me a log with the debug logging enabled for yeelight_bt and bleak (as described in readme) ? Thanks

matteos1 commented 2 years ago

home assistant 2022.8.1 light candela

Logger: homeassistant.components.light Source: custom_components/yeelight_bt/light.py:84 Integration: Luce (documentation, issues) First occurred: 17:22:15 (1 occurrences) Last logged: 17:22:15

Error while setting up yeelight_bt platform for light Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 281, in _async_setup_platform await asyncio.shield(task) File "/config/custom_components/yeelight_bt/light.py", line 84, in async_setup_entry raise ConfigEntryNotReady( NameError: name 'ConfigEntryNotReady' is not defined

matteos1 commented 2 years ago

https://pastebin.com/jDxufYHx

(Edited to get the log in pastbin so this thread is clearer)

yeahwangy commented 2 years ago

@hcoohb Thanks for the great work! Just update HAOS to 2022.8.1 with yeelightbt v1.1.0. It's still not controllable. Here is the full debug log, Hope this helps https://gist.github.com/yeahwangy/c52f7608859da7ef41c58cfb7f25e567

hcoohb commented 2 years ago

@matteos1, Thanks for your log, but no yeelight lamp was detected... the integration should not crash though, so that was a bug fixed in v1.2.0. Not sure why yeelight is not detected... Does it appear in a scan? Are you sure it is not connected to another device?

@yeahwangy, thanks! that definitely helps a lot, at least now I have the full list of UUID for the candela. But very confusing, now this time the light seems to not even respond to the notification request, whereas in your previous log it was at the "pairing" step that the lamp rejected the request...
I could not find any proper code online for the Candela that seems to be working with notifications... So in v1.2.0, I basically disabled notif and pairing step for candela. It might allow to control the lamp (but won't get any feedback from it). Please let me know if that changes anything?

And also, I'd be interested to do another test: contrary to the bedside, the Candela seems to publish frequent BLE advertisements (from your log). So could you try: remove the _yeelightbt integration from HA. Ensure you have bluetooth integration enabled and configured. Enable bleak debug log. then restart HA and wait it starts, and turn on and off the light a few times, and change the brightness. if you get me the log of that we can at least see if it published its state through advertisements. Cheers

matteos1 commented 2 years ago

@matteos1, Thanks for your log, but no yeelight lamp was detected... the integration should not crash though, so that was a bug fixed in v1.2.0. Not sure why yeelight is not detected... Does it appear in a scan? Are you sure it is not connected to another device?

the scan reveals the candela light and also indicates the number of mac. The light has been reset and is therefore not coupled with the application

matteos1 commented 2 years ago

image

matteos1 commented 2 years ago

is the project alive?

grain111 commented 2 years ago

Hi. My Candela lamp was working fine with June version of HA, but now it is not working (it is detected, but can't be controlled and the state isn't shown). Here are my logs: https://pastebin.com/3XrRpHjF

IvanVojtko commented 2 years ago

Hey @hcoohb. I was able to write a simple code that is able to change brightness of candela lamp.

import logging
import asyncio
import platform
import struct
from random import randint

from bleak import BleakClient
from bleak import _logger as logger

BTN_A_UUID = "8f65073d-9f57-4aaa-afea-397d19d5bbeb"
CONTROL_UUID = "aa7d3f34-2d4f-41e0-807f-52fbf8cf7443"

COMMAND_STX = 0x43
CMD_PAIR = 0x67
CMD_PAIR_ON = 0x02
RES_PAIR = 0x63
CMD_POWER = 0x40
CMD_POWER_ON = 0x01
CMD_POWER_OFF = 0x02
CMD_COLOR = 0x41
CMD_BRIGHTNESS = 0x42
CMD_TEMP = 0x43
CMD_RGB = 0x41
CMD_GETSTATE = 0x44
CMD_GETSTATE_SEC = 0x02
RES_GETSTATE = 0x45
CMD_GETNAME = 0x52
RES_GETNAME = 0x53
CMD_GETVER = 0x5C
RES_GETVER = 0x5D
CMD_GETSERIAL = 0x5E
RES_GETSERIAL = 0x5F
RES_GETTIME = 0x62

async def run(address, debug=True):
    if debug:
        import sys

        l = logging.getLogger("asyncio")
        l.setLevel(logging.DEBUG)
        h = logging.StreamHandler(sys.stdout)
        h.setLevel(logging.DEBUG)
        l.addHandler(h)
        logger.addHandler(h)
    def disconnect():
        print("Disconnected")

    async with BleakClient(address, disconnected_callback=disconnect()) as client:
        await asyncio.sleep(1)
        print("a")
        x = client.is_connected()
        print("Connected: "+str(x))
        print("Test")
        def btn_a_handler(sender, data):
            """Simple notification handler for btn a events."""
            print("{0}: {1}".format(sender, data))

        bits = bytearray(struct.pack("BBB15x", COMMAND_STX, CMD_PAIR, CMD_PAIR_ON))
        await client.write_gatt_char(CONTROL_UUID, bits)
        await asyncio.sleep(0.3)
        print("b")
        #await client.start_notify(BTN_A_UUID, btn_a_handler)
        await asyncio.sleep(0.3)
        bits = struct.pack("BBB15x", COMMAND_STX, CMD_GETSTATE, CMD_GETSTATE_SEC)
        print(bits)
        #await client.write_gatt_char(CONTROL_UUID, bytearray(bits))
        bits = struct.pack("BBB15x", COMMAND_STX, CMD_BRIGHTNESS, 100)
        await client.write_gatt_char(CONTROL_UUID, bytearray(bits))
        while client.is_connected():
            await asyncio.sleep(1)

if __name__ == "__main__":
    address = ("")

    loop = asyncio.get_event_loop()
    loop.set_debug(True)
    loop.run_until_complete(run(address, True))

But as soon as I enable client.start_notify(BTN_A_UUID, btn_a_handler), it stops working. It hangs for some time and crashes with bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Connection Rejected Due To Security Reasons) Maybe this will help you.

grain111 commented 2 years ago

I don't know if other people would be up for it, but maybe you could set up some kind of donation method so we could buy you a candela lamp?

IvanVojtko commented 2 years ago

Okay so another observation. It looks like pairing is not working. You can control lamp without pairing, but you can subscribe to notifications because after few seconds lamp will disconnect you. To me it looks like pairing process is not working. I was trying to create some standalone python code just to pair with a lamp but it was not working.

grain111 commented 2 years ago

Hi. Lately I had some time to tinker and I managed to connect Candela to Home Assistant using OP's code. I know it's not pretty and doesn't yet support notifications, but it works well enough. In future I plan to enable notifications and make pull request to original integration. To use it you have to copy my repo to custom_components folder in your config path and add following section to your configuration.yaml:

light:

My repo: https://github.com/grain111/candela_test

frr032 commented 2 years ago

FYI Same Candela issue as originally reported with HA 2022.10.1. Eagerly looking forward to the fix. Thanks

jussapaavo commented 2 years ago

Have been testing the 1.3.0 release for today and works great so far! Thanks for making it work, it's greatly appreciated.

hcoohb commented 2 years ago

Hi all, sorry for the delayed answer, life caught up with me a bit, @IvanVojtko , @grain111 Thanks for the testing and establishing that the candela fails on the start_notify command. I looked bit around as it is just weird that it was working with bluepy but then stopped working with bleak... One possible explanation is that the Candela does not follow 100% the bluetooth specification and bluez (used by bleak on linux system) expects it too. It seems exactly to behave like the error reported in bleak: https://github.com/hbldh/bleak/issues/972 Unfortunately there does not seem to be much workaround at this stage.... which means, getting the state from the device might not work from now on... (we could try writing the char to enable notif before the call to start_notify but in most device, that is not sufficient apparently as bluez still disconnect after short time. if anyone want to try that and don't know what to do, let me know)

But in 1.3.0, I basically disabled the notifications for the candela when using bluez (basically HA on linux) and always assume the command could be sent to the lamp... It is getting messy because without notification, we have no way of knowing if the lamp is already paired or not... at the moment, I force a wait time of 10s during connection to quickly allow to push the button if needed. I also enabled the notification if using a esphome bluetooth-proxy as I don't know how that adapter is behaving.... So could someone try things:

@jussapaavo , thanks for reporting, are you using a bluetooth adapter on the HA system? or a esp32?

grain111 commented 2 years ago

I have been testing notifications for Candela. Using your code, running it outside HA (as Python module), bleak-retry-connector is able to maintain connection and reconnects on error, but when running it as HA integration it blocks it from execution due to an error. One thing I don't understand is that when running notification outside HA it blocks execution of next test script commands (when I start_notify it doesn't execute any other command).

ASNNetworks commented 2 years ago

Hi all, sorry for the delayed answer, life caught up with me a bit, @IvanVojtko , @grain111 Thanks for the testing and establishing that the candela fails on the start_notify command. I looked bit around as it is just weird that it was working with bluepy but then stopped working with bleak... One possible explanation is that the Candela does not follow 100% the bluetooth specification and bluez (used by bleak on linux system) expects it too. It seems exactly to behave like the error reported in bleak: hbldh/bleak#972 Unfortunately there does not seem to be much workaround at this stage.... which means, getting the state from the device might not work from now on... (we could try writing the char to enable notif before the call to start_notify but in most device, that is not sufficient apparently as bluez still disconnect after short time. if anyone want to try that and don't know what to do, let me know)

But in 1.3.0, I basically disabled the notifications for the candela when using bluez (basically HA on linux) and always assume the command could be sent to the lamp... It is getting messy because without notification, we have no way of knowing if the lamp is already paired or not... at the moment, I force a wait time of 10s during connection to quickly allow to push the button if needed. I also enabled the notification if using a esphome bluetooth-proxy as I don't know how that adapter is behaving.... So could someone try things:

  • with a bluetooth adapter connected to HA and the bluetooth integration: Can you check that you can control the lamp? You won't be able to see the change in HA if you manually modify the lamp
  • if someone has a esp32 floating around and can flash a bluetooth proxy on it, disable the bluetooth integration (and restart HA to be sure that the commands are sent to the bluetooth-proxy): can you check if you can control the lamp? Can you see the manual changes reflected in HA?

@jussapaavo , thanks for reporting, are you using a bluetooth adapter on the HA system? or a esp32?

I happen to have tested this for the last 2 days with esp32 bluetooth proxy. I use the Odroid N2+, which doesn't have a bluetooth chip, so there is no way to even enable the bluetooth integration ;)

I could pair the Candela without issues, it even showed on the integrations page automatically where I could configure it and save it. I have two Candela's, both can be paired without issues and also show the full MAC address. However, after pairing they're both unavailable. Both lights have greyed out toggles and won't respond to anything. Adjusting the Candela's manually also don't reflect changes in HA.

Interesting point: when I restarted HA, while both were turned off by the power switch, both showed an error icon since they weren't reachable during restart. However, turning on back the power of the Candela, immediately made the error sign go away in integrations page, but still no controls/state updates.

Let me know if there are stuff you need testing or a beta build that you need esp32 bluetooth proxy testing with Candela.

hcoohb commented 2 years ago

@grain111

I have been testing notifications for Candela. Using your code, running it outside HA (as Python module), bleak-retry-connector is able to maintain connection and reconnects on error, but when running it as HA integration it blocks it from execution due to an error. One thing I don't understand is that when running notification outside HA it blocks execution of next test script commands (when I start_notify it doesn't execute any other command).

Do you mean that you were able to get notifications using bleak outside HA? Because at this stage I believe this is a bluez incompatibility with the candela not following proper bluetooth standard. My current code (1.3.0) do not call start_notify for the candela when using bluez backend.

hcoohb commented 2 years ago

@ASNNetworks

I happen to have tested this for the last 2 days with esp32 bluetooth proxy. I use the Odroid N2+, which doesn't have a bluetooth chip, so there is no way to even enable the bluetooth integration ;)

This is a good setup to test the bluetooth proxy indeed.

I could pair the Candela without issues, it even showed on the integrations page automatically where I could configure it and save it. I have two Candela's, both can be paired without issues and also show the full MAC address. However, after pairing they're both unavailable. Both lights have greyed out toggles and won't respond to anything. Adjusting the Candela's manually also don't reflect changes in HA.

When you say "pair" do you mean the lamp started to pulse and you had to push the button on the physical light?

Interesting point: when I restarted HA, while both were turned off by the power switch, both showed an error icon since they weren't reachable during restart. However, turning on back the power of the Candela, immediately made the error sign go away in integrations page, but still no controls/state updates.

What I noticed with the bluetooth-proxy is that it is usually not yet available on first start, so you will have a message saying that the yeelight-bt integration could not be setup but it will be retried 10s after and now the bluetooth proxy is available and the integration will load

Let me know if there are stuff you need testing or a beta build that you need esp32 bluetooth proxy testing with Candela.

Are you able to launch HA enabling debug logging for yeelight_bt, bleak_retry_connector and esphome.bluetooth? That should help to find out where it fails (it could be the start_notif for esp as well...):

logger:
  logs:
    custom_components.yeelight_bt: debug
    bleak_retry_connector: debug
    homeassistant.components.esphome.bluetooth: debug

Also, do you have only one esp32? I believe at this stage you can only have one active connection per esp32, and since this light requires constant connection, I am actually not sure what it would do if you try to connect two lights (I would assume one would just not connect). Can you give the log once you have added only one light in HA?

grain111 commented 2 years ago

@grain111

I have been testing notifications for Candela. Using your code, running it outside HA (as Python module), bleak-retry-connector is able to maintain connection and reconnects on error, but when running it as HA integration it blocks it from execution due to an error. One thing I don't understand is that when running notification outside HA it blocks execution of next test script commands (when I start_notify it doesn't execute any other command).

Do you mean that you were able to get notifications using bleak outside HA? Because at this stage I believe this is a bluez incompatibility with the candela not following proper bluetooth standard. My current code (1.3.0) do not call start_notify for the candela when using bluez backend.

Yes. When I added a line of code to start_notify I could see the notification when manually using Candela. After a few secenods there is an error (someone posted it previously, connection terminated due to security reasons), but bleak-retry-connector gracefully reconnects and the notifications keep coming without problem, but with periodic reconnection.

I have also tried an example from official bleak repo on how to use notifications. In that example there is a start_notify method, then asyncio.wait() and stop_notify. When I run this script with Candela it never stops notifications (until it crushes with an error message).

ASNNetworks commented 2 years ago

@ASNNetworks

I happen to have tested this for the last 2 days with esp32 bluetooth proxy. I use the Odroid N2+, which doesn't have a bluetooth chip, so there is no way to even enable the bluetooth integration ;)

This is a good setup to test the bluetooth proxy indeed.

I could pair the Candela without issues, it even showed on the integrations page automatically where I could configure it and save it. I have two Candela's, both can be paired without issues and also show the full MAC address. However, after pairing they're both unavailable. Both lights have greyed out toggles and won't respond to anything. Adjusting the Candela's manually also don't reflect changes in HA.

When you say "pair" do you mean the lamp started to pulse and you had to push the button on the physical light?

Interesting point: when I restarted HA, while both were turned off by the power switch, both showed an error icon since they weren't reachable during restart. However, turning on back the power of the Candela, immediately made the error sign go away in integrations page, but still no controls/state updates.

What I noticed with the bluetooth-proxy is that it is usually not yet available on first start, so you will have a message saying that the yeelight-bt integration could not be setup but it will be retried 10s after and now the bluetooth proxy is available and the integration will load

Let me know if there are stuff you need testing or a beta build that you need esp32 bluetooth proxy testing with Candela.

Are you able to launch HA enabling debug logging for yeelight_bt, bleak_retry_connector and esphome.bluetooth? That should help to find out where it fails (it could be the start_notif for esp as well...):

logger:
  logs:
    custom_components.yeelight_bt: debug
    bleak_retry_connector: debug
    homeassistant.components.esphome.bluetooth: debug

Also, do you have only one esp32? I believe at this stage you can only have one active connection per esp32, and since this light requires constant connection, I am actually not sure what it would do if you try to connect two lights (I would assume one would just not connect). Can you give the log once you have added only one light in HA?

Hi sorry I've been very busy but I just tried it today, it's not much that get's logged. I have 2 ESP's and for this test I disconnected one, removed the Candela and paired it again. I held the reset button of the Candela, then added new light through integrations and used the scan option. It showed the MAC address and I saved it. The ESP Proxy device is bluetoothproxy-kleedkamer This is what the log says:

https://pastebin.com/t46tGnUw

frr032 commented 2 years ago

Hi All,

I'm running HA 2022.10.5 and the Yeelight Integration 1.3.0. When HS is restated after adding the integration, it recognized that I have 2 candelas and I am able to add them. However, the devices are not enabled and are uncontrollable from HAS as other have reported. The on/off switch is disabled for the device and dimmer slider slides but does not control the light. Say that it unavailable.

I have removed and added the Yeelight Integration several times. Reset the candelas, etc Same behavior.

image

Not much in the error log below ...

Any suggestions to get this working?

Thanks, FRR

Error log Connection: BleakError: F8:24:41:C6:8E:2F - /org/bluez/hci0/dev_F8_24_41_C6_8E_2F: Failed to connect: [org.bluez.Error.Failed] le-connection-abort-by-local: Interference/range; External Bluetooth adapter w/extension may help; Extension cables reduce USB 3 port interference 16:44:27 – (ERROR) Yeelight bluetooth (custom integration) - message first occurred at 16:30:12 and shows up 35 times Updating yeelight_bt light took longer than the scheduled update interval 0:00:30 16:44:26 – (WARNING) Light - message first occurred at 16:30:56 and shows up 23 times Update of light.candela2 is taking over 10 seconds 16:44:06 – (WARNING) helpers/entity.py - message first occurred at 16:29:38 and shows up 36 times Failed to cancel connection (/org/bluez/hci0/dev_F8_24_41_C6_8E_2F): 16:38:06 – (WARNING) /usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py - message first occurred at 16:35:22 and shows up 3 times

frr032 commented 1 year ago

Any suggestions to resolve the Candela issue commented on Oct 23rd?

frr032 commented 1 year ago

Hi All,

I'm running HA 2022.10.5 and the Yeelight Integration 1.3.0. When HS is restated after adding the integration, it recognized that I have 2 candelas and I am able to add them. However, the devices are not enabled and are uncontrollable from HAS as other have reported. The on/off switch is disabled for the device and dimmer slider slides but does not control the light. Say that it unavailable.

I have removed and added the Yeelight Integration several times. Reset the candelas, etc Same behavior.

image

Not much in the error log below ...

Any suggestions to get this working?

Thanks, FRR

Error log Connection: BleakError: F8:24:41:C6:8E:2F - /org/bluez/hci0/dev_F8_24_41_C6_8E_2F: Failed to connect: [org.bluez.Error.Failed] le-connection-abort-by-local: Interference/range; External Bluetooth adapter w/extension may help; Extension cables reduce USB 3 port interference 16:44:27 – (ERROR) Yeelight bluetooth (custom integration) - message first occurred at 16:30:12 and shows up 35 times Updating yeelight_bt light took longer than the scheduled update interval 0:00:30 16:44:26 – (WARNING) Light - message first occurred at 16:30:56 and shows up 23 times Update of light.candela2 is taking over 10 seconds 16:44:06 – (WARNING) helpers/entity.py - message first occurred at 16:29:38 and shows up 36 times Failed to cancel connection (/org/bluez/hci0/dev_F8_24_41_C6_8E_2F): 16:38:06 – (WARNING) /usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py - message first occurred at 16:35:22 and shows up 3 times

Still looking for some help. Thanks

jojoro1 commented 6 months ago

I have the same problem. Any solutions?

grain111 commented 6 months ago

I have the same problem. Any solutions?

I managed to set it up in homebridge and it is sometimes slow but stable.

IvanVojtko commented 5 months ago

For anyone watching this. I made it working by first pairing using bluetoothctl.

bluetoothctl
connect XX:XX:XX:XX:XX:XX
pair XX:XX:XX:XX:XX:XX

After this it started working with this integration. It disconnects sometimes, but only for a few seconds.