custom-components / ble_monitor

BLE monitor for passive BLE sensors
https://community.home-assistant.io/t/passive-ble-monitor-integration/
MIT License
1.89k stars 243 forks source link

BT5.0 rtl8761bu (integrations conflict) #748

Closed rchovan closed 2 years ago

rchovan commented 2 years ago

Hi, I've changed my BT 4.0 to BT 5.0 adapter, but it does not work with my LYWSDCGQ devices. Main reason why I upgraded to BT5.0 is range. I have custom debian server, and bluetooth device is on 2m long USB 3.0 shielded cable.

My old BT4.0 device is

Bus 002 Device 017: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

hci0:   Type: Primary  Bus: USB
        BD Address: 00:1A:7D:DA:71:0C  ACL MTU: 310:10  SCO MTU: 64:8
        UP RUNNING 
        RX bytes:819422 acl:600 sco:0 events:19304 errors:0
        TX bytes:9314 acl:286 sco:0 commands:196 errors:0

My new BT 5.0 device is

Bus 002 Device 016: ID 0bda:8771 Realtek Semiconductor Corp. Bluetooth Radio

hci0:   Type: Primary  Bus: USB
        BD Address: 00:E0:4C:6A:FF:03  ACL MTU: 1021:6  SCO MTU: 255:12
        UP RUNNING 
        RX bytes:5445 acl:0 sco:0 events:321 errors:0
        TX bytes:22573 acl:0 sco:0 commands:313 errors:0

With BT 5.0 I can see other devices in log, but it does not receive messages from LYWSDCGQ.

