Improve user-facing logging and BLE id handling in device registry and PlejdBLEHandler
- Resolves #265
This commit is contained in:
parent
ae8e41ec41
commit
75306827ae
2 changed files with 31 additions and 7 deletions
|
|
@ -7,6 +7,8 @@ class DeviceRegistry {
|
|||
|
||||
/** @private @type {Object.<string, import('types/ApiSite').Device>} */
|
||||
devices = {};
|
||||
/** @private @type {Object.<string, number>} */
|
||||
mainBleIdByDeviceId = {};
|
||||
/** @private @type {Object.<string, string[]>} */
|
||||
outputDeviceUniqueIdsByRoomId = {};
|
||||
/** @private @type {Object.<number, string>} */
|
||||
|
|
@ -45,6 +47,10 @@ class DeviceRegistry {
|
|||
this.outputUniqueIdByBleOutputAddress[
|
||||
this.getUniqueBLEId(inputDevice.bleInputAddress, inputDevice.input)
|
||||
] = inputDevice.uniqueId;
|
||||
|
||||
if (!this.mainBleIdByDeviceId[inputDevice.deviceId]) {
|
||||
this.mainBleIdByDeviceId[inputDevice.deviceId] = inputDevice.bleInputAddress;
|
||||
}
|
||||
}
|
||||
|
||||
/** @param outputDevice {import('types/DeviceRegistry').OutputDevice} */
|
||||
|
|
@ -69,6 +75,9 @@ class DeviceRegistry {
|
|||
);
|
||||
|
||||
this.outputUniqueIdByBleOutputAddress[outputDevice.bleOutputAddress] = outputDevice.uniqueId;
|
||||
if (!this.mainBleIdByDeviceId[outputDevice.deviceId]) {
|
||||
this.mainBleIdByDeviceId[outputDevice.deviceId] = outputDevice.bleOutputAddress;
|
||||
}
|
||||
|
||||
if (!this.outputDeviceUniqueIdsByRoomId[outputDevice.roomId]) {
|
||||
this.outputDeviceUniqueIdsByRoomId[outputDevice.roomId] = [];
|
||||
|
|
@ -179,6 +188,14 @@ class DeviceRegistry {
|
|||
return (this.inputDevices[uniqueInputId] || {}).name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} deviceId
|
||||
*/
|
||||
getMainBleIdByDeviceId(deviceId) {
|
||||
return this.mainBleIdByDeviceId[deviceId];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {string } deviceId The physical device serial number
|
||||
* @return {import('./types/ApiSite').Device}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue