From ae8e41ec41e8371f3022636143fff105adb7e36f Mon Sep 17 00:00:00 2001 From: swevictor Date: Tue, 3 Oct 2023 21:56:04 +0200 Subject: [PATCH] Only add a BLE output id once during discovery to account for grouping in DWN devices --- plejd/DeviceRegistry.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plejd/DeviceRegistry.js b/plejd/DeviceRegistry.js index 951652e..cf1b3c8 100644 --- a/plejd/DeviceRegistry.js +++ b/plejd/DeviceRegistry.js @@ -49,6 +49,14 @@ class DeviceRegistry { /** @param outputDevice {import('types/DeviceRegistry').OutputDevice} */ addOutputDevice(outputDevice) { + const alreadyExistingBLEDevice = this.getOutputDeviceByBleOutputAddress(outputDevice.bleOutputAddress); + if (alreadyExistingBLEDevice) { + logger.warn(`Device with output id ${outputDevice.bleOutputAddress} already exists named ${alreadyExistingBLEDevice.name}. These two devices are probably grouped in the Plejd app. If this seems to be an error, please log a GitHub issue.`); + logger.info(`NOT adding ${outputDevice.name} to device registry`); + logger.verbose(`Details of device NOT added: ${JSON.stringify(outputDevice)}`); + return; + } + this.outputDevices = { ...this.outputDevices, [outputDevice.uniqueId]: outputDevice,