2022-02-28 09:16:12 INFO (MainThread) [homeassistant.setup] Setting up ble_monitor
2022-02-28 09:16:12 INFO (MainThread) [homeassistant.setup] Setup of domain ble_monitor took 0.0 seconds
2022-02-28 09:16:13 DEBUG (MainThread) [custom_components.ble_monitor] Initializing BLE Monitor entry (config entry): <homeassistant.config_entries.ConfigEntry object at 0x7fe0bc850510>
2022-02-28 09:16:13 DEBUG (MainThread) [custom_components.ble_monitor] async_setup_entry: domain {}
2022-02-28 09:16:13 DEBUG (MainThread) [custom_components.ble_monitor] HCI interface is [0]
2022-02-28 09:16:13 DEBUG (MainThread) [custom_components.ble_monitor] async_setup_entry: {'bt_interface': ['00:E0:4C:6A:FF:03'], 'bt_auto_restart': True, 'active_scan': False, 'discovery': True, 'period': 60, 'use_median': False, 'decimals': 1, 'log_spikes': False, 'restore_state': True, 'report_unknown': 'Off', 'devices': [{'mac': 'F8:24:41:E6:45:77', 'name': 'F82441E64577'}, {'mac': 'F8:24:41:E7:07:F2', 'name': 'F82441E707F2'}, {'mac': '58:2D:34:37:24:46', 'name': 'livingroom'}, {'mac': '58:2D:34:37:27:D0', 'name': 'sauna'}], 'is_flow': True, 'hci_interface': [0]}
2022-02-28 09:16:13 DEBUG (MainThread) [custom_components.ble_monitor] Spawning HCIdump thread
2022-02-28 09:16:13 DEBUG (MainThread) [custom_components.ble_monitor] HCIdump thread: Init
2022-02-28 09:16:13 DEBUG (MainThread) [custom_components.ble_monitor] 0 encryptors mac:key pairs loaded
2022-02-28 09:16:13 DEBUG (MainThread) [custom_components.ble_monitor] sensor whitelist: []
2022-02-28 09:16:13 DEBUG (MainThread) [custom_components.ble_monitor] 0 sensor whitelist item(s) loaded
2022-02-28 09:16:13 DEBUG (MainThread) [custom_components.ble_monitor] 0 device tracker(s) being monitored
2022-02-28 09:16:13 DEBUG (Thread-3) [custom_components.ble_monitor] HCIdump thread: Run
2022-02-28 09:16:13 DEBUG (Thread-3) [custom_components.ble_monitor] HCIdump thread: BLEScanRequester._initialized is False for hci0,  waiting for connection...
2022-02-28 09:16:14 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.ble_monitor
2022-02-28 09:16:14 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] Starting binary sensor entry startup
2022-02-28 09:16:14 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] BLE binary sensors updater initialization
2022-02-28 09:16:14 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] BLE binary sensors updater initialized
2022-02-28 09:16:14 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] Binary sensor entry setup finished
2022-02-28 09:16:14 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] Binary entities updater loop started!
2022-02-28 09:16:14 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] Binary sensor device with mac address F8:24:41:E6:45:77 has the following settings. Name: F82441E64577. Restore State: True. Reset Timer: 35
2022-02-28 09:16:14 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] Binary sensor device with mac address F8:24:41:E6:45:77 has the following settings. Name: F82441E64577. Restore State: True. Reset Timer: 35
2022-02-28 09:16:14 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] Binary sensor device with mac address F8:24:41:E7:07:F2 has the following settings. Name: F82441E707F2. Restore State: True. Reset Timer: 35
2022-02-28 09:16:14 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] Binary sensor device with mac address F8:24:41:E7:07:F2 has the following settings. Name: F82441E707F2. Restore State: True. Reset Timer: 35
2022-02-28 09:16:15 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.ble_monitor
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] Starting measuring sensor entry startup
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] BLE sensors updater initialization
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] BLE sensors updater initialized
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] Measuring sensor entry setup finished
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] Entities updater loop started!
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] async_added_to_hass called for ble remote binary single press F82441E64577
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] async_added_to_hass called for ble remote binary long press F82441E64577
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] async_added_to_hass called for ble remote binary single press F82441E707F2
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] async_added_to_hass called for ble remote binary long press F82441E707F2
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] Sensor device with mac_address F8:24:41:E6:45:77 has the following settings. Name: F82441E64577. Temperature unit: °C. Decimals: 1. Use Median: False. Restore state: True. Reset Timer: 35
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] Sensor device with mac_address F8:24:41:E6:45:77 has the following settings. Name: F82441E64577. Temperature unit: °C. Decimals: 1. Use Median: False. Restore state: True. Reset Timer: 35
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] Sensor device with mac_address F8:24:41:E7:07:F2 has the following settings. Name: F82441E707F2. Temperature unit: °C. Decimals: 1. Use Median: False. Restore state: True. Reset Timer: 35
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] Sensor device with mac_address F8:24:41:E7:07:F2 has the following settings. Name: F82441E707F2. Temperature unit: °C. Decimals: 1. Use Median: False. Restore state: True. Reset Timer: 35
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] Sensor device with mac_address 58:2D:34:37:24:46 has the following settings. Name: 582D34372446. Temperature unit: °C. Decimals: 1. Use Median: False. Restore state: True. Reset Timer: 35
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] Sensor device with mac_address 58:2D:34:37:24:46 has the following settings. Name: 582D34372446. Temperature unit: °C. Decimals: 1. Use Median: False. Restore state: True. Reset Timer: 35
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] Sensor device with mac_address 58:2D:34:37:24:46 has the following settings. Name: 582D34372446. Temperature unit: °C. Decimals: 1. Use Median: False. Restore state: True. Reset Timer: 35
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] Sensor device with mac_address 58:2D:34:37:24:46 has the following settings. Name: 582D34372446. Temperature unit: °C. Decimals: 1. Use Median: False. Restore state: True. Reset Timer: 35
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] Sensor device with mac_address 58:2D:34:37:27:D0 has the following settings. Name: 582D343727D0. Temperature unit: °C. Decimals: 1. Use Median: False. Restore state: True. Reset Timer: 35
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] Sensor device with mac_address 58:2D:34:37:27:D0 has the following settings. Name: 582D343727D0. Temperature unit: °C. Decimals: 1. Use Median: False. Restore state: True. Reset Timer: 35
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] Sensor device with mac_address 58:2D:34:37:27:D0 has the following settings. Name: 582D343727D0. Temperature unit: °C. Decimals: 1. Use Median: False. Restore state: True. Reset Timer: 35
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] Sensor device with mac_address 58:2D:34:37:27:D0 has the following settings. Name: 582D343727D0. Temperature unit: °C. Decimals: 1. Use Median: False. Restore state: True. Reset Timer: 35
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] async_added_to_hass called for ble rssi F82441E64577
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] async_added_to_hass called for ble remote F82441E64577
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] async_added_to_hass called for ble rssi F82441E707F2
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] async_added_to_hass called for ble remote F82441E707F2
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] async_added_to_hass called for ble temperature 582D34372446
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] async_added_to_hass called for ble humidity 582D34372446
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] async_added_to_hass called for ble battery 582D34372446
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] async_added_to_hass called for ble rssi 582D34372446
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] async_added_to_hass called for ble temperature 582D343727D0
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] async_added_to_hass called for ble humidity 582D343727D0
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] async_added_to_hass called for ble battery 582D343727D0
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.sensor] async_added_to_hass called for ble rssi 582D343727D0
2022-02-28 09:16:16 INFO (MainThread) [homeassistant.components.device_tracker] Setting up device_tracker.ble_monitor
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.device_tracker] Starting device tracker entry startup
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.device_tracker] BLE device tracker updater initialization
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.device_tracker] BLE device tracker updater initialized
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.device_tracker] Device Tracker entry setup finished
2022-02-28 09:16:16 DEBUG (MainThread) [custom_components.ble_monitor.device_tracker] Device tracker updater loop started!
2022-02-28 09:16:17 INFO (MainThread) [custom_components.hacs] Enable category: integration
2022-02-28 09:16:17 INFO (MainThread) [custom_components.hacs] Enable category: plugin
2022-02-28 09:16:17 INFO (MainThread) [custom_components.hacs] Enable category: theme
2022-02-28 09:16:18 ERROR (Thread-3) [custom_components.ble_monitor] HCIdump thread: Something wrong - interface hci0 not ready, and will be skipped for current scan period.
2022-02-28 09:16:18 DEBUG (Thread-3) [custom_components.ble_monitor] HCIdump thread: start main event_loop
2022-02-28 09:16:18 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'last_occurrence' when rendering '{{ value_json.last_occurrence }}'
2022-02-28 09:16:18 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'date' when rendering '{{ value_json.date }}'
2022-02-28 09:16:18 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'date' when rendering '{{ value_json.date }}'
2022-02-28 09:16:18 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'd' when rendering '{{ value_json.d }}'
2022-02-28 09:16:18 INFO (MainThread) [zigpy.ota.provider] Trådfri: OTA provider enabled
root@nas:~# systemctl stop bluetooth
root@nas:~# grep ble /HA/home-assistant.log
2022-02-28 09:16:09 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration linkplay 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-02-28 09:16:09 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration ble_monitor 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-02-28 09:16:09 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration spotcast 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-02-28 09:16:09 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration hacs 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-02-28 09:16:09 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration mikrotik_router 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-02-28 09:16:09 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration skykettle 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-02-28 09:16:10 WARNING (MainThread) [homeassistant.components.hassio.handler] Found incompatible HTTP option 'server_host'. Watchdog feature disabled
2022-02-28 09:16:12 INFO (MainThread) [homeassistant.bootstrap] Setting up stage 2: {'counter', 'hacs', 'energy', 'discovery', 'dhcp', 'zha', 'persistent_notification', 'conversation', 'heos', 'media_source', 'light', 'brother', 'input_button', 'my', 'stream', 'system_health', 'zone', 'logbook', 'sensor', 'camera', 'trace', 'spotcast', 'mobile_app', 'ipp', 'ssdp', 'input_datetime', 'blueprint', 'weather', 'binary_sensor', 'webostv', 'network', 'dialogflow', 'ble_monitor', 'xiaomi_aqara', 'wake_on_lan', 'nut', 'input_text', 'timer', 'notify', 'usb', 'map', 'automation', 'input_number', 'mikrotik_router', 'updater', 'tts', 'default_config', 'sun', 'telegram_bot', 'zeroconf', 'input_select', 'transmission', 'spotify', 'input_boolean', 'script', 'yeelight', 'media_player', 'dlna_dmr', 'scene', 'history', 'tag', 'group', 'home_connect'}
2022-02-28 09:16:12 DEBUG (MainThread) [custom_components.ble_monitor.bt_helpers] Response(header=<event_code=CommandCompleteEvent, controller_idx=0, param_len=283>, event_frame=<command_opcode=ReadControllerInformation, status=Success>, cmd_response_frame=<address=00:E0:4C:6A:FF:03, bluetooth_version=10, manufacturer=93, supported_settings=114687, current_settings={Powered: True, Connectable: False, FastConnectable: False, Discoverable: False, Bondable: False, LinkLevelSecurity: False, SecureSimplePairing: False, BREDR: True, HighSpeed: False, LowEnergy: False, Advertising: False, SecureConnections: False, DebugKeys: False, Privacy: False, ControllerConfiguration: False, StaticAddress: False, PHYConfiguration: False, WidebandSpeech: False}, class_of_device=0, name=b'RTK_BT_5.0', short_name=0>)
2022-02-28 09:16:12 INFO (MainThread) [homeassistant.setup] Setting up ble_monitor
2022-02-28 09:16:12 INFO (MainThread) [homeassistant.setup] Setup of domain ble_monitor took 0.0 seconds
2022-02-28 09:16:13 DEBUG (MainThread) [custom_components.ble_monitor] Initializing BLE Monitor entry (config entry): <homeassistant.config_entries.ConfigEntry object at 0x7fe0bc850510>
2022-02-28 09:16:13 DEBUG (MainThread) [custom_components.ble_monitor] async_setup_entry: domain {}
2022-02-28 09:16:13 DEBUG (MainThread) [custom_components.ble_monitor] HCI interface is [0]
2022-02-28 09:16:13 DEBUG (MainThread) [custom_components.ble_monitor] async_setup_entry: {'bt_interface': ['00:E0:4C:6A:FF:03'], 'bt_auto_restart': True, 'active_scan': False, 'discovery': True, 'period': 60, 'use_median': False, 'decimals': 1, 'log_spikes': False, 'restore_state': True, 'report_unknown': 'Off', 'devices': [{'mac': 'F8:24:41:E6:45:77', 'name': 'F82441E64577'}, {'mac': 'F8:24:41:E7:07:F2', 'name': 'F82441E707F2'}, {'mac': '58:2D:34:37:24:46', 'name': 'livingroom'}, {'mac': '58:2D:34:37:27:D0', 'name': 'sauna'}], 'is_flow': True, 'hci_interface': [0]}
2022-02-28 09:16:13 DEBUG (MainThread) [custom_components.ble_monitor] Spawning HCIdump thread
2022-02-28 09:16:13 DEBUG (MainThread) [custom_components.ble_monitor] HCIdump thread: Init
2022-02-28 09:16:13 DEBUG (MainThread) [custom_components.ble_monitor] 0 encryptors mac:key pairs loaded
2022-02-28 09:16:13 DEBUG (MainThread) [custom_components.ble_monitor] sensor whitelist: []
2022-02-28 09:16:13 DEBUG (MainThread) [custom_components.ble_monitor] 0 sensor whitelist item(s) loaded
2022-02-28 09:16:13 DEBUG (MainThread) [custom_components.ble_monitor] 0 device tracker(s) being monitored
2022-02-28 09:16:13 DEBUG (Thread-3) [custom_components.ble_monitor] HCIdump thread: Run
2022-02-28 09:16:13 DEBUG (Thread-3) [custom_components.ble_monitor] HCIdump thread: BLEScanRequester._initialized is False for hci0,  waiting for connection...
2022-02-28 09:16:14 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.ble_monitor
2022-02-28 09:16:14 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] Starting binary sensor entry startup
2022-02-28 09:16:14 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] BLE binary sensors updater initialization
2022-02-28 09:16:14 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] BLE binary sensors updater initialized
2022-02-28 09:16:14 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] Binary sensor entry setup finished
2022-02-28 09:16:14 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] Binary entities updater loop started!
2022-02-28 09:16:14 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] Binary sensor device with mac address F8:24:41:E6:45:77 has the following settings. Name: F82441E64577. Restore State: True. Reset Timer: 35
2022-02-28 09:16:14 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] Binary sensor device with mac address F8:24:41:E6:45:77 has the following settings. Name: F82441E64577. Restore State: True. Reset Timer: 35
2022-02-28 09:16:14 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] Binary sensor device with mac address F8:24:41:E7:07:F2 has the following settings. Name: F82441E707F2. Restore State: True. Reset Timer: 35
2022-02-28 09:16:14 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] Binary sensor device with mac address F8:24:41:E7:07:F2 has the following settings. Name: F82441E707F2. Restore State: True. Reset Timer: 35

