@homebridge-plugins/homebridge-govee 11.34.2-beta.11 → 11.34.2-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -0
- package/lib/connection/ble.js +24 -2
- package/lib/utils/ble-protocol.js +28 -0
- package/lib/utils/device-context.js +18 -8
- package/lib/utils/lang-en.js +4 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -25,6 +25,7 @@ All notable changes to `@homebridge-plugins/homebridge-govee` will be documented
|
|
|
25
25
|
- fix: give the H5106 a battery service, so its low battery setting does something
|
|
26
26
|
- fix: stop a light's broadcast being mistaken for an h5101 sensor reading
|
|
27
27
|
- fix: follow a device renamed in the govee app, instead of keeping its first name forever (#1344)
|
|
28
|
+
- fix: say why the bluetooth adapter would not start, rather than only that it timed out (#1344)
|
|
28
29
|
|
|
29
30
|
## v11.34.1 (2026-08-06)
|
|
30
31
|
|
package/lib/connection/ble.js
CHANGED
|
@@ -4,7 +4,7 @@ import process from 'node:process'
|
|
|
4
4
|
import btClient from '@stoprocent/noble'
|
|
5
5
|
|
|
6
6
|
import { buildHandshake, isHandshakeFrame, parseHandshakeResponse, V2Session } from '../utils/ble-crypto.js'
|
|
7
|
-
import { BLE_STAGE_TIMEOUTS, UUID } from '../utils/ble-protocol.js'
|
|
7
|
+
import { BLE_STAGE_TIMEOUTS, describeAdapterState, UUID } from '../utils/ble-protocol.js'
|
|
8
8
|
import { decodeAny } from '../utils/decode.js'
|
|
9
9
|
import { getDeviceCapabilities } from '../utils/device-capabilities.js'
|
|
10
10
|
import { base64ToHex, generateCodeFromHexValues, hexToTwoItems, sleep } from '../utils/functions.js'
|
|
@@ -42,6 +42,9 @@ export default class BLEConnection {
|
|
|
42
42
|
this.scanTimeoutId = null
|
|
43
43
|
this.isShuttingDown = false
|
|
44
44
|
|
|
45
|
+
// The power-on failure is said once, not every few minutes - see waitForPowerOn
|
|
46
|
+
this.powerOnReported = false
|
|
47
|
+
|
|
45
48
|
// Store event handler references for cleanup
|
|
46
49
|
this.eventHandlers = {
|
|
47
50
|
stateChange: null,
|
|
@@ -64,6 +67,11 @@ export default class BLEConnection {
|
|
|
64
67
|
this.btState = state
|
|
65
68
|
this.log.debug('[BLE] adapter state changed to: %s.', state)
|
|
66
69
|
|
|
70
|
+
// Someone has acted on it, so a later failure is worth saying again
|
|
71
|
+
if (state === 'poweredOn') {
|
|
72
|
+
this.powerOnReported = false
|
|
73
|
+
}
|
|
74
|
+
|
|
67
75
|
// If adapter loses power while operations are in progress, clean up
|
|
68
76
|
if (state !== 'poweredOn') {
|
|
69
77
|
this.handleAdapterPowerLoss()
|
|
@@ -224,7 +232,21 @@ export default class BLEConnection {
|
|
|
224
232
|
await btClient.waitForPoweredOnAsync(timeout)
|
|
225
233
|
return true
|
|
226
234
|
} catch (err) {
|
|
227
|
-
|
|
235
|
+
// Say what to do about it, from the state noble reported, rather than
|
|
236
|
+
// repeating its "timed out" message for every possible cause (#1344).
|
|
237
|
+
const advice = describeAdapterState(this.btState, platformLang)
|
|
238
|
+
const message = advice
|
|
239
|
+
? `${advice} [${this.btState}]`
|
|
240
|
+
: err.message
|
|
241
|
+
|
|
242
|
+
// The retry runs every few minutes, so say it once and then keep quiet -
|
|
243
|
+
// nothing changes until someone acts on it
|
|
244
|
+
if (this.powerOnReported) {
|
|
245
|
+
this.log.debug('[BLE] failed to power on adapter: %s.', message)
|
|
246
|
+
} else {
|
|
247
|
+
this.powerOnReported = true
|
|
248
|
+
this.log.warn('[BLE] failed to power on adapter: %s.', message)
|
|
249
|
+
}
|
|
228
250
|
return false
|
|
229
251
|
}
|
|
230
252
|
}
|
|
@@ -101,3 +101,31 @@ export const BLE_STAGE_TIMEOUTS = {
|
|
|
101
101
|
export const BLE_UPDATE_TIMEOUT = Object
|
|
102
102
|
.values(BLE_STAGE_TIMEOUTS)
|
|
103
103
|
.reduce((total, stage) => total + stage, 0)
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* What a noble adapter state means for the person reading the log.
|
|
107
|
+
*
|
|
108
|
+
* ⚠️ The plugin used to report only noble's own message — "Timeout waiting for
|
|
109
|
+
* Noble to be powered on" — for every one of these. That reads as a stuck
|
|
110
|
+
* adapter no matter which it is, and the three real causes need completely
|
|
111
|
+
* different fixes: a blocked radio, a missing capability, or no adapter at all.
|
|
112
|
+
* Working out which cost a reporter four days of back-and-forth (#1344), and it
|
|
113
|
+
* was knowable from the state noble had already reported.
|
|
114
|
+
*
|
|
115
|
+
* Returns undefined when the state does not point at a specific cause, so the
|
|
116
|
+
* caller can fall back to noble's own wording.
|
|
117
|
+
*/
|
|
118
|
+
export function describeAdapterState(state, lang) {
|
|
119
|
+
switch (state) {
|
|
120
|
+
case 'poweredOff':
|
|
121
|
+
return lang.blePowerBlocked
|
|
122
|
+
case 'unauthorized':
|
|
123
|
+
return lang.blePowerUnauthorized
|
|
124
|
+
case 'unsupported':
|
|
125
|
+
return lang.blePowerNoAdapter
|
|
126
|
+
case 'unknown':
|
|
127
|
+
return lang.blePowerUnknown
|
|
128
|
+
default:
|
|
129
|
+
return undefined
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -74,17 +74,27 @@ export function applyDeviceContext(platform, accessory, device, deviceConf, join
|
|
|
74
74
|
// label in the configuration.
|
|
75
75
|
//
|
|
76
76
|
// ⚠️ This used to run for LAN-only devices only, so every other device kept
|
|
77
|
-
// whatever name it was discovered under, forever.
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
// automations (#1344).
|
|
77
|
+
// whatever name it was discovered under, forever. A name HAP complains about
|
|
78
|
+
// (brackets, say) could then not be cleared without deleting the cached
|
|
79
|
+
// accessory and losing its room and automations (#1344).
|
|
81
80
|
//
|
|
82
|
-
//
|
|
83
|
-
//
|
|
84
|
-
//
|
|
81
|
+
// ⚠️ This does NOT rename anything in the Home app. HomeKit fixes the name a
|
|
82
|
+
// user sees when the accessory is first added, and a rename made there never
|
|
83
|
+
// comes back to us either. What this fixes is the name Homebridge itself
|
|
84
|
+
// shows and, through the Name characteristic, the HAP warning.
|
|
85
|
+
//
|
|
86
|
+
// `updateDisplayName` is the supported way to do it - assigning to
|
|
87
|
+
// `displayName` sets only Homebridge's copy and leaves the HAP accessory
|
|
88
|
+
// behind. It arrived in Homebridge v1.10.0, and this plugin still supports
|
|
89
|
+
// ^1.6.0, hence the check.
|
|
85
90
|
if (device.deviceName && accessory.displayName !== device.deviceName) {
|
|
86
91
|
platform.log('[%s] %s [%s].', accessory.displayName, platformLang.devRenamed, device.deviceName)
|
|
87
|
-
|
|
92
|
+
|
|
93
|
+
if (typeof accessory.updateDisplayName === 'function') {
|
|
94
|
+
accessory.updateDisplayName(device.deviceName)
|
|
95
|
+
} else {
|
|
96
|
+
accessory.displayName = device.deviceName
|
|
97
|
+
}
|
|
88
98
|
|
|
89
99
|
const hapChar = platform.api?.hap?.Characteristic
|
|
90
100
|
const infoService = accessory.getService?.(platform.api?.hap?.Service?.AccessoryInformation)
|
package/lib/utils/lang-en.js
CHANGED
|
@@ -25,6 +25,10 @@ export default {
|
|
|
25
25
|
bleScanNoStart: 'could not start sync as',
|
|
26
26
|
bleScanNoStop: 'could not stop sync as',
|
|
27
27
|
bleScanUnknown: 'reading received for unknown accessory',
|
|
28
|
+
blePowerBlocked: 'the bluetooth adapter is switched off or blocked - check `rfkill list`, and `sudo rfkill unblock bluetooth` if it is blocked',
|
|
29
|
+
blePowerNoAdapter: 'no bluetooth adapter was found - check the adapter exists and the bluetooth service is running',
|
|
30
|
+
blePowerUnauthorized: 'not allowed to use the bluetooth adapter - node needs raw network access, which a node upgrade wipes: `sudo setcap cap_net_raw+eip $(readlink -f $(which node))`, then fully restart homebridge',
|
|
31
|
+
blePowerUnknown: 'the bluetooth adapter never reported its state - check the bluetooth service is running',
|
|
28
32
|
bleStart: 'scanning started',
|
|
29
33
|
bleStop: 'scanning stopped',
|
|
30
34
|
bleTimeout: 'BLE took too long',
|
package/package.json
CHANGED