From bb9a286167f94f114f921a1303a2838cd1aadbe4 Mon Sep 17 00:00:00 2001 From: Connor Petty Date: Sun, 8 Nov 2020 02:17:19 -0800 Subject: [PATCH] Fix duplicate channel bug (#8980) Signed-off-by: Connor Petty --- .../binding/bluetooth/BeaconBluetoothHandler.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.binding.bluetooth/src/main/java/org/openhab/binding/bluetooth/BeaconBluetoothHandler.java b/bundles/org.openhab.binding.bluetooth/src/main/java/org/openhab/binding/bluetooth/BeaconBluetoothHandler.java index f4911c06ae..163a5b1573 100644 --- a/bundles/org.openhab.binding.bluetooth/src/main/java/org/openhab/binding/bluetooth/BeaconBluetoothHandler.java +++ b/bundles/org.openhab.binding.bluetooth/src/main/java/org/openhab/binding/bluetooth/BeaconBluetoothHandler.java @@ -102,11 +102,17 @@ public class BeaconBluetoothHandler extends BaseThingHandler implements Bluetoot } ThingBuilder builder = editThing(); + boolean changed = false; for (Channel channel : createDynamicChannels()) { // we only want to add each channel, not replace all of them - builder.withChannel(channel); + if (getThing().getChannel(channel.getUID()) == null) { + builder.withChannel(channel); + changed = true; + } + } + if (changed) { + updateThing(builder.build()); } - updateThing(builder.build()); updateStatus(ThingStatus.UNKNOWN); } -- 2.47.3