I know, that this device need to load firmware, but it looks like it is working

[86442.612511] usb 2-10: new high-speed USB device number 10 using xhci_hcd
[86447.536645] usb 2-10: new high-speed USB device number 11 using xhci_hcd
[86459.133228] usb 2-10: reset high-speed USB device number 11 using xhci_hcd
[86459.509273] usb 2-10: reset high-speed USB device number 11 using xhci_hcd
[87001.226537] usb 2-1: new full-speed USB device number 12 using xhci_hcd
[87001.378233] Bluetooth: hci0: RTL: examining hci_ver=0a hci_rev=000b lmp_ver=0a lmp_subver=8761
[87001.379219] Bluetooth: hci0: RTL: rom_version status=0 version=1
[87001.379223] Bluetooth: hci0: RTL: loading rtl_bt/rtl8761bu_fw.bin
[87001.379269] bluetooth hci0: firmware: direct-loading firmware rtl_bt/rtl8761bu_fw.bin
[87001.379284] Bluetooth: hci0: RTL: loading rtl_bt/rtl8761bu_config.bin
[87001.379298] bluetooth hci0: firmware: direct-loading firmware rtl_bt/rtl8761bu_config.bin
[87001.379309] Bluetooth: hci0: RTL: cfg_sz 6, total sz 20522
[87001.489234] Bluetooth: hci0: RTL: fw version 0x0999646b

