From: Connor Petty Date: Sun, 8 Nov 2020 10:17:19 +0000 (-0800) Subject: Fix duplicate channel bug (#8980) X-Git-Url: https://git.basschouten.com/?a=commitdiff_plain;h=bb9a286167f94f114f921a1303a2838cd1aadbe4;p=openhab-addons.git Fix duplicate channel bug (#8980) Signed-off-by: Connor Petty --- 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); }