Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[danfossairunit] Remove deprecated channel main#manual_fan_speed when unlinked #11668

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
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;
Expand Down Expand Up @@ -96,6 +98,7 @@ public void initialize() {
updateStatus(ThingStatus.UNKNOWN);
config = getConfigAs(DanfossAirUnitConfiguration.class);
valueCache = new ValueCache(config.updateUnchangedValuesEveryMillis);
removeDeprecatedChannels();
try {
var localCommunicationController = new DanfossAirUnitCommunicationController(
InetAddress.getByName(config.host), TCP_PORT);
Expand All @@ -119,6 +122,21 @@ public void initialize() {
}
}

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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@
<channel id="current_time" typeId="currentTime"/>
<channel id="mode" typeId="mode"/>
<channel id="manual_fan_step" typeId="manualFanStep"/>
<channel id="manual_fan_speed" typeId="manualFanSpeed"/>
<channel id="manual_fan_speed" typeId="manualFanStep">
jlaur marked this conversation as resolved.
Show resolved Hide resolved
<label>Manual Fan Speed</label>
<description>Deprecated, please use Manual Fan Step instead. This channel will be removed in a later version.</description>
</channel>
<channel id="supply_fan_speed" typeId="supplyFanSpeed"/>
<channel id="extract_fan_speed" typeId="extractFanSpeed"/>
<channel id="supply_fan_step" typeId="supplyFanStep"/>
Expand Down Expand Up @@ -157,13 +160,6 @@
<category>Fan</category>
<state step="10" min="0" max="100"/>
</channel-type>
<channel-type id="manualFanSpeed" advanced="true">
<item-type>Dimmer</item-type>
<label>Manual Fan Speed</label>
<description>Deprecated, please use Manual Fan Step instead. This channel will be removed in a later version.</description>
<category>Fan</category>
<state step="10" min="0" max="100"/>
</channel-type>
<channel-type id="supplyFanSpeed">
<item-type>Number</item-type>
<label>Supply Fan Speed</label>
Expand Down