If you need any more logs data, feel free to ask.

Ernst79 commented 2 years ago

Did you check #738?

rchovan commented 2 years ago

Yes I read it, my device is using firmware with different version. It works randomly and for some time. I'm not sure where is the issue .

HA stopped

root@nas:~# hcitool lescan
LE Scan ...
0F:E6:5A:14:18:41 (unknown)
19:43:2E:44:96:CF (unknown)
C1:8D:6E:46:CF:00 RK-G200S-E
C1:8D:6E:46:CF:00 (unknown)
58:2D:34:37:27:D0 (unknown)
58:2D:34:37:27:D0 MJ_HT_V1
58:2D:34:37:24:46 (unknown)
DC:77:2B:67:FE:7A (unknown)
58:2D:34:37:24:46 MJ_HT_V1

It can see BLE devices outside of HA.

HA running

root@nas:~# hcitool lescan
Enable scan failed: Input/output error

It has same settings as BT4.0 device.

BT4.0

root@nas:/HA# btmgmt info
Index list with 1 item
hci0:   Primary controller
        addr 00:1A:7D:DA:71:0C version 6 manufacturer 10 class 0x2c0104
        supported settings: powered connectable fast-connectable discoverable bondable link-security ssp br/edr hs le advertising secure-conn debug-keys privacy static-addr phy-configuration 
        current settings: powered ssp br/edr le secure-conn 
        name nas
        short name 

