From 4eea4ac4f4fa7e0af28b529a8e73c1347386a29c Mon Sep 17 00:00:00 2001 From: jlaur Date: Fri, 17 Dec 2021 19:16:13 +0100 Subject: [PATCH] [danfossairunit] Remove deprecated channel main#manual_fan_speed when unlinked (#11668) * Remove deprecated channel if unlinked. Signed-off-by: Jacob Laursen --- .../handler/DanfossAirUnitHandler.java | 18 ++++++++++++++++++ .../OH-INF/i18n/danfossairunit.properties | 4 ++-- .../resources/OH-INF/thing/thing-types.xml | 12 ++++-------- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/bundles/org.openhab.binding.danfossairunit/src/main/java/org/openhab/binding/danfossairunit/internal/handler/DanfossAirUnitHandler.java b/bundles/org.openhab.binding.danfossairunit/src/main/java/org/openhab/binding/danfossairunit/internal/handler/DanfossAirUnitHandler.java index 6b69008c9..f94e7932d 100644 --- a/bundles/org.openhab.binding.danfossairunit/src/main/java/org/openhab/binding/danfossairunit/internal/handler/DanfossAirUnitHandler.java +++ b/bundles/org.openhab.binding.danfossairunit/src/main/java/org/openhab/binding/danfossairunit/internal/handler/DanfossAirUnitHandler.java @@ -23,12 +23,14 @@ import java.util.concurrent.TimeUnit; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.danfossairunit.internal.Channel; +import org.openhab.binding.danfossairunit.internal.ChannelGroup; import org.openhab.binding.danfossairunit.internal.DanfossAirUnit; import org.openhab.binding.danfossairunit.internal.DanfossAirUnitCommunicationController; import org.openhab.binding.danfossairunit.internal.DanfossAirUnitConfiguration; import org.openhab.binding.danfossairunit.internal.DanfossAirUnitWriteAccessor; import org.openhab.binding.danfossairunit.internal.UnexpectedResponseValueException; import org.openhab.binding.danfossairunit.internal.ValueCache; +import org.openhab.core.thing.ChannelGroupUID; import org.openhab.core.thing.ChannelUID; import org.openhab.core.thing.Thing; import org.openhab.core.thing.ThingStatus; @@ -96,6 +98,7 @@ public class DanfossAirUnitHandler extends BaseThingHandler { updateStatus(ThingStatus.UNKNOWN); config = getConfigAs(DanfossAirUnitConfiguration.class); valueCache = new ValueCache(config.updateUnchangedValuesEveryMillis); + removeDeprecatedChannels(); try { var localCommunicationController = new DanfossAirUnitCommunicationController( InetAddress.getByName(config.host), TCP_PORT); @@ -119,6 +122,21 @@ public class DanfossAirUnitHandler extends BaseThingHandler { } } + private void removeDeprecatedChannels() { + ChannelGroupUID mainChannelGroupUid = new ChannelGroupUID(thing.getUID(), ChannelGroup.MAIN.getGroupName()); + ChannelUID manualFanSpeedChannelUid = new ChannelUID(mainChannelGroupUid, + Channel.CHANNEL_MANUAL_FAN_SPEED.getChannelName()); + if (this.isLinked(manualFanSpeedChannelUid)) { + ChannelUID manualFanStepChannelUid = new ChannelUID(mainChannelGroupUid, + Channel.CHANNEL_MANUAL_FAN_STEP.getChannelName()); + logger.warn("Channel '{}' is deprecated, please use '{}' instead.", manualFanSpeedChannelUid, + manualFanStepChannelUid); + } else { + logger.debug("Removing deprecated unlinked channel '{}'.", manualFanSpeedChannelUid); + updateThing(editThing().withoutChannel(manualFanSpeedChannelUid).build()); + } + } + private void updateAllChannels() { DanfossAirUnit localAirUnit = this.airUnit; if (localAirUnit == null) { diff --git a/bundles/org.openhab.binding.danfossairunit/src/main/resources/OH-INF/i18n/danfossairunit.properties b/bundles/org.openhab.binding.danfossairunit/src/main/resources/OH-INF/i18n/danfossairunit.properties index 02fe39707..7777616d2 100644 --- a/bundles/org.openhab.binding.danfossairunit/src/main/resources/OH-INF/i18n/danfossairunit.properties +++ b/bundles/org.openhab.binding.danfossairunit/src/main/resources/OH-INF/i18n/danfossairunit.properties @@ -24,6 +24,8 @@ channel-group-type.danfossairunit.humidity.channel.humidity.description = Curren channel-group-type.danfossairunit.main.label = Mode and Fan Speeds channel-group-type.danfossairunit.main.channel.boost.label = Boost channel-group-type.danfossairunit.main.channel.boost.description = Enables fan boost +channel-group-type.danfossairunit.main.channel.manual_fan_speed.label = Manual Fan Speed +channel-group-type.danfossairunit.main.channel.manual_fan_speed.description = Deprecated, please use Manual Fan Step instead. This channel will be removed in a later version. channel-group-type.danfossairunit.main.channel.night_cooling.label = Night Cooling channel-group-type.danfossairunit.main.channel.night_cooling.description = Enables night cooling channel-group-type.danfossairunit.recuperator.label = Recuperator @@ -60,8 +62,6 @@ channel-type.danfossairunit.extractFanStep.description = Current step setting of channel-type.danfossairunit.filterPeriod.label = Filter Period channel-type.danfossairunit.filterPeriod.description = Number of months between filter replacements channel-type.danfossairunit.humidity.label = Humidity -channel-type.danfossairunit.manualFanSpeed.label = Manual Fan Speed -channel-type.danfossairunit.manualFanSpeed.description = Deprecated, please use Manual Fan Step instead. This channel will be removed in a later version. channel-type.danfossairunit.manualFanStep.label = Manual Fan Step channel-type.danfossairunit.manualFanStep.description = Controls 10-step setting of the fan when operation mode is manual channel-type.danfossairunit.mode.label = Mode diff --git a/bundles/org.openhab.binding.danfossairunit/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.danfossairunit/src/main/resources/OH-INF/thing/thing-types.xml index b526e27bb..3873c72cd 100644 --- a/bundles/org.openhab.binding.danfossairunit/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.danfossairunit/src/main/resources/OH-INF/thing/thing-types.xml @@ -50,7 +50,10 @@ - + + + Deprecated, please use Manual Fan Step instead. This channel will be removed in a later version. + @@ -157,13 +160,6 @@ Fan - - Dimmer - - Deprecated, please use Manual Fan Step instead. This channel will be removed in a later version. - Fan - - Number