From 436e7c39bab68d66f43c9d9e7650a2280f36a9cb Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Tue, 27 Dec 2022 16:50:38 +0100 Subject: [PATCH] Remove deprecated channels (#14033) Signed-off-by: Jacob Laursen --- .../handler/HDPowerViewHubHandler.java | 47 ------------------- .../OH-INF/i18n/hdpowerview.properties | 1 - 2 files changed, 48 deletions(-) diff --git a/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewHubHandler.java b/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewHubHandler.java index 7cfe8778f04..8e0f5ae5f00 100644 --- a/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewHubHandler.java +++ b/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewHubHandler.java @@ -50,7 +50,6 @@ import org.openhab.binding.hdpowerview.internal.exceptions.HubException; import org.openhab.binding.hdpowerview.internal.exceptions.HubInvalidResponseException; import org.openhab.binding.hdpowerview.internal.exceptions.HubMaintenanceException; import org.openhab.binding.hdpowerview.internal.exceptions.HubProcessingException; -import org.openhab.core.library.CoreItemFactory; import org.openhab.core.library.types.OnOffType; import org.openhab.core.thing.Bridge; import org.openhab.core.thing.Channel; @@ -63,7 +62,6 @@ import org.openhab.core.thing.ThingStatusInfo; import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.BaseBridgeHandler; import org.openhab.core.thing.binding.ThingHandler; -import org.openhab.core.thing.binding.builder.ChannelBuilder; import org.openhab.core.thing.type.ChannelTypeUID; import org.openhab.core.types.Command; import org.openhab.core.types.RefreshType; @@ -100,7 +98,6 @@ public class HDPowerViewHubHandler extends BaseBridgeHandler { private List sceneCollectionCache = new CopyOnWriteArrayList<>(); private List scheduledEventCache = new CopyOnWriteArrayList<>(); private Instant userDataUpdated = Instant.MIN; - private Boolean deprecatedChannelsCreated = false; private final ChannelTypeUID sceneChannelTypeUID = new ChannelTypeUID(HDPowerViewBindingConstants.BINDING_ID, HDPowerViewBindingConstants.CHANNELTYPE_SCENE_ACTIVATE); @@ -181,7 +178,6 @@ public class HDPowerViewHubHandler extends BaseBridgeHandler { sceneCache.clear(); sceneCollectionCache.clear(); scheduledEventCache.clear(); - deprecatedChannelsCreated = false; } public HDPowerViewWebTargets getWebTargets() { @@ -481,52 +477,9 @@ public class HDPowerViewHubHandler extends BaseBridgeHandler { updateThing(editThing().withChannels(channelBuilder.build()).build()); - createDeprecatedSceneChannels(scenes); - return scenes; } - /** - * Create backwards compatible scene channels if any items configured before release 3.2 - * are still linked. Users should have a reasonable amount of time to migrate to the new - * scene channels that are connected to a channel group. - */ - private void createDeprecatedSceneChannels(List scenes) { - if (deprecatedChannelsCreated) { - // Only do this once. - return; - } - ChannelGroupUID channelGroupUid = new ChannelGroupUID(thing.getUID(), - HDPowerViewBindingConstants.CHANNEL_GROUP_SCENES); - for (Scene scene : scenes) { - String channelId = Integer.toString(scene.id); - ChannelUID newChannelUid = new ChannelUID(channelGroupUid, channelId); - ChannelUID deprecatedChannelUid = new ChannelUID(getThing().getUID(), channelId); - String description = translationProvider.getText("dynamic-channel.scene-activate.deprecated.description", - scene.getName()); - Channel channel = ChannelBuilder.create(deprecatedChannelUid, CoreItemFactory.SWITCH) - .withType(sceneChannelTypeUID).withLabel(scene.getName()).withDescription(description).build(); - logger.debug("Creating deprecated channel '{}' ('{}') to probe for linked items", deprecatedChannelUid, - scene.getName()); - updateThing(editThing().withChannel(channel).build()); - if (this.isLinked(deprecatedChannelUid) && !this.isLinked(newChannelUid)) { - logger.warn("Created deprecated channel '{}' ('{}'), please link items to '{}' instead", - deprecatedChannelUid, scene.getName(), newChannelUid); - } else { - if (this.isLinked(newChannelUid)) { - logger.debug("Removing deprecated channel '{}' ('{}') since new channel '{}' is linked", - deprecatedChannelUid, scene.getName(), newChannelUid); - - } else { - logger.debug("Removing deprecated channel '{}' ('{}') since it has no linked items", - deprecatedChannelUid, scene.getName()); - } - updateThing(editThing().withoutChannel(deprecatedChannelUid).build()); - } - } - deprecatedChannelsCreated = true; - } - private List fetchSceneCollections() throws HubInvalidResponseException, HubProcessingException, HubMaintenanceException { SceneCollections sceneCollections = webTargets.getSceneCollections(); diff --git a/bundles/org.openhab.binding.hdpowerview/src/main/resources/OH-INF/i18n/hdpowerview.properties b/bundles/org.openhab.binding.hdpowerview/src/main/resources/OH-INF/i18n/hdpowerview.properties index 6aeb6076f95..b351827fb91 100644 --- a/bundles/org.openhab.binding.hdpowerview/src/main/resources/OH-INF/i18n/hdpowerview.properties +++ b/bundles/org.openhab.binding.hdpowerview/src/main/resources/OH-INF/i18n/hdpowerview.properties @@ -73,7 +73,6 @@ offline.gone.shade-unknown-to-hub = Shade is unknown to Hub # dynamic channels dynamic-channel.scene-activate.description = Activates the scene ''{0}'' -dynamic-channel.scene-activate.deprecated.description = DEPRECATED: Activates the scene ''{0}'' dynamic-channel.scene-group-activate.description = Activates the scene group ''{0}'' dynamic-channel.automation-enabled.description = Enables/disables the automation ''{0}'' dynamic-channel.automation-enabled.label = {0}, {1}, {2}