BT5.0

root@nas:/HA# btmgmt info
Index list with 1 item

hci0:   Primary controller
        addr 00:E0:4C:6A:FF:03 version 10 manufacturer 93 class 0x2c0104
        supported settings: powered connectable fast-connectable discoverable bondable link-security ssp br/edr hs le advertising secure-conn debug-keys privacy static-addr phy-configuration 
        current settings: powered ssp br/edr le secure-conn 
        name nas
        short name 
Ernst79 commented 2 years ago

I hope @Magalex2x14 can help you with this. One thing I notice is that both BT devices report the same MAC address in your last post? I guess the BT5.0 should show a different MAC, similar as in your first post.

rchovan commented 2 years ago

sorry, copy/paste error, .. this one is correct BT5.0

root@nas:/HA# btmgmt info
Index list with 1 item

hci0:   Primary controller
        addr 00:E0:4C:6A:FF:03 version 10 manufacturer 93 class 0x2c0104
        supported settings: powered connectable fast-connectable discoverable bondable link-security ssp br/edr hs le advertising secure-conn debug-keys privacy static-addr phy-configuration 
        current settings: powered ssp br/edr le secure-conn 
        name nas
        short name 
Magalex2x14 commented 2 years ago

Hello, @rchovan ! In your situation, I'm confused by the small difference between the number of commands and events on the interface. I suspect that in the second case, almost nothing really appears on it except for the start scan commands themselves: image

