I need some help with this. I recently bought a H5174 (which is not yet supported) and I added support for it (untested/unverified).
I think I am having problems in general getting the integration to work at all. While the “hcitool lescan” command always fails with “Set scan parameters failed: Input/output error”, which from what I gathered is because my machine has a Bluetooth 5.0 chip, it looks like I am getting the data using the bluetoothctl command, which is what I used to add support for this model.
Anyway, I wonder if I’m running into a bleson bug. It never gets the EVT_LE_ADVERTISING_REPORT
notification, which means “Last mfg data” always says “None”:
homeassistant_1 | 2021-05-03 09:28:32 DEBUG (SyncWorker_3) [custom_components.govee_ble_hci.sensor] update_ble_loop called
homeassistant_1 | 2021-05-03 09:28:32 DEBUG (SyncWorker_3) [custom_components.govee_ble_hci.sensor] Last mfg data for BDAddress('A4:C1:38:XX:XX:XX'): None
homeassistant_1 | 2021-05-03 09:28:43 WARNING (HCISocketPoller) [bleson] TODO: unhandled HCI Event packet, type=HCIPacket(event_name='Command_Status', event_code=15, subevent_code=None, data=b'\x02\x01\x04', length=3)
homeassistant_1 | 2021-05-03 09:29:32 DEBUG (SyncWorker_6) [custom_components.govee_ble_hci.sensor] update_ble_loop called
homeassistant_1 | 2021-05-03 09:29:32 DEBUG (SyncWorker_6) [custom_components.govee_ble_hci.sensor] Last mfg data for BDAddress('A4:C1:38:XX:XX:XX'): None
It seems like I’m getting this bleson “unhandled HCI Event packet” whenever the device sends its information.
Based on btmon output, I am getting BLE message (LE Extended Advertising Report (0x0d)) (which should be EVT_LE_ADVERTISING_REPORT
) from the sensor:
> HCI Event: LE Meta Event (0x3e) plen 53 #115 [hci0] 26.757586
LE Extended Advertising Report (0x0d)
Num reports: 1
Entry 0
Event type: 0x001a
Props: 0x001a
Scannable
Scan response
Use legacy advertising PDUs
Data status: Complete
Legacy PDU Type: SCAN_RSP to an ADV_IND (0x001a)
Address type: Public (0x00)
Address: A4:C1:38:XX:XX:XX (Telink Semiconductor (Taipei) Co. Ltd.)
Primary PHY: LE 1M
Secondary PHY: No packets
SID: no ADI field (0xff)
TX power: 0 dBm
RSSI: -75 dBm (0xb5)
Periodic advertising invteral: 0.00 msec (0x0000)
Direct address type: Public (0x00)
Direct address: 00:00:00:00:00:00 (OUI 00-00-00)
Data length: 0x1b
1a ff 4c 00 02 15 49 4e 54 45 4c 4c 49 5f 52 4f ..L...INTELLI_RO
43 4b 53 5f 48 57 50 75 f2 ff c2 CKS_HWPu...
@ MGMT Event: Device Found (0x0012) plen 72 {0x0003} [hci0] 26.757706
LE Address: A4:C1:38:XX:XX:XX (Telink Semiconductor (Taipei) Co. Ltd.)
RSSI: -75 dBm (0xb5)
Flags: 0x00000000
Data length: 58
Name (complete): GVH5174_0C44
16-bit Service UUIDs (complete): 1 entry
Unknown (0xec88)
Flags: 0x05
LE Limited Discoverable Mode
BR/EDR Not Supported
Company: Nokia Mobile Phones (1)
Data: 0101035caa64
Company: Apple, Inc. (76)
Type: iBeacon (2)
UUID: 57485f53-4b43-4f52-5f49-4c4c45544e49
Version: 30032.65522
TX power: -62 dB
My machine is a Intel NUC7PJYH (which has an integrated Bluetooth 5.0 chip) and I’m running Debian 10 Buster on it. HASS is running in a docker container. It didn’t seem to matter whether it’s running privileged or not, setting capabilities also didn’t seem to affect this. I don’t have any other Govee sensors to test with, but I suspect none of them would work.
Is this pointing to a bleson bug?
EDIT: So I think I am only getting these messages because I did a “scan on” in bluetoothctl. When I just restart HASS it seems like it can’t enable BLE scanning:
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2 #101 [hci0] 65.077794
Scanning: Enabled (0x01)
Filter duplicates: Disabled (0x00)
> HCI Event: Command Complete (0x0e) plen 4 #102 [hci0] 65.078745
LE Set Scan Enable (0x08|0x000c) ncmd 1
Status: Command Disallowed (0x0c)
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2 #103 [hci0] 66.027513
Scanning: Disabled (0x00)
Filter duplicates: Disabled (0x00)
> HCI Event: Command Complete (0x0e) plen 4 #104 [hci0] 66.027756
LE Set Scan Enable (0x08|0x000c) ncmd 1
Status: Command Disallowed (0x0c)
< HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7 #105 [hci0] 66.027794
Type: Active (0x01)
Interval: 10.000 msec (0x0010)
Window: 10.000 msec (0x0010)
Own address type: Public (0x00)
Filter policy: Accept all advertisement (0x00)
> HCI Event: Command Complete (0x0e) plen 4 #106 [hci0] 66.028752
LE Set Scan Parameters (0x08|0x000b) ncmd 1
Status: Command Disallowed (0x0c)
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2 #107 [hci0] 66.028782
Scanning: Enabled (0x01)
Filter duplicates: Disabled (0x00)
> HCI Event: Command Complete (0x0e) plen 4 #108 [hci0] 66.029749
LE Set Scan Enable (0x08|0x000c) ncmd 1
Status: Command Disallowed (0x0c)
Seems like maybe the problem is what some other projects ran into as well: use le extended commands set if supported by vicamo · Pull Request #30 · frawau/aioblescan · GitHub or Intel NUC problem (RTL8822CE also), LE Set Scan Enable -> Command disallowed) · Issue #61 · custom-components/ble_monitor · GitHub
Maybe bleson needs a similar fix?
EDIT 2: Yep I think that’s the problem, bleson doesn’t properly initiate BLE scanning. Bluetoothctl enables it like this, and it works:
@ MGMT Command: Start Discovery (0x0023) plen 1 {0x0001} [hci0] 944.311994
Address type: 0x07
BR/EDR
LE Public
LE Random
< HCI Command: LE Set Random Address (0x08|0x0005) plen 6 #193 [hci0] 944.312398
Address: 00:29:21:B2:1D:3B (Non-Resolvable)
> HCI Event: Command Complete (0x0e) plen 4 #194 [hci0] 944.426695
LE Set Random Address (0x08|0x0005) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Extended Scan Parameters (0x08|0x0041) plen 8 #195 [hci0] 944.426865
Own address type: Random (0x01)
Filter policy: Accept all advertisement (0x00)
PHYs: 0x01
Entry 0: LE 1M
Type: Active (0x01)
Interval: 11.250 msec (0x0012)
Window: 11.250 msec (0x0012)
> HCI Event: Command Complete (0x0e) plen 4 #196 [hci0] 944.427496
LE Set Extended Scan Parameters (0x08|0x0041) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Extended Scan Enable (0x08|0x0042) plen 6 #197 [hci0] 944.427572
Extended scan: Enabled (0x01)
Filter duplicates: Enabled (0x01)
Duration: 0 msec (0x0000)
Period: 0.00 sec (0x0000)
> HCI Event: Command Complete (0x0e) plen 4 #198 [hci0] 944.429497
LE Set Extended Scan Enable (0x08|0x0042) ncmd 2
Status: Success (0x00)
@ MGMT Event: Command Complete (0x0001) plen 4 {0x0001} [hci0] 944.429590
Start Discovery (0x0023) plen 1
Status: Success (0x00)
Address type: 0x07
BR/EDR
LE Public
LE Random
So, i think bleson needs this implemented: Intel NUC problem (RTL8822CE also), LE Set Scan Enable -> Command disallowed) · Issue #61 · custom-components/ble_monitor · GitHub
I wrote up a bug for this: "LE Set Scan Enable" fails with "Command Disallowed (0x0c)" on some hardware · Issue #84 · TheCellule/python-bleson · GitHub