[miio] channels removal (#9237)
Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
This commit is contained in:
parent
7bc48a220b
commit
ab3dcba5dc
@ -107,6 +107,10 @@ public final class MiIoBindingConstants {
|
|||||||
public static final String PROPERTY_TIMEOUT = "timeout";
|
public static final String PROPERTY_TIMEOUT = "timeout";
|
||||||
public static final String PROPERTY_CLOUDSERVER = "cloudServer";
|
public static final String PROPERTY_CLOUDSERVER = "cloudServer";
|
||||||
|
|
||||||
|
public static final Set<String> PERSISTENT_CHANNELS = Collections.unmodifiableSet(
|
||||||
|
Stream.of(CHANNEL_COMMAND, CHANNEL_RPC, CHANNEL_SSID, CHANNEL_BSSID, CHANNEL_RSSI, CHANNEL_LIFE)
|
||||||
|
.collect(Collectors.toSet()));
|
||||||
|
|
||||||
public static final byte[] DISCOVER_STRING = org.openhab.binding.miio.internal.Utils
|
public static final byte[] DISCOVER_STRING = org.openhab.binding.miio.internal.Utils
|
||||||
.hexStringToByteArray("21310020ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
.hexStringToByteArray("21310020ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||||
public static final int PORT = 54321;
|
public static final int PORT = 54321;
|
||||||
|
|||||||
@ -411,6 +411,13 @@ public class MiIoBasicHandler extends MiIoAbstractHandler {
|
|||||||
actions = new HashMap<>();
|
actions = new HashMap<>();
|
||||||
final MiIoBasicDevice device = this.miioDevice;
|
final MiIoBasicDevice device = this.miioDevice;
|
||||||
if (device != null) {
|
if (device != null) {
|
||||||
|
for (Channel cn : getThing().getChannels()) {
|
||||||
|
logger.trace("Channel '{}' for thing {} already exist... removing", cn.getUID(),
|
||||||
|
getThing().getUID());
|
||||||
|
if (!PERSISTENT_CHANNELS.contains(cn.getUID().getId().toString())) {
|
||||||
|
thingBuilder.withoutChannels(cn);
|
||||||
|
}
|
||||||
|
}
|
||||||
for (MiIoBasicChannel miChannel : device.getDevice().getChannels()) {
|
for (MiIoBasicChannel miChannel : device.getDevice().getChannels()) {
|
||||||
logger.debug("properties {}", miChannel);
|
logger.debug("properties {}", miChannel);
|
||||||
if (!miChannel.getType().isEmpty()) {
|
if (!miChannel.getType().isEmpty()) {
|
||||||
@ -454,13 +461,6 @@ public class MiIoBasicHandler extends MiIoAbstractHandler {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ChannelUID channelUID = new ChannelUID(getThing().getUID(), channel);
|
ChannelUID channelUID = new ChannelUID(getThing().getUID(), channel);
|
||||||
|
|
||||||
// TODO: Need to understand if this harms anything. If yes, channel only to be added when not there already.
|
|
||||||
// current way allows to have no issues when channels are changing.
|
|
||||||
if (getThing().getChannel(channel) != null) {
|
|
||||||
logger.info("Channel '{}' for thing {} already exist... removing", channel, getThing().getUID());
|
|
||||||
thingBuilder.withoutChannel(new ChannelUID(getThing().getUID(), channel));
|
|
||||||
}
|
|
||||||
ChannelBuilder newChannel = ChannelBuilder.create(channelUID, dataType).withLabel(miChannel.getFriendlyName());
|
ChannelBuilder newChannel = ChannelBuilder.create(channelUID, dataType).withLabel(miChannel.getFriendlyName());
|
||||||
boolean useGeneratedChannelType = false;
|
boolean useGeneratedChannelType = false;
|
||||||
if (!miChannel.getChannelType().isBlank()) {
|
if (!miChannel.getChannelType().isBlank()) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user