Let's look further:

Magalex2x14 commented 2 years ago

Also, in the last comment here the dude writes that he had to replace the firmware file in order for the adapter to work with USB3. Try plugging it into a USB2 port if your server has one.

rchovan commented 2 years ago

Hi, I know, that it is lot of information, but maybe someone can pinpoint problem with this device. Thank you for your time and help.

My device is C-TECH BTD-01 Bluetooth 5.0 device.

I have it connected to USB2.0 desktop port with powered USB HUB (from USB port, not from adapter)

/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/6p, 5000M
    ID 1d6b:0003 Linux Foundation 3.0 root hub
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/14p, 480M
    ID 1d6b:0002 Linux Foundation 2.0 root hub
    |__ Port 2: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        ID 0bda:5411 Realtek Semiconductor Corp. RTS5411 Hub
        |__ Port 1: Dev 4, If 0, Class=Communications, Driver=cdc_acm, 12M
            ID 1cf1:0030 Dresden Elektronik ZigBee gateway [ConBee II]
        |__ Port 1: Dev 4, If 1, Class=CDC Data, Driver=cdc_acm, 12M
            ID 1cf1:0030 Dresden Elektronik ZigBee gateway [ConBee II]
        |__ Port 2: Dev 22, If 0, Class=Wireless, Driver=btusb, 12M
            ID 0bda:8771 Realtek Semiconductor Corp. 
        |__ Port 2: Dev 22, If 1, Class=Wireless, Driver=btusb, 12M
            ID 0bda:8771 Realtek Semiconductor Corp. 
        |__ Port 3: Dev 6, If 0, Class=Vendor Specific Class, Driver=pl2303, 12M
            ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port / Mobile Action MA-8910P
    |__ Port 5: Dev 5, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
        ID 051d:0002 American Power Conversion Uninterruptible Power Supply
    |__ Port 9: Dev 7, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
        ID 046d:c01d Logitech, Inc. MX510 Optical Mouse
    |__ Port 10: Dev 11, If 4, Class=Vendor Specific Class, Driver=option, 480M
        ID 12d1:1436 Huawei Technologies Co., Ltd. Broadband stick
    |__ Port 10: Dev 11, If 2, Class=CDC Data, Driver=cdc_ether, 480M
        ID 12d1:1436 Huawei Technologies Co., Ltd. Broadband stick
    |__ Port 10: Dev 11, If 0, Class=Vendor Specific Class, Driver=option, 480M
        ID 12d1:1436 Huawei Technologies Co., Ltd. Broadband stick
    |__ Port 10: Dev 11, If 5, Class=Mass Storage, Driver=usb-storage, 480M
        ID 12d1:1436 Huawei Technologies Co., Ltd. Broadband stick
    |__ Port 10: Dev 11, If 3, Class=Vendor Specific Class, Driver=option, 480M
        ID 12d1:1436 Huawei Technologies Co., Ltd. Broadband stick
    |__ Port 10: Dev 11, If 1, Class=Communications, Driver=cdc_ether, 480M
        ID 12d1:1436 Huawei Technologies Co., Ltd. Broadband stick
    |__ Port 10: Dev 11, If 6, Class=Mass Storage, Driver=usb-storage, 480M
        ID 12d1:1436 Huawei Technologies Co., Ltd. Broadband stick
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
    ID 1d6b:0002 Linux Foundation 2.0 root hub
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 480M
        ID 8087:8000 Intel Corp. Integrated Rate Matching Hub

