Fix duplicate channel bug (#8980)

Signed-off-by: Connor Petty <mistercpp2000+gitsignoff@gmail.com>
This commit is contained in:
Connor Petty
2020-11-08 02:17:19 -08:00
committed by GitHub
parent d3bf62bb3b
commit bb9a286167

View File

@@ -102,11 +102,17 @@ public class BeaconBluetoothHandler extends BaseThingHandler implements Bluetoot
} }
ThingBuilder builder = editThing(); ThingBuilder builder = editThing();
boolean changed = false;
for (Channel channel : createDynamicChannels()) { for (Channel channel : createDynamicChannels()) {
// we only want to add each channel, not replace all of them // we only want to add each channel, not replace all of them
if (getThing().getChannel(channel.getUID()) == null) {
builder.withChannel(channel); builder.withChannel(channel);
changed = true;
} }
}
if (changed) {
updateThing(builder.build()); updateThing(builder.build());
}
updateStatus(ThingStatus.UNKNOWN); updateStatus(ThingStatus.UNKNOWN);
} }