I'm running Debian testing with this kernel

Linux nas 5.16.0-1-amd64 #1 SMP PREEMPT Debian 5.16.7-2 (2022-02-09) x86_64 GNU/Linux

Firmware for my device is installed from firmware-realtek (20210818-1) package. I can't determine version, only from dmesg output Bluetooth: hci0: RTL: fw version 0x0999646b

Here is modinfo for btrtl module :

root@nas:/HA# modinfo btrtl
filename:       /lib/modules/5.16.0-1-amd64/kernel/drivers/bluetooth/btrtl.ko
firmware:       rtl_bt/rtl8852au_config.bin
firmware:       rtl_bt/rtl8852au_fw.bin
firmware:       rtl_bt/rtl8822b_config.bin
firmware:       rtl_bt/rtl8822b_fw.bin
firmware:       rtl_bt/rtl8821a_config.bin
firmware:       rtl_bt/rtl8821a_fw.bin
firmware:       rtl_bt/rtl8761a_config.bin
firmware:       rtl_bt/rtl8761a_fw.bin
firmware:       rtl_bt/rtl8723ds_config.bin
firmware:       rtl_bt/rtl8723ds_fw.bin
firmware:       rtl_bt/rtl8723bs_config.bin
firmware:       rtl_bt/rtl8723bs_fw.bin
firmware:       rtl_bt/rtl8723b_config.bin
firmware:       rtl_bt/rtl8723b_fw.bin
firmware:       rtl_bt/rtl8723a_fw.bin
license:        GPL
version:        0.1
description:    Bluetooth support for Realtek devices ver 0.1
author:         Daniel Drake <drake@endlessm.com>
srcversion:     A598FD6D96AFC0D4B82A01F
depends:        bluetooth
retpoline:      Y
intree:         Y
name:           btrtl
vermagic:       5.16.0-1-amd64 SMP preempt mod_unload modversions 
sig_id:         PKCS#7
signer:         Debian Secure Boot CA
sig_key:        4B:6E:F5:AB:CA:66:98:25:17:8E:05:2C:84:66:7C:CB:C0:53:1F:8C
sig_hashalgo:   sha256
signature:      2B:10:4D:58:C7:64:C5:C7:5F:35:D5:46:DC:57:9F:82:7C:7F:45:32:
                7F:AD:5E:EE:D3:35:BA:8A:0D:AE:B6:0E:65:92:7B:C4:83:C9:FC:33:
                5F:10:2A:18:24:7E:67:0F:97:F4:80:1E:02:BE:0E:91:8C:C3:16:D8:
                91:60:12:ED:A3:6B:1C:96:E8:4B:2F:7F:97:C3:0A:03:C7:A6:3C:D5:
                22:9E:EC:58:F9:1D:0D:CA:4D:FE:78:59:2F:5C:41:A4:4B:4C:73:58:
                F1:55:C6:51:03:8C:02:DE:8C:47:00:A5:A3:E2:19:C9:52:94:0A:AE:
                B9:29:D8:56:1F:15:89:00:AD:DD:C7:26:BE:BE:C4:59:62:9B:3C:75:
                89:B4:68:A2:99:27:53:04:62:97:AB:84:E4:DB:D9:C7:25:6F:3A:DA:
                79:DC:9C:11:20:9F:09:BD:DE:41:34:04:3E:9D:71:AE:F0:CF:87:D5:
                73:48:27:29:BF:1E:4E:F1:8F:16:53:7B:7F:E7:39:C9:6F:E1:EF:40:
                75:A5:2B:9B:3C:26:BC:D8:DA:90:84:05:EB:C2:26:22:F6:19:B3:0D:
                51:7D:92:74:5C:52:7C:25:F3:9A:11:B0:F4:63:B8:62:AA:36:92:AB:
                62:B0:DF:9E:57:04:C2:91:D9:63:DD:98:C7:D5:83:3F

Here are md5 hashes for my files

root@nas:/HA# md5sum /lib/firmware/rtl_bt/rtl8761bu_config.bin 
49951f548b87ea0258d128195ef6e0cf  /lib/firmware/rtl_bt/rtl8761bu_config.bin
root@nas:/HA# md5sum /lib/firmware/rtl_bt/rtl8761bu_fw.bin 
f6b8f224d74ad4e9ee8490c82ff80924  /lib/firmware/rtl_bt/rtl8761bu_fw.bin

And here are hashes for files from https://linuxreviews.org/Realtek_RTL8761B

root@nas:~/rtl_bt# md5sum *
84f1760abbd8fa58d8ac1483c5c9359f  rtl8761b_config
647b1797b8586f5760205ffbdcdb2d84  rtl8761b_fw

Here are outputs from btmon with BT5.0 and BT4.0 for comparison.

bt50.log bt40.log

And this is how it looks like, it is working some time, then it stop. image

Magalex2x14 commented 2 years ago

Thanks, @rchovan, for the detailed answer. I haven't looked deep into your logs yet, but from what I see when I take a quick look at bt50.log, I'm concluding that you have some component running, whose work interrupts the scan initiated by ble_monitor - once every few seconds, a scan is initiated with parameters differ than those used by ble_monitor:

At the very beginning of the log there is a whitelist setting:

Please note that ble_monitor uses the following scan options (hardcoded), and the whitelist implemented in ble_monitor works at the top level, in python, and is not used at the hci level:

Think about which of the components you use could behave this way? Find out which device has this address - C1:8D:6E:46:CF:00. And let us know - it's very interesting.

rchovan commented 2 years ago

C1:8D:6E:46:CF:00 is Kettle Redmond RK-G200S-E. I'm using this integration https://github.com/ClusterM/skykettle-ha. image

If there is issue with this interation, it is only on BT5.0 device, because with BT4.0 they work together without problem image

Magalex2x14 commented 2 years ago

I suspect that the problem may be related to the different behavior of the utilities used by SkyKettle to access Bluetooth functions, depending on the type of interface (gattool, hcitool, etc). I can’t say for sure right now - I need to study their code, but I think that this is close to the truth. ble_monitor uses a "low-level" approach, so it doesn't have this dependency. Look at this issue also - https://github.com/ClusterM/skykettle-ha/issues/9 Simultaneous normal operation of both integrations on the same interface is pretty difficult. The negative effects may not be noticeable, but they are still present anyway. The only way I see is to distribute them to separate interfaces. hci0 for one, hci1 for the other. It is worth asking the author of SkyKettle to implement support for working on an arbitrary interface (I did not find any mention of such functionality).

Magalex2x14 commented 2 years ago

In the general case, if the integration does not often (for a long time) interrupt the scanning of the air (with the setting of a white list, for example), and does not often establish long connections, then the joint operation of such integration with ble_monitor is quite possible - the flow of data to ble_monitor will be interrupted only until the beginning of the next scan period (60 sec by default).

rchovan commented 2 years ago

Hello @Magalex2x14
I just replaced BT5.0 with BT4.0 without any change in configuration, With BT4.0 both integrations work together without problem.

ble-monitor device image

skykettle device image

Do you have any idea why it works wit BT4.0 and not with BT5.0 ?

And I've observed another thing. hcitool lescan is much much faster with BT4.0 USB than BT5.0 USB.

Magalex2x14 commented 2 years ago

@rchovan the author of the SkyKettle integration and I continued this topic here.

I'm closing this issue for now, as there's nothing we can do about it at the moment. We'll reopen if there's a reason...