From 36802db90ed3a645edc1a417bf890c24c0f98a52 Mon Sep 17 00:00:00 2001 From: Cody Cutrer Date: Tue, 31 Dec 2024 13:08:28 -0700 Subject: [PATCH] [mqtt.homeassistant] Remove newStyleChannels temporary back-compat (#17908) This includes removing deprecated channel IDs controlled by the same flag. Signed-off-by: Cody Cutrer --- .../internal/DiscoverComponents.java | 6 +- .../mqtt/homeassistant/internal/HaID.java | 12 +-- .../internal/component/AbstractComponent.java | 29 ++--- .../component/AbstractRawSchemaLight.java | 4 +- .../internal/component/AlarmControlPanel.java | 30 ++---- .../internal/component/BinarySensor.java | 4 +- .../internal/component/Button.java | 4 +- .../internal/component/Camera.java | 4 +- .../internal/component/Climate.java | 28 ++--- .../internal/component/ComponentFactory.java | 51 +++++---- .../internal/component/Cover.java | 4 +- .../component/DefaultSchemaLight.java | 21 ++-- .../internal/component/DeviceTracker.java | 4 +- .../internal/component/DeviceTrigger.java | 16 ++- .../internal/component/Event.java | 4 +- .../homeassistant/internal/component/Fan.java | 9 +- .../internal/component/Humidifier.java | 4 +- .../internal/component/JSONSchemaLight.java | 38 +++---- .../internal/component/Light.java | 16 ++- .../internal/component/Lock.java | 4 +- .../internal/component/Number.java | 4 +- .../internal/component/Scene.java | 4 +- .../internal/component/Select.java | 4 +- .../internal/component/Sensor.java | 4 +- .../internal/component/Switch.java | 4 +- .../homeassistant/internal/component/Tag.java | 4 +- .../component/TemplateSchemaLight.java | 17 ++- .../internal/component/Text.java | 4 +- .../internal/component/Update.java | 4 +- .../internal/component/Vacuum.java | 45 +++----- .../internal/component/Valve.java | 4 +- .../internal/component/WaterHeater.java | 4 +- .../discovery/HomeAssistantDiscovery.java | 1 - .../handler/HomeAssistantThingHandler.java | 9 +- .../component/AbstractComponentTests.java | 10 -- .../AlarmControlPanelDeprecatedTests.java | 100 ------------------ .../component/AlarmControlPanelTests.java | 5 - .../internal/component/BinarySensorTests.java | 2 +- .../internal/component/ClimateTests.java | 67 ++++++------ .../component/DefaultSchemaLightTests.java | 18 ++-- .../component/DeviceTriggerTests.java | 5 - .../internal/component/FanTests.java | 20 ++-- .../component/JSONSchemaLightTests.java | 10 +- .../internal/component/SensorTests.java | 2 +- .../component/TemplateSchemaLightTests.java | 17 ++- .../internal/component/VacuumTests.java | 44 ++++---- .../HomeAssistantThingHandlerTests.java | 60 +---------- .../homeassistant/DiscoverComponentsTest.java | 2 +- .../HomeAssistantMQTTImplementationTest.java | 2 +- 49 files changed, 245 insertions(+), 523 deletions(-) delete mode 100644 bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/AlarmControlPanelDeprecatedTests.java diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/DiscoverComponents.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/DiscoverComponents.java index 3046847e947..90a58ffbfe3 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/DiscoverComponents.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/DiscoverComponents.java @@ -53,7 +53,6 @@ public class DiscoverComponents implements MqttMessageSubscriber { private final ScheduledExecutorService scheduler; private final ChannelStateUpdateListener updateListener; private final AvailabilityTracker tracker; - private final boolean newStyleChannels; protected final CompletableFuture<@Nullable Void> discoverFinishedFuture = new CompletableFuture<>(); private final Gson gson; @@ -84,7 +83,7 @@ public class DiscoverComponents implements MqttMessageSubscriber { */ public DiscoverComponents(ThingUID thingUID, ScheduledExecutorService scheduler, ChannelStateUpdateListener channelStateUpdateListener, AvailabilityTracker tracker, Gson gson, - Jinjava jinjava, UnitProvider unitProvider, boolean newStyleChannels) { + Jinjava jinjava, UnitProvider unitProvider) { this.thingUID = thingUID; this.scheduler = scheduler; this.updateListener = channelStateUpdateListener; @@ -92,7 +91,6 @@ public class DiscoverComponents implements MqttMessageSubscriber { this.jinjava = jinjava; this.unitProvider = unitProvider; this.tracker = tracker; - this.newStyleChannels = newStyleChannels; } @Override @@ -108,7 +106,7 @@ public class DiscoverComponents implements MqttMessageSubscriber { if (config.length() > 0) { try { component = ComponentFactory.createComponent(thingUID, haID, config, updateListener, tracker, scheduler, - gson, jinjava, unitProvider, newStyleChannels); + gson, jinjava, unitProvider); component.setConfigSeen(); logger.trace("Found HomeAssistant component {}", haID); diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/HaID.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/HaID.java index 7abaf4bcb15..9b24528ac8d 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/HaID.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/HaID.java @@ -187,19 +187,9 @@ public class HaID { * * @return group id */ - public String getGroupId(@Nullable final String uniqueId, boolean newStyleChannels) { + public String getGroupId(@Nullable final String uniqueId) { String result = uniqueId; - // newStyleChannels are auto-discovered things with openHAB >= 4.3.0 - // assuming the topic has both a node ID and an object ID, simply use - // the component type and object ID - without encoding(!) - // since the only character allowed in object IDs but not allowed in UID - // is `-`. It also doesn't need to be reversible, so it's okay to just - // collapse `-` to `_`. - if (!nodeID.isBlank() && newStyleChannels) { - return component + "_" + objectID.replace('-', '_'); - } - // the null test is only here so the compile knows, result is not null afterwards if (result == null || result.isBlank()) { StringBuilder str = new StringBuilder(); diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/AbstractComponent.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/AbstractComponent.java index 1aef48287da..689ddd37372 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/AbstractComponent.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/AbstractComponent.java @@ -111,7 +111,6 @@ public abstract class AbstractComponent protected final C channelConfiguration; protected boolean configSeen; - protected final boolean newStyleChannels; protected final String uniqueId; protected @Nullable String groupId; protected String componentId; @@ -121,14 +120,10 @@ public abstract class AbstractComponent * * @param componentConfiguration generic componentConfiguration with not parsed JSON config * @param clazz target configuration type - * @param newStyleChannels if new style channels should be used * @param singleChannelComponent if this component only ever has one channel, so should never be in a group - * (only if newStyleChannels is true) */ - public AbstractComponent(ComponentFactory.ComponentConfiguration componentConfiguration, Class clazz, - boolean newStyleChannels) { + public AbstractComponent(ComponentFactory.ComponentConfiguration componentConfiguration, Class clazz) { this.componentConfiguration = componentConfiguration; - this.newStyleChannels = newStyleChannels; this.channelConfigurationJson = componentConfiguration.getConfigJSON(); this.channelConfiguration = componentConfiguration.getConfig(clazz); @@ -137,18 +132,11 @@ public abstract class AbstractComponent this.haID = componentConfiguration.getHaID(); String name = channelConfiguration.getName(); - if (newStyleChannels) { - // try for a simple component/group ID first; if there are conflicts - // (components of different types, but the same object id) - // we'll resolve them later - groupId = componentId = haID.objectID.replace('-', '_'); - } else if (name != null && !name.isEmpty()) { - groupId = componentId = this.haID.getGroupId(channelConfiguration.getUniqueId(), false); - } else { - groupId = null; - componentId = ""; - } - uniqueId = haID.component + "_" + haID.getGroupId(channelConfiguration.getUniqueId(), false); + // try for a simple component/group ID first; if there are conflicts + // (components of different types, but the same object id) + // we'll resolve them later + groupId = componentId = haID.objectID.replace('-', '_'); + uniqueId = haID.component + "_" + haID.getGroupId(channelConfiguration.getUniqueId()); this.configSeen = false; @@ -199,9 +187,6 @@ public abstract class AbstractComponent protected void finalizeChannels() { addJsonAttributesChannel(); - if (!newStyleChannels) { - return; - } if (channels.size() == 1) { groupId = null; channels.values().forEach(c -> c.resetUID(buildChannelUID(componentId))); @@ -214,7 +199,7 @@ public abstract class AbstractComponent } public void resolveConflict() { - if (newStyleChannels && channels.size() == 1) { + if (channels.size() == 1) { componentId = componentId + "_" + haID.component; channels.values().forEach(c -> c.resetUID(buildChannelUID(componentId))); } else { diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/AbstractRawSchemaLight.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/AbstractRawSchemaLight.java index db7241130c3..95a5b3d3f3d 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/AbstractRawSchemaLight.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/AbstractRawSchemaLight.java @@ -33,8 +33,8 @@ abstract class AbstractRawSchemaLight extends Light { protected ComponentChannel rawChannel; protected TextValue colorModeValue; - public AbstractRawSchemaLight(ComponentFactory.ComponentConfiguration builder, boolean newStyleChannels) { - super(builder, newStyleChannels); + public AbstractRawSchemaLight(ComponentFactory.ComponentConfiguration builder) { + super(builder); hiddenChannels.add(rawChannel = buildChannel(RAW_CHANNEL_ID, ComponentChannelType.STRING, new TextValue(), "Raw state", this).stateTopic(channelConfiguration.stateTopic) .commandTopic(channelConfiguration.commandTopic, channelConfiguration.isRetain(), diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/AlarmControlPanel.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/AlarmControlPanel.java index 2976d254867..4067dc2f9a7 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/AlarmControlPanel.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/AlarmControlPanel.java @@ -35,7 +35,6 @@ import com.google.gson.annotations.SerializedName; @NonNullByDefault public class AlarmControlPanel extends AbstractComponent { public static final String STATE_CHANNEL_ID = "state"; - public static final String STATE_CHANNEL_ID_DEPRECATED = "alarm"; public static final String SWITCH_DISARM_CHANNEL_ID = "disarm"; public static final String SWITCH_ARM_HOME_CHANNEL_ID = "armhome"; public static final String SWITCH_ARM_AWAY_CHANNEL_ID = "armaway"; @@ -93,8 +92,8 @@ public class AlarmControlPanel extends AbstractComponent stateEnum = new ArrayList(List.of(STATE_DISARMED, STATE_TRIGGERED, STATE_ARMING, STATE_DISARMING, STATE_PENDING, STATE_TRIGGERED)); @@ -124,35 +123,18 @@ public class AlarmControlPanel extends AbstractComponent { protected String payloadPress = "PRESS"; } - public Button(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) { - super(componentConfiguration, ChannelConfiguration.class, newStyleChannels); + public Button(ComponentFactory.ComponentConfiguration componentConfiguration) { + super(componentConfiguration, ChannelConfiguration.class); TextValue value = new TextValue(new String[] { channelConfiguration.payloadPress }); diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Camera.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Camera.java index 94ae6c3a342..02660dd7590 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Camera.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Camera.java @@ -39,8 +39,8 @@ public class Camera extends AbstractComponent { protected String topic = ""; } - public Camera(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) { - super(componentConfiguration, ChannelConfiguration.class, newStyleChannels); + public Camera(ComponentFactory.ComponentConfiguration componentConfiguration) { + super(componentConfiguration, ChannelConfiguration.class); ImageValue value = new ImageValue(); diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Climate.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Climate.java index 6396b1e44b0..bccc4865c45 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Climate.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Climate.java @@ -49,12 +49,9 @@ public class Climate extends AbstractComponent { public static final String ACTION_CH_ID = "action"; public static final String AUX_CH_ID = "aux"; public static final String AWAY_MODE_CH_ID = "away-mode"; - public static final String AWAY_MODE_CH_ID_DEPRECATED = "awayMode"; public static final String CURRENT_HUMIDITY_CH_ID = "current-humidity"; public static final String CURRENT_TEMPERATURE_CH_ID = "current-temperature"; - public static final String CURRENT_TEMPERATURE_CH_ID_DEPRECATED = "currentTemperature"; public static final String FAN_MODE_CH_ID = "fan-mode"; - public static final String FAN_MODE_CH_ID_DEPRECATED = "fanMode"; public static final String HOLD_CH_ID = "hold"; public static final String MODE_CH_ID = "mode"; public static final String PRESET_MODE_CH_ID = "preset-mode"; @@ -62,9 +59,7 @@ public class Climate extends AbstractComponent { public static final String TARGET_HUMIDITY_CH_ID = "target-humidity"; public static final String TEMPERATURE_CH_ID = "temperature"; public static final String TEMPERATURE_HIGH_CH_ID = "temperature-high"; - public static final String TEMPERATURE_HIGH_CH_ID_DEPRECATED = "temperatureHigh"; public static final String TEMPERATURE_LOW_CH_ID = "temperature-low"; - public static final String TEMPERATURE_LOW_CH_ID_DEPRECATED = "temperatureLow"; public static final String POWER_CH_ID = "power"; private static final String ACTION_OFF = "off"; @@ -224,8 +219,8 @@ public class Climate extends AbstractComponent { protected Boolean sendIfOff = true; } - public Climate(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) { - super(componentConfiguration, ChannelConfiguration.class, newStyleChannels); + public Climate(ComponentFactory.ComponentConfiguration componentConfiguration) { + super(componentConfiguration, ChannelConfiguration.class); TemperatureUnit temperatureUnit = channelConfiguration.temperatureUnit; if (channelConfiguration.temperatureUnit == null) { @@ -250,8 +245,7 @@ public class Climate extends AbstractComponent { channelConfiguration.auxCommandTopic, channelConfiguration.auxStateTemplate, channelConfiguration.auxStateTopic, commandFilter); - buildOptionalChannel(newStyleChannels ? AWAY_MODE_CH_ID : AWAY_MODE_CH_ID_DEPRECATED, - ComponentChannelType.SWITCH, new OnOffValue(), updateListener, null, + buildOptionalChannel(AWAY_MODE_CH_ID, ComponentChannelType.SWITCH, new OnOffValue(), updateListener, null, channelConfiguration.awayModeCommandTopic, channelConfiguration.awayModeStateTemplate, channelConfiguration.awayModeStateTopic, commandFilter); @@ -259,12 +253,12 @@ public class Climate extends AbstractComponent { new NumberValue(new BigDecimal(0), new BigDecimal(100), null, Units.PERCENT), updateListener, null, null, channelConfiguration.currentHumidityTemplate, channelConfiguration.currentHumidityTopic, null); - buildOptionalChannel(newStyleChannels ? CURRENT_TEMPERATURE_CH_ID : CURRENT_TEMPERATURE_CH_ID_DEPRECATED, - ComponentChannelType.TEMPERATURE, new NumberValue(null, null, precision, temperatureUnit.getUnit()), - updateListener, null, null, channelConfiguration.currentTemperatureTemplate, - channelConfiguration.currentTemperatureTopic, commandFilter); + buildOptionalChannel(CURRENT_TEMPERATURE_CH_ID, ComponentChannelType.TEMPERATURE, + new NumberValue(null, null, precision, temperatureUnit.getUnit()), updateListener, null, null, + channelConfiguration.currentTemperatureTemplate, channelConfiguration.currentTemperatureTopic, + commandFilter); - buildOptionalChannel(newStyleChannels ? FAN_MODE_CH_ID : FAN_MODE_CH_ID_DEPRECATED, ComponentChannelType.STRING, + buildOptionalChannel(FAN_MODE_CH_ID, ComponentChannelType.STRING, new TextValue(channelConfiguration.fanModes.toArray(new String[0])), updateListener, channelConfiguration.fanModeCommandTemplate, channelConfiguration.fanModeCommandTopic, channelConfiguration.fanModeStateTemplate, channelConfiguration.fanModeStateTopic, commandFilter); @@ -306,16 +300,14 @@ public class Climate extends AbstractComponent { channelConfiguration.temperatureCommandTopic, channelConfiguration.temperatureStateTemplate, channelConfiguration.temperatureStateTopic, commandFilter); - buildOptionalChannel(newStyleChannels ? TEMPERATURE_HIGH_CH_ID : TEMPERATURE_HIGH_CH_ID_DEPRECATED, - ComponentChannelType.TEMPERATURE, + buildOptionalChannel(TEMPERATURE_HIGH_CH_ID, ComponentChannelType.TEMPERATURE, new NumberValue(channelConfiguration.minTemp, channelConfiguration.maxTemp, channelConfiguration.tempStep, temperatureUnit.getUnit()), updateListener, channelConfiguration.temperatureHighCommandTemplate, channelConfiguration.temperatureHighCommandTopic, channelConfiguration.temperatureHighStateTemplate, channelConfiguration.temperatureHighStateTopic, commandFilter); - buildOptionalChannel(newStyleChannels ? TEMPERATURE_LOW_CH_ID : TEMPERATURE_LOW_CH_ID_DEPRECATED, - ComponentChannelType.TEMPERATURE, + buildOptionalChannel(TEMPERATURE_LOW_CH_ID, ComponentChannelType.TEMPERATURE, new NumberValue(channelConfiguration.minTemp, channelConfiguration.maxTemp, channelConfiguration.tempStep, temperatureUnit.getUnit()), updateListener, channelConfiguration.temperatureLowCommandTemplate, diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/ComponentFactory.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/ComponentFactory.java index a6d4e819487..1e0a1edd77a 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/ComponentFactory.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/ComponentFactory.java @@ -48,59 +48,58 @@ public class ComponentFactory { */ public static AbstractComponent createComponent(ThingUID thingUID, HaID haID, String channelConfigurationJSON, ChannelStateUpdateListener updateListener, AvailabilityTracker tracker, ScheduledExecutorService scheduler, - Gson gson, Jinjava jinjava, UnitProvider unitProvider, boolean newStyleChannels) - throws ConfigurationException { + Gson gson, Jinjava jinjava, UnitProvider unitProvider) throws ConfigurationException { ComponentConfiguration componentConfiguration = new ComponentConfiguration(thingUID, haID, channelConfigurationJSON, gson, jinjava, updateListener, tracker, scheduler, unitProvider); switch (haID.component) { case "alarm_control_panel": - return new AlarmControlPanel(componentConfiguration, newStyleChannels); + return new AlarmControlPanel(componentConfiguration); case "binary_sensor": - return new BinarySensor(componentConfiguration, newStyleChannels); + return new BinarySensor(componentConfiguration); case "button": - return new Button(componentConfiguration, newStyleChannels); + return new Button(componentConfiguration); case "camera": - return new Camera(componentConfiguration, newStyleChannels); + return new Camera(componentConfiguration); case "climate": - return new Climate(componentConfiguration, newStyleChannels); + return new Climate(componentConfiguration); case "cover": - return new Cover(componentConfiguration, newStyleChannels); + return new Cover(componentConfiguration); case "device_automation": - return new DeviceTrigger(componentConfiguration, newStyleChannels); + return new DeviceTrigger(componentConfiguration); case "device_tracker": - return new DeviceTracker(componentConfiguration, newStyleChannels); + return new DeviceTracker(componentConfiguration); case "event": - return new Event(componentConfiguration, newStyleChannels); + return new Event(componentConfiguration); case "fan": - return new Fan(componentConfiguration, newStyleChannels); + return new Fan(componentConfiguration); case "humidifier": - return new Humidifier(componentConfiguration, newStyleChannels); + return new Humidifier(componentConfiguration); case "light": - return Light.create(componentConfiguration, newStyleChannels); + return Light.create(componentConfiguration); case "lock": - return new Lock(componentConfiguration, newStyleChannels); + return new Lock(componentConfiguration); case "number": - return new Number(componentConfiguration, newStyleChannels); + return new Number(componentConfiguration); case "scene": - return new Scene(componentConfiguration, newStyleChannels); + return new Scene(componentConfiguration); case "select": - return new Select(componentConfiguration, newStyleChannels); + return new Select(componentConfiguration); case "sensor": - return new Sensor(componentConfiguration, newStyleChannels); + return new Sensor(componentConfiguration); case "switch": - return new Switch(componentConfiguration, newStyleChannels); + return new Switch(componentConfiguration); case "tag": - return new Tag(componentConfiguration, newStyleChannels); + return new Tag(componentConfiguration); case "text": - return new Text(componentConfiguration, newStyleChannels); + return new Text(componentConfiguration); case "update": - return new Update(componentConfiguration, newStyleChannels); + return new Update(componentConfiguration); case "vacuum": - return new Vacuum(componentConfiguration, newStyleChannels); + return new Vacuum(componentConfiguration); case "valve": - return new Valve(componentConfiguration, newStyleChannels); + return new Valve(componentConfiguration); case "water_heater": - return new WaterHeater(componentConfiguration, newStyleChannels); + return new WaterHeater(componentConfiguration); default: throw new UnsupportedComponentException("Component '" + haID + "' is unsupported!"); } diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Cover.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Cover.java index 2aad521fec4..b0f2ecc53ae 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Cover.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Cover.java @@ -88,8 +88,8 @@ public class Cover extends AbstractComponent { @Nullable ComponentChannel stateChannel = null; - public Cover(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) { - super(componentConfiguration, ChannelConfiguration.class, newStyleChannels); + public Cover(ComponentFactory.ComponentConfiguration componentConfiguration) { + super(componentConfiguration, ChannelConfiguration.class); boolean optimistic = false; Boolean localOptimistic = channelConfiguration.optimistic; diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/DefaultSchemaLight.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/DefaultSchemaLight.java index 8a4e4a019a4..b603d995f86 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/DefaultSchemaLight.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/DefaultSchemaLight.java @@ -55,17 +55,16 @@ public class DefaultSchemaLight extends Light { protected @Nullable ComponentChannel rgbChannel; protected @Nullable ComponentChannel xyChannel; - public DefaultSchemaLight(ComponentFactory.ComponentConfiguration builder, boolean newStyleChannels) { - super(builder, newStyleChannels); + public DefaultSchemaLight(ComponentFactory.ComponentConfiguration builder) { + super(builder); } @Override protected void buildChannels() { AutoUpdatePolicy autoUpdatePolicy = optimistic ? AutoUpdatePolicy.RECOMMEND : null; ComponentChannel localOnOffChannel; - localOnOffChannel = onOffChannel = buildChannel( - newStyleChannels ? SWITCH_CHANNEL_ID : SWITCH_CHANNEL_ID_DEPRECATED, ComponentChannelType.SWITCH, - onOffValue, "On/Off State", this) + localOnOffChannel = onOffChannel = buildChannel(SWITCH_CHANNEL_ID, ComponentChannelType.SWITCH, onOffValue, + "On/Off State", this) .stateTopic(channelConfiguration.stateTopic, channelConfiguration.stateValueTemplate) .commandTopic(channelConfiguration.commandTopic, channelConfiguration.isRetain(), channelConfiguration.getQos()) @@ -92,15 +91,14 @@ public class DefaultSchemaLight extends Light { } if (channelConfiguration.colorModeStateTopic != null) { - buildChannel(newStyleChannels ? COLOR_MODE_CHANNEL_ID : COLOR_MODE_CHANNEL_ID_DEPRECATED, - ComponentChannelType.STRING, new TextValue(), "Current color mode", this) + buildChannel(COLOR_MODE_CHANNEL_ID, ComponentChannelType.STRING, new TextValue(), "Current color mode", + this) .stateTopic(channelConfiguration.colorModeStateTopic, channelConfiguration.colorModeValueTemplate) .inferOptimistic(channelConfiguration.optimistic).build(); } if (channelConfiguration.colorTempStateTopic != null || channelConfiguration.colorTempCommandTopic != null) { - buildChannel(newStyleChannels ? COLOR_TEMP_CHANNEL_ID : COLOR_TEMP_CHANNEL_ID_DEPRECATED, - ComponentChannelType.NUMBER, colorTempValue, "Color Temperature", this) + buildChannel(COLOR_TEMP_CHANNEL_ID, ComponentChannelType.NUMBER, colorTempValue, "Color Temperature", this) .stateTopic(channelConfiguration.colorTempStateTopic, channelConfiguration.colorTempValueTemplate) .commandTopic(channelConfiguration.colorTempCommandTopic, channelConfiguration.isRetain(), channelConfiguration.getQos()) @@ -180,7 +178,7 @@ public class DefaultSchemaLight extends Light { hiddenChannels.add(localOnOffChannel); channels.put(BRIGHTNESS_CHANNEL_ID, localBrightnessChannel); } else { - channels.put(newStyleChannels ? SWITCH_CHANNEL_ID : SWITCH_CHANNEL_ID_DEPRECATED, localOnOffChannel); + channels.put(SWITCH_CHANNEL_ID, localOnOffChannel); } } @@ -329,8 +327,7 @@ public class DefaultSchemaLight extends Light { } else { listener.updateChannelState(primaryChannelUID, state); } - } else if (id.equals(newStyleChannels ? COLOR_TEMP_CHANNEL_ID : COLOR_TEMP_CHANNEL_ID_DEPRECATED) - || channel.getIdWithoutGroup().equals(EFFECT_CHANNEL_ID)) { + } else if (id.equals(COLOR_TEMP_CHANNEL_ID) || channel.getIdWithoutGroup().equals(EFFECT_CHANNEL_ID)) { // Real channels; pass through listener.updateChannelState(channel, state); } else if (id.equals(HS_CHANNEL_ID) || id.equals(XY_CHANNEL_ID)) { diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/DeviceTracker.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/DeviceTracker.java index 70b47010ba8..982bb46d17e 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/DeviceTracker.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/DeviceTracker.java @@ -98,8 +98,8 @@ public class DeviceTracker extends AbstractComponent impleme private final HomeAssistantChannelTransformation transformation; - public Event(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) { - super(componentConfiguration, ChannelConfiguration.class, newStyleChannels); + public Event(ComponentFactory.ComponentConfiguration componentConfiguration) { + super(componentConfiguration, ChannelConfiguration.class); transformation = new HomeAssistantChannelTransformation(getJinjava(), this, ""); diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Fan.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Fan.java index 99394e08860..8928217165b 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Fan.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Fan.java @@ -44,7 +44,6 @@ import com.google.gson.annotations.SerializedName; @NonNullByDefault public class Fan extends AbstractComponent implements ChannelStateUpdateListener { public static final String SWITCH_CHANNEL_ID = "switch"; - public static final String SWITCH_CHANNEL_ID_DEPRECATED = "fan"; public static final String SPEED_CHANNEL_ID = "speed"; public static final String PRESET_MODE_CHANNEL_ID = "preset-mode"; public static final String OSCILLATION_CHANNEL_ID = "oscillation"; @@ -131,16 +130,16 @@ public class Fan extends AbstractComponent implements private final ComponentChannel primaryChannel; private final ChannelStateUpdateListener channelStateUpdateListener; - public Fan(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) { - super(componentConfiguration, ChannelConfiguration.class, newStyleChannels); + public Fan(ComponentFactory.ComponentConfiguration componentConfiguration) { + super(componentConfiguration, ChannelConfiguration.class); this.channelStateUpdateListener = componentConfiguration.getUpdateListener(); onOffValue = new OnOffValue(channelConfiguration.payloadOn, channelConfiguration.payloadOff); ChannelStateUpdateListener onOffListener = channelConfiguration.percentageCommandTopic == null ? componentConfiguration.getUpdateListener() : this; - onOffChannel = buildChannel(newStyleChannels ? SWITCH_CHANNEL_ID : SWITCH_CHANNEL_ID_DEPRECATED, - ComponentChannelType.SWITCH, onOffValue, "On/Off State", onOffListener) + onOffChannel = buildChannel(SWITCH_CHANNEL_ID, ComponentChannelType.SWITCH, onOffValue, "On/Off State", + onOffListener) .stateTopic(channelConfiguration.stateTopic, channelConfiguration.stateValueTemplate) .commandTopic(channelConfiguration.commandTopic, channelConfiguration.isRetain(), channelConfiguration.getQos(), channelConfiguration.commandTemplate) diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Humidifier.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Humidifier.java index cedbbde975a..111f4f88ec8 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Humidifier.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Humidifier.java @@ -108,8 +108,8 @@ public class Humidifier extends AbstractComponent modes; } - public Humidifier(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) { - super(componentConfiguration, ChannelConfiguration.class, newStyleChannels); + public Humidifier(ComponentFactory.ComponentConfiguration componentConfiguration) { + super(componentConfiguration, ChannelConfiguration.class); if (!PLATFORM_HUMIDIFIER.equals(channelConfiguration.platform)) { throw new ConfigurationException("platform must be " + PLATFORM_HUMIDIFIER); diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/JSONSchemaLight.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/JSONSchemaLight.java index d21651a8f55..f446d19fb0e 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/JSONSchemaLight.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/JSONSchemaLight.java @@ -76,8 +76,8 @@ public class JSONSchemaLight extends AbstractRawSchemaLight { protected @Nullable Integer transition; } - public JSONSchemaLight(ComponentFactory.ComponentConfiguration builder, boolean newStyleChannels) { - super(builder, newStyleChannels); + public JSONSchemaLight(ComponentFactory.ComponentConfiguration builder) { + super(builder); } @Override @@ -91,17 +91,15 @@ public class JSONSchemaLight extends AbstractRawSchemaLight { } if (supportedColorModes.contains(LightColorMode.COLOR_MODE_COLOR_TEMP)) { - colorTempChannel = buildChannel( - newStyleChannels ? COLOR_TEMP_CHANNEL_ID : COLOR_TEMP_CHANNEL_ID_DEPRECATED, - ComponentChannelType.NUMBER, colorTempValue, "Color Temperature", this) - .commandTopic(DUMMY_TOPIC, true, 1).commandFilter(command -> handleColorTempCommand(command)) + colorTempChannel = buildChannel(COLOR_TEMP_CHANNEL_ID, ComponentChannelType.NUMBER, colorTempValue, + "Color Temperature", this).commandTopic(DUMMY_TOPIC, true, 1) + .commandFilter(command -> handleColorTempCommand(command)) .withAutoUpdatePolicy(autoUpdatePolicy).build(); if (hasColorChannel) { colorModeValue = new TextValue( supportedColorModes.stream().map(LightColorMode::serializedName).toArray(String[]::new)); - buildChannel(newStyleChannels ? COLOR_MODE_CHANNEL_ID : COLOR_MODE_CHANNEL_ID_DEPRECATED, - ComponentChannelType.STRING, colorModeValue, "Color Mode", this) + buildChannel(COLOR_MODE_CHANNEL_ID, ComponentChannelType.STRING, colorModeValue, "Color Mode", this) .withAutoUpdatePolicy(autoUpdatePolicy).isAdvanced(true).build(); } @@ -117,9 +115,9 @@ public class JSONSchemaLight extends AbstractRawSchemaLight { "Brightness", this).commandTopic(DUMMY_TOPIC, true, 1).commandFilter(this::handleCommand) .withAutoUpdatePolicy(autoUpdatePolicy).build(); } else { - onOffChannel = buildChannel(newStyleChannels ? SWITCH_CHANNEL_ID : SWITCH_CHANNEL_ID_DEPRECATED, - ComponentChannelType.SWITCH, onOffValue, "On/Off State", this).commandTopic(DUMMY_TOPIC, true, 1) - .commandFilter(this::handleCommand).withAutoUpdatePolicy(autoUpdatePolicy).build(); + onOffChannel = buildChannel(SWITCH_CHANNEL_ID, ComponentChannelType.SWITCH, onOffValue, "On/Off State", + this).commandTopic(DUMMY_TOPIC, true, 1).commandFilter(this::handleCommand) + .withAutoUpdatePolicy(autoUpdatePolicy).build(); } if (effectValue != null) { @@ -314,8 +312,7 @@ public class JSONSchemaLight extends AbstractRawSchemaLight { } else { colorTempValue .update(new QuantityType(Objects.requireNonNull(jsonState.colorTemp), Units.MIRED)); - listener.updateChannelState(buildChannelUID( - newStyleChannels ? COLOR_TEMP_CHANNEL_ID : COLOR_TEMP_CHANNEL_ID_DEPRECATED), + listener.updateChannelState(buildChannelUID(COLOR_TEMP_CHANNEL_ID), colorTempValue.getChannelState()); // Populate the color channel (if there is one) to match the color temperature. @@ -342,8 +339,7 @@ public class JSONSchemaLight extends AbstractRawSchemaLight { if (colorTempChannel != null) { double kelvin = ColorUtil.xyToKelvin(xy); colorTempValue.update(new QuantityType(kelvin, Units.KELVIN)); - listener.updateChannelState(buildChannelUID( - newStyleChannels ? COLOR_TEMP_CHANNEL_ID : COLOR_TEMP_CHANNEL_ID_DEPRECATED), + listener.updateChannelState(buildChannelUID(COLOR_TEMP_CHANNEL_ID), colorTempValue.getChannelState()); } } @@ -378,9 +374,7 @@ public class JSONSchemaLight extends AbstractRawSchemaLight { final double[] xy = ColorUtil.hsbToXY(colorState); double kelvin = ColorUtil.xyToKelvin(new double[] { xy[0], xy[1] }); colorTempValue.update(new QuantityType(kelvin, Units.KELVIN)); - listener.updateChannelState( - buildChannelUID( - newStyleChannels ? COLOR_TEMP_CHANNEL_ID : COLOR_TEMP_CHANNEL_ID_DEPRECATED), + listener.updateChannelState(buildChannelUID(COLOR_TEMP_CHANNEL_ID), colorTempValue.getChannelState()); } @@ -389,9 +383,7 @@ public class JSONSchemaLight extends AbstractRawSchemaLight { // https://github.com/home-assistant/core/blob/4f965f0eca09f0d12ae1c98c6786054063a36b44/homeassistant/components/mqtt/light/schema_json.py#L258 if (jsonState.colorTemp != null) { colorTempValue.update(new QuantityType(Objects.requireNonNull(jsonState.colorTemp), Units.MIRED)); - listener.updateChannelState( - buildChannelUID( - newStyleChannels ? COLOR_TEMP_CHANNEL_ID : COLOR_TEMP_CHANNEL_ID_DEPRECATED), + listener.updateChannelState(buildChannelUID(COLOR_TEMP_CHANNEL_ID), colorTempValue.getChannelState()); colorModeValue.update(new StringType(LightColorMode.COLOR_MODE_COLOR_TEMP.serializedName())); @@ -419,9 +411,7 @@ public class JSONSchemaLight extends AbstractRawSchemaLight { logger.warn("Invalid color value for {}", getHaID()); } - listener.updateChannelState( - buildChannelUID(newStyleChannels ? COLOR_MODE_CHANNEL_ID : COLOR_MODE_CHANNEL_ID_DEPRECATED), - colorModeValue.getChannelState()); + listener.updateChannelState(buildChannelUID(COLOR_MODE_CHANNEL_ID), colorModeValue.getChannelState()); if (localColorChannel != null) { listener.updateChannelState(localColorChannel.getChannel().getUID(), colorValue.getChannelState()); diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Light.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Light.java index d704679adef..6fd24adff89 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Light.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Light.java @@ -56,12 +56,9 @@ public abstract class Light extends AbstractComponent { private OnOffValue lockValue; private TextValue stateValue; - public Lock(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) { - super(componentConfiguration, ChannelConfiguration.class, newStyleChannels); + public Lock(ComponentFactory.ComponentConfiguration componentConfiguration) { + super(componentConfiguration, ChannelConfiguration.class); this.optimistic = channelConfiguration.optimistic || channelConfiguration.stateTopic.isBlank(); diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Number.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Number.java index acce7e5bf3f..fe33c809f6c 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Number.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Number.java @@ -64,8 +64,8 @@ public class Number extends AbstractComponent { protected String mode = "auto"; } - public Number(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) { - super(componentConfiguration, ChannelConfiguration.class, newStyleChannels); + public Number(ComponentFactory.ComponentConfiguration componentConfiguration) { + super(componentConfiguration, ChannelConfiguration.class); NumberValue value = new NumberValue(channelConfiguration.min, channelConfiguration.max, channelConfiguration.step, UnitUtils.parseUnit(channelConfiguration.unitOfMeasurement)); diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Scene.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Scene.java index 695e0844b03..ff17d456b2c 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Scene.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Scene.java @@ -45,8 +45,8 @@ public class Scene extends AbstractComponent { protected String payloadOn = "ON"; } - public Scene(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) { - super(componentConfiguration, ChannelConfiguration.class, newStyleChannels); + public Scene(ComponentFactory.ComponentConfiguration componentConfiguration) { + super(componentConfiguration, ChannelConfiguration.class); TextValue value = new TextValue(new String[] { channelConfiguration.payloadOn }); diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Select.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Select.java index 150793be6af..d54ba90a100 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Select.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Select.java @@ -49,8 +49,8 @@ public class Select extends AbstractComponent { protected String[] options = new String[0]; } - public Select(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) { - super(componentConfiguration, ChannelConfiguration.class, newStyleChannels); + public Select(ComponentFactory.ComponentConfiguration componentConfiguration) { + super(componentConfiguration, ChannelConfiguration.class); TextValue value = new TextValue(channelConfiguration.options); diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Sensor.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Sensor.java index ec1d373b763..e63b92d7e05 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Sensor.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Sensor.java @@ -61,8 +61,8 @@ public class Sensor extends AbstractComponent { protected String stateTopic = ""; } - public Sensor(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) { - super(componentConfiguration, ChannelConfiguration.class, newStyleChannels); + public Sensor(ComponentFactory.ComponentConfiguration componentConfiguration) { + super(componentConfiguration, ChannelConfiguration.class); Value value; String uom = channelConfiguration.unitOfMeasurement; diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Switch.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Switch.java index 2aeac76068c..5d0e7b0b2c2 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Switch.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Switch.java @@ -54,8 +54,8 @@ public class Switch extends AbstractComponent { protected String payloadOff = "OFF"; } - public Switch(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) { - super(componentConfiguration, ChannelConfiguration.class, newStyleChannels); + public Switch(ComponentFactory.ComponentConfiguration componentConfiguration) { + super(componentConfiguration, ChannelConfiguration.class); OnOffValue value = new OnOffValue(channelConfiguration.stateOn, channelConfiguration.stateOff, channelConfiguration.payloadOn, channelConfiguration.payloadOff); diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Tag.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Tag.java index 758ac6c8a6d..371d7ab2841 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Tag.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Tag.java @@ -37,8 +37,8 @@ public class Tag extends AbstractComponent { protected String topic = ""; } - public Tag(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) { - super(componentConfiguration, ChannelConfiguration.class, newStyleChannels); + public Tag(ComponentFactory.ComponentConfiguration componentConfiguration) { + super(componentConfiguration, ChannelConfiguration.class); buildChannel(TAG_CHANNEL_ID, ComponentChannelType.TRIGGER, new TextValue(), getName(), componentConfiguration.getUpdateListener()) diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/TemplateSchemaLight.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/TemplateSchemaLight.java index e1d1035a264..539e70dea46 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/TemplateSchemaLight.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/TemplateSchemaLight.java @@ -70,8 +70,8 @@ public class TemplateSchemaLight extends AbstractRawSchemaLight { public static final String EFFECT = "effect"; } - public TemplateSchemaLight(ComponentFactory.ComponentConfiguration builder, boolean newStyleChannels) { - super(builder, newStyleChannels); + public TemplateSchemaLight(ComponentFactory.ComponentConfiguration builder) { + super(builder); transformation = new HomeAssistantChannelTransformation(getJinjava(), this, ""); } @@ -96,14 +96,13 @@ public class TemplateSchemaLight extends AbstractRawSchemaLight { "Brightness", this).commandTopic(DUMMY_TOPIC, true, 1) .commandFilter(command -> handleCommand(command)).withAutoUpdatePolicy(autoUpdatePolicy).build(); } else { - onOffChannel = buildChannel(newStyleChannels ? SWITCH_CHANNEL_ID : SWITCH_CHANNEL_ID_DEPRECATED, - ComponentChannelType.SWITCH, onOffValue, "On/Off State", this).commandTopic(DUMMY_TOPIC, true, 1) - .commandFilter(command -> handleCommand(command)).withAutoUpdatePolicy(autoUpdatePolicy).build(); + onOffChannel = buildChannel(SWITCH_CHANNEL_ID, ComponentChannelType.SWITCH, onOffValue, "On/Off State", + this).commandTopic(DUMMY_TOPIC, true, 1).commandFilter(command -> handleCommand(command)) + .withAutoUpdatePolicy(autoUpdatePolicy).build(); } if (channelConfiguration.colorTempTemplate != null) { - buildChannel(newStyleChannels ? COLOR_TEMP_CHANNEL_ID : COLOR_TEMP_CHANNEL_ID_DEPRECATED, - ComponentChannelType.NUMBER, colorTempValue, "Color Temperature", this) + buildChannel(COLOR_TEMP_CHANNEL_ID, ComponentChannelType.NUMBER, colorTempValue, "Color Temperature", this) .commandTopic(DUMMY_TOPIC, true, 1).commandFilter(command -> handleColorTempCommand(command)) .withAutoUpdatePolicy(autoUpdatePolicy).build(); } @@ -285,9 +284,7 @@ public class TemplateSchemaLight extends AbstractRawSchemaLight { } else { colorTempValue.update(new QuantityType(mireds, Units.MIRED)); } - listener.updateChannelState( - buildChannelUID(newStyleChannels ? COLOR_TEMP_CHANNEL_ID : COLOR_TEMP_CHANNEL_ID_DEPRECATED), - colorTempValue.getChannelState()); + listener.updateChannelState(buildChannelUID(COLOR_TEMP_CHANNEL_ID), colorTempValue.getChannelState()); } } diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Text.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Text.java index 690123b5007..74b53426899 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Text.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Text.java @@ -54,8 +54,8 @@ public class Text extends AbstractComponent { protected String mode = MODE_TEXT; // Presumably for a password, it should mask any controls in the UI } - public Text(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) { - super(componentConfiguration, ChannelConfiguration.class, newStyleChannels); + public Text(ComponentFactory.ComponentConfiguration componentConfiguration) { + super(componentConfiguration, ChannelConfiguration.class); TextValue value = new TextValue(); diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Update.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Update.java index 07aeb74f2d7..6e982f67262 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Update.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Update.java @@ -143,8 +143,8 @@ public class Update extends AbstractComponent imple private ReleaseState state = new ReleaseState(); private @Nullable ReleaseStateListener listener = null; - public Update(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) { - super(componentConfiguration, ChannelConfiguration.class, newStyleChannels); + public Update(ComponentFactory.ComponentConfiguration componentConfiguration) { + super(componentConfiguration, ChannelConfiguration.class); TextValue value = new TextValue(); String commandTopic = channelConfiguration.commandTopic; diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Vacuum.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Vacuum.java index 502601c0e00..3dd1d40c0c4 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Vacuum.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Vacuum.java @@ -58,13 +58,9 @@ public class Vacuum extends AbstractComponent { public static final String COMMAND_CH_ID = "command"; public static final String FAN_SPEED_CH_ID = "fan-speed"; - public static final String FAN_SPEED_CH_ID_DEPRECATED = "fanSpeed"; public static final String CUSTOM_COMMAND_CH_ID = "custom-command"; - public static final String CUSTOM_COMMAND_CH_ID_DEPRECATED = "customCommand"; public static final String BATTERY_LEVEL_CH_ID = "battery-level"; - public static final String BATTERY_LEVEL_CH_ID_DEPRECATED = "batteryLevel"; public static final String JSON_ATTRIBUTES_CH_ID = "json-attributes"; - public static final String JSON_ATTRIBUTES_CH_ID_DEPRECATED = "jsonAttributes"; public static final String STATE_CH_ID = "state"; private static final String STATE_TEMPLATE = "{{ value_json.state }}"; @@ -122,8 +118,8 @@ public class Vacuum extends AbstractComponent { * * @param componentConfiguration generic componentConfiguration with not parsed JSON config */ - public Vacuum(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) { - super(componentConfiguration, ChannelConfiguration.class, newStyleChannels); + public Vacuum(ComponentFactory.ComponentConfiguration componentConfiguration) { + super(componentConfiguration, ChannelConfiguration.class); final ChannelStateUpdateListener updateListener = componentConfiguration.getUpdateListener(); final var supportedFeatures = channelConfiguration.supportedFeatures; @@ -137,7 +133,7 @@ public class Vacuum extends AbstractComponent { addPayloadToList(supportedFeatures, FEATURE_PAUSE, channelConfiguration.payloadPause, commands); buildOptionalChannel(COMMAND_CH_ID, ComponentChannelType.STRING, new TextValue(commands.toArray(new String[0])), - updateListener, null, channelConfiguration.commandTopic, null, null); + updateListener, null, channelConfiguration.commandTopic, null, null, "Command"); final var fanSpeedList = channelConfiguration.fanSpeedList; if (supportedFeatures.contains(FEATURE_FAN_SPEED) && fanSpeedList != null && !fanSpeedList.isEmpty()) { @@ -147,21 +143,18 @@ public class Vacuum extends AbstractComponent { } var fanSpeedValue = new TextValue(fanSpeedList.toArray(new String[0]), fanSpeedCommandList); if (supportedFeatures.contains(FEATURE_STATUS)) { - buildOptionalChannel(newStyleChannels ? FAN_SPEED_CH_ID : FAN_SPEED_CH_ID_DEPRECATED, - ComponentChannelType.STRING, fanSpeedValue, updateListener, null, + buildOptionalChannel(FAN_SPEED_CH_ID, ComponentChannelType.STRING, fanSpeedValue, updateListener, null, channelConfiguration.setFanSpeedTopic, "{{ value_json.fan_speed }}", - channelConfiguration.stateTopic); + channelConfiguration.stateTopic, "Fan Speed"); } else { - buildOptionalChannel(newStyleChannels ? FAN_SPEED_CH_ID : FAN_SPEED_CH_ID_DEPRECATED, - ComponentChannelType.STRING, fanSpeedValue, updateListener, null, - channelConfiguration.setFanSpeedTopic, null, null); + buildOptionalChannel(FAN_SPEED_CH_ID, ComponentChannelType.STRING, fanSpeedValue, updateListener, null, + channelConfiguration.setFanSpeedTopic, null, null, "Fan Speed"); } } if (supportedFeatures.contains(FEATURE_SEND_COMMAND)) { - buildOptionalChannel(newStyleChannels ? CUSTOM_COMMAND_CH_ID : CUSTOM_COMMAND_CH_ID_DEPRECATED, - ComponentChannelType.STRING, new TextValue(), updateListener, null, - channelConfiguration.sendCommandTopic, null, null); + buildOptionalChannel(CUSTOM_COMMAND_CH_ID, ComponentChannelType.STRING, new TextValue(), updateListener, + null, channelConfiguration.sendCommandTopic, null, null, "Custom Command"); } if (supportedFeatures.contains(FEATURE_STATUS)) { @@ -169,32 +162,24 @@ public class Vacuum extends AbstractComponent { buildOptionalChannel(STATE_CH_ID, ComponentChannelType.STRING, new TextValue(new String[] { STATE_CLEANING, STATE_DOCKED, STATE_PAUSED, STATE_IDLE, STATE_RETURNING, STATE_ERROR }), - updateListener, null, null, STATE_TEMPLATE, channelConfiguration.stateTopic); + updateListener, null, null, STATE_TEMPLATE, channelConfiguration.stateTopic, "State"); if (supportedFeatures.contains(FEATURE_BATTERY)) { - buildOptionalChannel(newStyleChannels ? BATTERY_LEVEL_CH_ID : BATTERY_LEVEL_CH_ID_DEPRECATED, - ComponentChannelType.DIMMER, + buildOptionalChannel(BATTERY_LEVEL_CH_ID, ComponentChannelType.DIMMER, new PercentageValue(BigDecimal.ZERO, BigDecimal.valueOf(100), BigDecimal.ONE, null, null, null), - updateListener, null, null, "{{ value_json.battery_level }}", channelConfiguration.stateTopic); + updateListener, null, null, "{{ value_json.battery_level }}", channelConfiguration.stateTopic, + "Battery Level"); } } finalizeChannels(); } - // Overridden to use deprecated channel ID - @Override - protected void addJsonAttributesChannel() { - buildOptionalChannel(newStyleChannels ? JSON_ATTRIBUTES_CH_ID : JSON_ATTRIBUTES_CH_ID_DEPRECATED, - ComponentChannelType.STRING, new TextValue(), componentConfiguration.getUpdateListener(), null, null, - channelConfiguration.getJsonAttributesTemplate(), channelConfiguration.getJsonAttributesTopic()); - } - @Nullable private ComponentChannel buildOptionalChannel(String channelId, ComponentChannelType channelType, Value valueState, ChannelStateUpdateListener channelStateUpdateListener, @Nullable String commandTemplate, - @Nullable String commandTopic, @Nullable String stateTemplate, @Nullable String stateTopic) { + @Nullable String commandTopic, @Nullable String stateTemplate, @Nullable String stateTopic, String label) { if ((commandTopic != null && !commandTopic.isBlank()) || (stateTopic != null && !stateTopic.isBlank())) { - return buildChannel(channelId, channelType, valueState, getName(), channelStateUpdateListener) + return buildChannel(channelId, channelType, valueState, label, channelStateUpdateListener) .stateTopic(stateTopic, stateTemplate, channelConfiguration.getValueTemplate()) .commandTopic(commandTopic, channelConfiguration.isRetain(), channelConfiguration.getQos(), commandTemplate) diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Valve.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Valve.java index 5a0cc23cf73..ad9c8cde5a8 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Valve.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/Valve.java @@ -110,8 +110,8 @@ public class Valve extends AbstractComponent impleme private final ChannelStateUpdateListener channelStateUpdateListener; private final ObjectMapper objectMapper = new ObjectMapper(); - public Valve(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) { - super(componentConfiguration, ChannelConfiguration.class, newStyleChannels); + public Valve(ComponentFactory.ComponentConfiguration componentConfiguration) { + super(componentConfiguration, ChannelConfiguration.class); this.channelStateUpdateListener = componentConfiguration.getUpdateListener(); AutoUpdatePolicy autoUpdatePolicy = null; diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/WaterHeater.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/WaterHeater.java index 3e79c5761aa..b5124535078 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/WaterHeater.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/component/WaterHeater.java @@ -113,8 +113,8 @@ public class WaterHeater extends AbstractComponent modes = DEFAULT_MODES; } - public WaterHeater(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) { - super(componentConfiguration, ChannelConfiguration.class, newStyleChannels); + public WaterHeater(ComponentFactory.ComponentConfiguration componentConfiguration) { + super(componentConfiguration, ChannelConfiguration.class); if (!PLATFORM_WATER_HEATER.equals(channelConfiguration.platform)) { throw new ConfigurationException("platform must be " + PLATFORM_WATER_HEATER); diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/discovery/HomeAssistantDiscovery.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/discovery/HomeAssistantDiscovery.java index 0d8d99b29ff..24df91e1071 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/discovery/HomeAssistantDiscovery.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/discovery/HomeAssistantDiscovery.java @@ -163,7 +163,6 @@ public class HomeAssistantDiscovery extends AbstractMQTTDiscovery { Map properties = new HashMap<>(); properties = config.appendToProperties(properties); properties.put("deviceId", thingID); - properties.put("newStyleChannels", "true"); buildResult(thingID, thingUID, config.getThingName(), haID, properties, bridgeUID); } diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/handler/HomeAssistantThingHandler.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/handler/HomeAssistantThingHandler.java index 23216418496..193a96ced75 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/handler/HomeAssistantThingHandler.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/main/java/org/openhab/binding/mqtt/homeassistant/internal/handler/HomeAssistantThingHandler.java @@ -111,7 +111,6 @@ public class HomeAssistantThingHandler extends AbstractMQTTThingHandler private Set discoveryHomeAssistantIDs = new HashSet<>(); private boolean started; - private boolean newStyleChannels; private @Nullable Update updateComponent; /** @@ -135,11 +134,8 @@ public class HomeAssistantThingHandler extends AbstractMQTTThingHandler this.unitProvider = unitProvider; this.attributeReceiveTimeout = attributeReceiveTimeout; this.delayedProcessing = new DelayedBatchProcessing<>(attributeReceiveTimeout, this, scheduler); - - newStyleChannels = "true".equals(thing.getProperties().get("newStyleChannels")); - this.discoverComponents = new DiscoverComponents(thing.getUID(), scheduler, this, this, gson, jinjava, - unitProvider, newStyleChannels); + unitProvider); } @Override @@ -187,8 +183,7 @@ public class HomeAssistantThingHandler extends AbstractMQTTThingHandler String channelConfigurationJSON = (String) channelConfig.get("config"); try { AbstractComponent component = ComponentFactory.createComponent(thingUID, haID, - channelConfigurationJSON, this, this, scheduler, gson, jinjava, unitProvider, - newStyleChannels); + channelConfigurationJSON, this, this, scheduler, gson, jinjava, unitProvider); if (typeID.equals(MqttBindingConstants.HOMEASSISTANT_MQTT_THING)) { typeID = calculateThingTypeUID(component); } diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/AbstractComponentTests.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/AbstractComponentTests.java index febda9cf5b8..97aa1bc02fa 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/AbstractComponentTests.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/AbstractComponentTests.java @@ -82,9 +82,6 @@ public abstract class AbstractComponentTests extends AbstractHomeAssistantTests when(callbackMock.getBridge(eq(BRIDGE_UID))).thenReturn(bridgeThing); - if (useNewStyleChannels()) { - haThing.setProperty("newStyleChannels", "true"); - } thingHandler = new LatchThingHandler(haThing, channelTypeProvider, stateDescriptionProvider, channelTypeRegistry, unitProvider, SUBSCRIBE_TIMEOUT, ATTRIBUTE_RECEIVE_TIMEOUT); thingHandler.setConnection(bridgeConnection); @@ -109,13 +106,6 @@ public abstract class AbstractComponentTests extends AbstractHomeAssistantTests */ protected abstract Set getConfigTopics(); - /** - * If new style channels should be used for this test. - */ - protected boolean useNewStyleChannels() { - return false; - } - /** * Process payload to discover and configure component. Topic should be added to {@link #getConfigTopics()} * diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/AlarmControlPanelDeprecatedTests.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/AlarmControlPanelDeprecatedTests.java deleted file mode 100644 index 6881d758b69..00000000000 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/AlarmControlPanelDeprecatedTests.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Copyright (c) 2010-2024 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.mqtt.homeassistant.internal.component; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; - -import java.util.Set; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.junit.jupiter.api.Test; -import org.openhab.binding.mqtt.generic.values.TextValue; -import org.openhab.core.library.types.StringType; - -/** - * Tests for {@link AlarmControlPanel} - * - * @author Anton Kharuzhy - Initial contribution - */ -@NonNullByDefault -public class AlarmControlPanelDeprecatedTests extends AbstractComponentTests { - public static final String CONFIG_TOPIC = "alarm_control_panel/0x0000000000000000_alarm_control_panel_zigbee2mqtt"; - - @SuppressWarnings("null") - @Test - public void testAlarmControlPanel() { - // @formatter:off - var component = discoverComponent(configTopicToMqtt(CONFIG_TOPIC), - """ - { \ - "availability": [ \ - { \ - "topic": "zigbee2mqtt/bridge/state" \ - } \ - ], \ - "code": "12345", \ - "command_topic": "zigbee2mqtt/alarm/set/state", \ - "device": { \ - "identifiers": [ \ - "zigbee2mqtt_0x0000000000000000" \ - ], \ - "manufacturer": "BestAlarmEver", \ - "model": "Heavy duty super duper alarm", \ - "name": "Alarm", \ - "sw_version": "Zigbee2MQTT 1.18.2" \ - }, \ - "name": "alarm", \ - "payload_arm_away": "ARM_AWAY_", \ - "payload_arm_home": "ARM_HOME_", \ - "payload_arm_night": "ARM_NIGHT_", \ - "payload_arm_custom_bypass": "ARM_CUSTOM_BYPASS_", \ - "payload_disarm": "DISARM_", \ - "state_topic": "zigbee2mqtt/alarm/state" \ - } \ - """); - // @formatter:on - - assertThat(component.channels.size(), is(4)); - assertThat(component.getName(), is("alarm")); - - assertChannel(component, AlarmControlPanel.STATE_CHANNEL_ID_DEPRECATED, "zigbee2mqtt/alarm/state", "", "alarm", - TextValue.class); - assertChannel(component, AlarmControlPanel.SWITCH_DISARM_CHANNEL_ID, "", "zigbee2mqtt/alarm/set/state", "alarm", - TextValue.class); - assertChannel(component, AlarmControlPanel.SWITCH_ARM_AWAY_CHANNEL_ID, "", "zigbee2mqtt/alarm/set/state", - "alarm", TextValue.class); - assertChannel(component, AlarmControlPanel.SWITCH_ARM_HOME_CHANNEL_ID, "", "zigbee2mqtt/alarm/set/state", - "alarm", TextValue.class); - - publishMessage("zigbee2mqtt/alarm/state", "armed_home"); - assertState(component, AlarmControlPanel.STATE_CHANNEL_ID_DEPRECATED, new StringType("armed_home")); - publishMessage("zigbee2mqtt/alarm/state", "armed_away"); - assertState(component, AlarmControlPanel.STATE_CHANNEL_ID_DEPRECATED, new StringType("armed_away")); - - component.getChannel(AlarmControlPanel.SWITCH_DISARM_CHANNEL_ID).getState() - .publishValue(new StringType("DISARM_")); - assertPublished("zigbee2mqtt/alarm/set/state", "DISARM_"); - component.getChannel(AlarmControlPanel.SWITCH_ARM_AWAY_CHANNEL_ID).getState() - .publishValue(new StringType("ARM_AWAY_")); - assertPublished("zigbee2mqtt/alarm/set/state", "ARM_AWAY_"); - component.getChannel(AlarmControlPanel.SWITCH_ARM_HOME_CHANNEL_ID).getState() - .publishValue(new StringType("ARM_HOME_")); - assertPublished("zigbee2mqtt/alarm/set/state", "ARM_HOME_"); - } - - @Override - protected Set getConfigTopics() { - return Set.of(CONFIG_TOPIC); - } -} diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/AlarmControlPanelTests.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/AlarmControlPanelTests.java index 4ab20cac1bd..f5ee44a5085 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/AlarmControlPanelTests.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/AlarmControlPanelTests.java @@ -88,9 +88,4 @@ public class AlarmControlPanelTests extends AbstractComponentTests { protected Set getConfigTopics() { return Set.of(CONFIG_TOPIC); } - - @Override - protected boolean useNewStyleChannels() { - return true; - } } diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/BinarySensorTests.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/BinarySensorTests.java index d11f1f82f47..0263e34ddfa 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/BinarySensorTests.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/BinarySensorTests.java @@ -65,7 +65,7 @@ public class BinarySensorTests extends AbstractComponentTests { assertThat(component.channels.size(), is(1)); assertThat(component.getName(), is("onoffsensor")); - assertThat(component.getComponentId(), is("sn1")); + assertThat(component.getComponentId(), is("0x0000000000000000_binary_sensor_zigbee2mqtt")); assertChannel(component, BinarySensor.SENSOR_CHANNEL_ID, "zigbee2mqtt/sensor/state", "", "onoffsensor", OnOffValue.class); diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/ClimateTests.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/ClimateTests.java index abed25174bc..fe3a6d3183a 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/ClimateTests.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/ClimateTests.java @@ -76,10 +76,9 @@ public class ClimateTests extends AbstractComponentTests { assertThat(component.getName(), is("th1")); assertChannel(component, Climate.ACTION_CH_ID, "zigbee2mqtt/th1", "", "th1", TextValue.class); - assertChannel(component, Climate.AWAY_MODE_CH_ID_DEPRECATED, "zigbee2mqtt/th1", "zigbee2mqtt/th1/set/away_mode", - "th1", OnOffValue.class); - assertChannel(component, Climate.CURRENT_TEMPERATURE_CH_ID_DEPRECATED, "zigbee2mqtt/th1", "", "th1", - NumberValue.class); + assertChannel(component, Climate.AWAY_MODE_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/set/away_mode", "th1", + OnOffValue.class); + assertChannel(component, Climate.CURRENT_TEMPERATURE_CH_ID, "zigbee2mqtt/th1", "", "th1", NumberValue.class); assertChannel(component, Climate.HOLD_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/set/preset", "th1", TextValue.class); assertChannel(component, Climate.MODE_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/set/system_mode", "th1", @@ -95,13 +94,13 @@ public class ClimateTests extends AbstractComponentTests { "current_heating_setpoint": "24"}\ """); assertState(component, Climate.ACTION_CH_ID, new StringType("off")); - assertState(component, Climate.AWAY_MODE_CH_ID_DEPRECATED, OnOffType.ON); - assertState(component, Climate.CURRENT_TEMPERATURE_CH_ID_DEPRECATED, new QuantityType<>(22.2, SIUnits.CELSIUS)); + assertState(component, Climate.AWAY_MODE_CH_ID, OnOffType.ON); + assertState(component, Climate.CURRENT_TEMPERATURE_CH_ID, new QuantityType<>(22.2, SIUnits.CELSIUS)); assertState(component, Climate.HOLD_CH_ID, new StringType("schedule")); assertState(component, Climate.MODE_CH_ID, new StringType("heat")); assertState(component, Climate.TEMPERATURE_CH_ID, new QuantityType<>(24, SIUnits.CELSIUS)); - component.getChannel(Climate.AWAY_MODE_CH_ID_DEPRECATED).getState().publishValue(OnOffType.OFF); + component.getChannel(Climate.AWAY_MODE_CH_ID).getState().publishValue(OnOffType.OFF); assertPublished("zigbee2mqtt/th1/set/away_mode", "OFF"); component.getChannel(Climate.HOLD_CH_ID).getState().publishValue(new StringType("eco")); assertPublished("zigbee2mqtt/th1/set/preset", "eco"); @@ -148,10 +147,9 @@ public class ClimateTests extends AbstractComponentTests { assertThat(component.getName(), is("th1")); assertChannel(component, Climate.ACTION_CH_ID, "zigbee2mqtt/th1", "", "th1", TextValue.class); - assertChannel(component, Climate.AWAY_MODE_CH_ID_DEPRECATED, "zigbee2mqtt/th1", "zigbee2mqtt/th1/set/away_mode", - "th1", OnOffValue.class); - assertChannel(component, Climate.CURRENT_TEMPERATURE_CH_ID_DEPRECATED, "zigbee2mqtt/th1", "", "th1", - NumberValue.class); + assertChannel(component, Climate.AWAY_MODE_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/set/away_mode", "th1", + OnOffValue.class); + assertChannel(component, Climate.CURRENT_TEMPERATURE_CH_ID, "zigbee2mqtt/th1", "", "th1", NumberValue.class); assertChannel(component, Climate.HOLD_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/set/preset", "th1", TextValue.class); assertChannel(component, Climate.MODE_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/set/system_mode", "th1", @@ -167,14 +165,14 @@ public class ClimateTests extends AbstractComponentTests { "current_heating_setpoint": "24"}\ """); assertState(component, Climate.ACTION_CH_ID, new StringType("off")); - assertState(component, Climate.AWAY_MODE_CH_ID_DEPRECATED, OnOffType.ON); - assertState(component, Climate.CURRENT_TEMPERATURE_CH_ID_DEPRECATED, new QuantityType<>(22.2, SIUnits.CELSIUS)); + assertState(component, Climate.AWAY_MODE_CH_ID, OnOffType.ON); + assertState(component, Climate.CURRENT_TEMPERATURE_CH_ID, new QuantityType<>(22.2, SIUnits.CELSIUS)); assertState(component, Climate.HOLD_CH_ID, new StringType("schedule")); assertState(component, Climate.MODE_CH_ID, new StringType("heat")); assertState(component, Climate.TEMPERATURE_CH_ID, new QuantityType<>(24, SIUnits.CELSIUS)); // Climate is in OFF state - component.getChannel(Climate.AWAY_MODE_CH_ID_DEPRECATED).getState().publishValue(OnOffType.OFF); + component.getChannel(Climate.AWAY_MODE_CH_ID).getState().publishValue(OnOffType.OFF); assertNotPublished("zigbee2mqtt/th1/set/away_mode", "OFF"); component.getChannel(Climate.HOLD_CH_ID).getState().publishValue(new StringType("eco")); assertNotPublished("zigbee2mqtt/th1/set/preset", "eco"); @@ -193,7 +191,7 @@ public class ClimateTests extends AbstractComponentTests { """); // Climate is in ON state - component.getChannel(Climate.AWAY_MODE_CH_ID_DEPRECATED).getState().publishValue(OnOffType.OFF); + component.getChannel(Climate.AWAY_MODE_CH_ID).getState().publishValue(OnOffType.OFF); assertPublished("zigbee2mqtt/th1/set/away_mode", "OFF"); component.getChannel(Climate.HOLD_CH_ID).getState().publishValue(new StringType("eco")); assertPublished("zigbee2mqtt/th1/set/preset", "eco"); @@ -256,12 +254,12 @@ public class ClimateTests extends AbstractComponentTests { assertChannel(component, Climate.ACTION_CH_ID, "zigbee2mqtt/th1", "", "MQTT HVAC", TextValue.class); assertChannel(component, Climate.AUX_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/aux", "MQTT HVAC", OnOffValue.class); - assertChannel(component, Climate.AWAY_MODE_CH_ID_DEPRECATED, "zigbee2mqtt/th1", "zigbee2mqtt/th1/away_mode", - "MQTT HVAC", OnOffValue.class); - assertChannel(component, Climate.CURRENT_TEMPERATURE_CH_ID_DEPRECATED, "zigbee2mqtt/th1", "", "MQTT HVAC", + assertChannel(component, Climate.AWAY_MODE_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/away_mode", "MQTT HVAC", + OnOffValue.class); + assertChannel(component, Climate.CURRENT_TEMPERATURE_CH_ID, "zigbee2mqtt/th1", "", "MQTT HVAC", NumberValue.class); - assertChannel(component, Climate.FAN_MODE_CH_ID_DEPRECATED, "zigbee2mqtt/th1", "zigbee2mqtt/th1/fan_mode", - "MQTT HVAC", TextValue.class); + assertChannel(component, Climate.FAN_MODE_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/fan_mode", "MQTT HVAC", + TextValue.class); assertChannel(component, Climate.HOLD_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/hold", "MQTT HVAC", TextValue.class); assertChannel(component, Climate.MODE_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/mode", "MQTT HVAC", @@ -270,10 +268,10 @@ public class ClimateTests extends AbstractComponentTests { TextValue.class); assertChannel(component, Climate.TEMPERATURE_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/temperature", "MQTT HVAC", NumberValue.class); - assertChannel(component, Climate.TEMPERATURE_HIGH_CH_ID_DEPRECATED, "zigbee2mqtt/th1", - "zigbee2mqtt/th1/temperature_high", "MQTT HVAC", NumberValue.class); - assertChannel(component, Climate.TEMPERATURE_LOW_CH_ID_DEPRECATED, "zigbee2mqtt/th1", - "zigbee2mqtt/th1/temperature_low", "MQTT HVAC", NumberValue.class); + assertChannel(component, Climate.TEMPERATURE_HIGH_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/temperature_high", + "MQTT HVAC", NumberValue.class); + assertChannel(component, Climate.TEMPERATURE_LOW_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/temperature_low", + "MQTT HVAC", NumberValue.class); assertChannel(component, Climate.POWER_CH_ID, "", "zigbee2mqtt/th1/power", "MQTT HVAC", OnOffValue.class); assertChannel(component, Climate.JSON_ATTRIBUTES_CHANNEL_ID, "zigbee2mqtt/th1", "", "JSON Attributes", TextValue.class); @@ -287,24 +285,21 @@ public class ClimateTests extends AbstractComponentTests { assertState(component, Climate.ACTION_CH_ID, new StringType("fan")); assertState(component, Climate.AUX_CH_ID, OnOffType.ON); - assertState(component, Climate.AWAY_MODE_CH_ID_DEPRECATED, OnOffType.OFF); - assertState(component, Climate.CURRENT_TEMPERATURE_CH_ID_DEPRECATED, - new QuantityType<>(35.5, ImperialUnits.FAHRENHEIT)); - assertState(component, Climate.FAN_MODE_CH_ID_DEPRECATED, new StringType("p2")); + assertState(component, Climate.AWAY_MODE_CH_ID, OnOffType.OFF); + assertState(component, Climate.CURRENT_TEMPERATURE_CH_ID, new QuantityType<>(35.5, ImperialUnits.FAHRENHEIT)); + assertState(component, Climate.FAN_MODE_CH_ID, new StringType("p2")); assertState(component, Climate.HOLD_CH_ID, new StringType("u2")); assertState(component, Climate.MODE_CH_ID, new StringType("B1")); assertState(component, Climate.SWING_CH_ID, new StringType("G1")); assertState(component, Climate.TEMPERATURE_CH_ID, new QuantityType<>(30, ImperialUnits.FAHRENHEIT)); - assertState(component, Climate.TEMPERATURE_HIGH_CH_ID_DEPRECATED, - new QuantityType<>(37, ImperialUnits.FAHRENHEIT)); - assertState(component, Climate.TEMPERATURE_LOW_CH_ID_DEPRECATED, - new QuantityType<>(20, ImperialUnits.FAHRENHEIT)); + assertState(component, Climate.TEMPERATURE_HIGH_CH_ID, new QuantityType<>(37, ImperialUnits.FAHRENHEIT)); + assertState(component, Climate.TEMPERATURE_LOW_CH_ID, new QuantityType<>(20, ImperialUnits.FAHRENHEIT)); component.getChannel(Climate.AUX_CH_ID).getState().publishValue(OnOffType.OFF); assertPublished("zigbee2mqtt/th1/aux", "OFF"); - component.getChannel(Climate.AWAY_MODE_CH_ID_DEPRECATED).getState().publishValue(OnOffType.ON); + component.getChannel(Climate.AWAY_MODE_CH_ID).getState().publishValue(OnOffType.ON); assertPublished("zigbee2mqtt/th1/away_mode", "ON"); - component.getChannel(Climate.FAN_MODE_CH_ID_DEPRECATED).getState().publishValue(new StringType("p1")); + component.getChannel(Climate.FAN_MODE_CH_ID).getState().publishValue(new StringType("p1")); assertPublished("zigbee2mqtt/th1/fan_mode", "fan_mode=p1"); component.getChannel(Climate.HOLD_CH_ID).getState().publishValue(new StringType("u3")); assertPublished("zigbee2mqtt/th1/hold", "hold=u3"); @@ -314,9 +309,9 @@ public class ClimateTests extends AbstractComponentTests { assertPublished("zigbee2mqtt/th1/swing", "swing=G2"); component.getChannel(Climate.TEMPERATURE_CH_ID).getState().publishValue(new DecimalType(30.5)); assertPublished("zigbee2mqtt/th1/temperature", "temperature=30.5"); - component.getChannel(Climate.TEMPERATURE_HIGH_CH_ID_DEPRECATED).getState().publishValue(new DecimalType(39.5)); + component.getChannel(Climate.TEMPERATURE_HIGH_CH_ID).getState().publishValue(new DecimalType(39.5)); assertPublished("zigbee2mqtt/th1/temperature_high", "temperature_high=39.5"); - component.getChannel(Climate.TEMPERATURE_LOW_CH_ID_DEPRECATED).getState().publishValue(new DecimalType(19.5)); + component.getChannel(Climate.TEMPERATURE_LOW_CH_ID).getState().publishValue(new DecimalType(19.5)); assertPublished("zigbee2mqtt/th1/temperature_low", "temperature_low=19.5"); component.getChannel(Climate.POWER_CH_ID).getState().publishValue(OnOffType.OFF); assertPublished("zigbee2mqtt/th1/power", "OFF"); diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/DefaultSchemaLightTests.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/DefaultSchemaLightTests.java index 802c6b4de96..3d70428e348 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/DefaultSchemaLightTests.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/DefaultSchemaLightTests.java @@ -274,16 +274,16 @@ public class DefaultSchemaLightTests extends AbstractComponentTests { assertThat(component.channels.size(), is(1)); assertThat(component.getName(), is("light")); - assertChannel(component, Light.SWITCH_CHANNEL_ID_DEPRECATED, "zigbee2mqtt/light/state", - "zigbee2mqtt/light/set/state", "On/Off State", OnOffValue.class); + assertChannel(component, Light.SWITCH_CHANNEL_ID, "zigbee2mqtt/light/state", "zigbee2mqtt/light/set/state", + "On/Off State", OnOffValue.class); assertThat(component.brightnessChannel, is(nullValue())); publishMessage("zigbee2mqtt/light/state", "{\"power\": \"ON_\"}"); - assertState(component, Light.SWITCH_CHANNEL_ID_DEPRECATED, OnOffType.ON); + assertState(component, Light.SWITCH_CHANNEL_ID, OnOffType.ON); publishMessage("zigbee2mqtt/light/state", "{\"power\": \"OFF_\"}"); - assertState(component, Light.SWITCH_CHANNEL_ID_DEPRECATED, OnOffType.OFF); + assertState(component, Light.SWITCH_CHANNEL_ID, OnOffType.OFF); - sendCommand(component, Light.SWITCH_CHANNEL_ID_DEPRECATED, OnOffType.OFF); + sendCommand(component, Light.SWITCH_CHANNEL_ID, OnOffType.OFF); assertPublished("zigbee2mqtt/light/set/state", "OFF_"); } @@ -305,17 +305,17 @@ public class DefaultSchemaLightTests extends AbstractComponentTests { assertThat(component.channels.size(), is(2)); assertThat(component.getName(), is("light")); - assertChannel(component, Light.SWITCH_CHANNEL_ID_DEPRECATED, "zigbee2mqtt/light/state", - "zigbee2mqtt/light/set/state", "On/Off State", OnOffValue.class); + assertChannel(component, Light.SWITCH_CHANNEL_ID, "zigbee2mqtt/light/state", "zigbee2mqtt/light/set/state", + "On/Off State", OnOffValue.class); assertChannel(component, Light.EFFECT_CHANNEL_ID, "zigbee2mqtt/light/effect", "zigbee2mqtt/light/set/effect", "Lighting Effect", TextValue.class); publishMessage("zigbee2mqtt/light/state", "{\"power\": \"ON\"}"); - assertState(component, Light.SWITCH_CHANNEL_ID_DEPRECATED, OnOffType.ON); + assertState(component, Light.SWITCH_CHANNEL_ID, OnOffType.ON); publishMessage("zigbee2mqtt/light/effect", "party"); assertState(component, Light.EFFECT_CHANNEL_ID, new StringType("party")); publishMessage("zigbee2mqtt/light/state", "{\"power\": \"OFF\"}"); - assertState(component, Light.SWITCH_CHANNEL_ID_DEPRECATED, OnOffType.OFF); + assertState(component, Light.SWITCH_CHANNEL_ID, OnOffType.OFF); sendCommand(component, Light.EFFECT_CHANNEL_ID, new StringType("rainbow")); assertPublished("zigbee2mqtt/light/set/effect", "rainbow"); diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/DeviceTriggerTests.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/DeviceTriggerTests.java index a45c1eac347..6ed0b7acbd6 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/DeviceTriggerTests.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/DeviceTriggerTests.java @@ -145,9 +145,4 @@ public class DeviceTriggerTests extends AbstractComponentTests { protected Set getConfigTopics() { return Set.of(CONFIG_TOPIC_1, CONFIG_TOPIC_2); } - - @Override - protected boolean useNewStyleChannels() { - return true; - } } diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/FanTests.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/FanTests.java index 7978ff0d137..bc78602428e 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/FanTests.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/FanTests.java @@ -73,21 +73,21 @@ public class FanTests extends AbstractComponentTests { assertThat(component.channels.size(), is(1)); assertThat(component.getName(), is("fan")); - assertChannel(component, Fan.SWITCH_CHANNEL_ID_DEPRECATED, "zigbee2mqtt/fan/state", "zigbee2mqtt/fan/set/state", + assertChannel(component, Fan.SWITCH_CHANNEL_ID, "zigbee2mqtt/fan/state", "zigbee2mqtt/fan/set/state", "On/Off State", OnOffValue.class, null); publishMessage("zigbee2mqtt/fan/state", "ON_"); - assertState(component, Fan.SWITCH_CHANNEL_ID_DEPRECATED, OnOffType.ON); + assertState(component, Fan.SWITCH_CHANNEL_ID, OnOffType.ON); publishMessage("zigbee2mqtt/fan/state", "ON_"); - assertState(component, Fan.SWITCH_CHANNEL_ID_DEPRECATED, OnOffType.ON); + assertState(component, Fan.SWITCH_CHANNEL_ID, OnOffType.ON); publishMessage("zigbee2mqtt/fan/state", "OFF_"); - assertState(component, Fan.SWITCH_CHANNEL_ID_DEPRECATED, OnOffType.OFF); + assertState(component, Fan.SWITCH_CHANNEL_ID, OnOffType.OFF); publishMessage("zigbee2mqtt/fan/state", "ON_"); - assertState(component, Fan.SWITCH_CHANNEL_ID_DEPRECATED, OnOffType.ON); + assertState(component, Fan.SWITCH_CHANNEL_ID, OnOffType.ON); - component.getChannel(Fan.SWITCH_CHANNEL_ID_DEPRECATED).getState().publishValue(OnOffType.OFF); + component.getChannel(Fan.SWITCH_CHANNEL_ID).getState().publishValue(OnOffType.OFF); assertPublished("zigbee2mqtt/fan/set/state", "OFF_"); - component.getChannel(Fan.SWITCH_CHANNEL_ID_DEPRECATED).getState().publishValue(OnOffType.ON); + component.getChannel(Fan.SWITCH_CHANNEL_ID).getState().publishValue(OnOffType.ON); assertPublished("zigbee2mqtt/fan/set/state", "ON_"); } @@ -187,7 +187,7 @@ public class FanTests extends AbstractComponentTests { assertThat(component.channels.size(), is(1)); assertThat(component.getName(), is("fan")); - assertChannel(component, Fan.SWITCH_CHANNEL_ID_DEPRECATED, "", "zigbee2mqtt/fan/set/state", "On/Off State", + assertChannel(component, Fan.SWITCH_CHANNEL_ID, "", "zigbee2mqtt/fan/set/state", "On/Off State", OnOffValue.class, AutoUpdatePolicy.RECOMMEND); } @@ -225,7 +225,7 @@ public class FanTests extends AbstractComponentTests { assertThat(component.channels.size(), is(1)); assertThat(component.getName(), is("fan")); - assertChannel(component, Fan.SWITCH_CHANNEL_ID_DEPRECATED, "zigbee2mqtt/fan/state", "zigbee2mqtt/fan/set/state", + assertChannel(component, Fan.SWITCH_CHANNEL_ID, "zigbee2mqtt/fan/state", "zigbee2mqtt/fan/set/state", "On/Off State", OnOffValue.class, AutoUpdatePolicy.RECOMMEND); } @@ -296,7 +296,7 @@ public class FanTests extends AbstractComponentTests { assertThat(component.channels.size(), is(1)); - component.getChannel(Fan.SWITCH_CHANNEL_ID_DEPRECATED).getState().publishValue(OnOffType.OFF); + component.getChannel(Fan.SWITCH_CHANNEL_ID).getState().publishValue(OnOffType.OFF); assertPublished("zigbee2mqtt/fan/set/state", "set to OFF_"); } diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/JSONSchemaLightTests.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/JSONSchemaLightTests.java index 083d9151d3f..75e3c4de3f3 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/JSONSchemaLightTests.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/JSONSchemaLightTests.java @@ -203,16 +203,16 @@ public class JSONSchemaLightTests extends AbstractComponentTests { assertThat(component.channels.size(), is(1)); assertThat(component.getName(), is("light")); - assertChannel(component, Light.SWITCH_CHANNEL_ID_DEPRECATED, "", "dummy", "On/Off State", OnOffValue.class); + assertChannel(component, Light.SWITCH_CHANNEL_ID, "", "dummy", "On/Off State", OnOffValue.class); publishMessage("zigbee2mqtt/light/state", "{ \"state\": \"ON\" }"); - assertState(component, Light.SWITCH_CHANNEL_ID_DEPRECATED, OnOffType.ON); + assertState(component, Light.SWITCH_CHANNEL_ID, OnOffType.ON); publishMessage("zigbee2mqtt/light/state", "{ \"state\": \"OFF\" }"); - assertState(component, Light.SWITCH_CHANNEL_ID_DEPRECATED, OnOffType.OFF); + assertState(component, Light.SWITCH_CHANNEL_ID, OnOffType.OFF); - sendCommand(component, Light.SWITCH_CHANNEL_ID_DEPRECATED, OnOffType.OFF); + sendCommand(component, Light.SWITCH_CHANNEL_ID, OnOffType.OFF); assertPublished("zigbee2mqtt/light/set/state", "{\"state\":\"OFF\"}"); - sendCommand(component, Light.SWITCH_CHANNEL_ID_DEPRECATED, OnOffType.ON); + sendCommand(component, Light.SWITCH_CHANNEL_ID, OnOffType.ON); assertPublished("zigbee2mqtt/light/set/state", "{\"state\":\"ON\"}"); } diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/SensorTests.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/SensorTests.java index d712ee20317..e046c8d23d8 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/SensorTests.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/SensorTests.java @@ -65,7 +65,7 @@ public class SensorTests extends AbstractComponentTests { assertThat(component.channels.size(), is(1)); assertThat(component.getName(), is("sensor1")); - assertThat(component.getComponentId(), is("sn1")); + assertThat(component.getComponentId(), is("0x0000000000000000_sensor_zigbee2mqtt")); assertChannel(component, Sensor.SENSOR_CHANNEL_ID, "zigbee2mqtt/sensor/state", "", "sensor1", NumberValue.class); diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/TemplateSchemaLightTests.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/TemplateSchemaLightTests.java index c7be8675705..856b35f79ee 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/TemplateSchemaLightTests.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/TemplateSchemaLightTests.java @@ -151,12 +151,11 @@ public class TemplateSchemaLightTests extends AbstractComponentTests { assertThat(component.getName(), is("Bulb-white")); assertChannel(component, Light.BRIGHTNESS_CHANNEL_ID, "", "dummy", "Brightness", PercentageValue.class); - assertChannel(component, Light.COLOR_TEMP_CHANNEL_ID_DEPRECATED, "", "dummy", "Color Temperature", - NumberValue.class); + assertChannel(component, Light.COLOR_TEMP_CHANNEL_ID, "", "dummy", "Color Temperature", NumberValue.class); publishMessage("shellies/bulb/color/0/status", "{ \"state\": \"on\", \"brightness\": 100 }"); assertState(component, Light.BRIGHTNESS_CHANNEL_ID, PercentType.HUNDRED); - assertState(component, Light.COLOR_TEMP_CHANNEL_ID_DEPRECATED, UnDefType.NULL); + assertState(component, Light.COLOR_TEMP_CHANNEL_ID, UnDefType.NULL); sendCommand(component, Light.BRIGHTNESS_CHANNEL_ID, PercentType.HUNDRED); assertPublished("shellies/bulb/color/0/set", "{\"turn\": \"on\", \"mode\": \"white\", \"brightness\": 100}"); @@ -164,7 +163,7 @@ public class TemplateSchemaLightTests extends AbstractComponentTests { sendCommand(component, Light.BRIGHTNESS_CHANNEL_ID, OnOffType.OFF); assertPublished("shellies/bulb/color/0/set", "{\"turn\":\"off\", \"mode\": \"white\"}"); - sendCommand(component, Light.COLOR_TEMP_CHANNEL_ID_DEPRECATED, new QuantityType(200, Units.MIRED)); + sendCommand(component, Light.COLOR_TEMP_CHANNEL_ID, new QuantityType(200, Units.MIRED)); assertPublished("shellies/bulb/color/0/set", "{\"turn\": \"on\", \"mode\": \"white\", \"temp\": 5000}"); } @@ -185,16 +184,16 @@ public class TemplateSchemaLightTests extends AbstractComponentTests { assertThat(component.channels.size(), is(1)); assertThat(component.getName(), is("light")); - assertChannel(component, Light.SWITCH_CHANNEL_ID_DEPRECATED, "", "dummy", "On/Off State", OnOffValue.class); + assertChannel(component, Light.SWITCH_CHANNEL_ID, "", "dummy", "On/Off State", OnOffValue.class); publishMessage("zigbee2mqtt/light/state", "{\"power\": \"on\"}"); - assertState(component, Light.SWITCH_CHANNEL_ID_DEPRECATED, OnOffType.ON); + assertState(component, Light.SWITCH_CHANNEL_ID, OnOffType.ON); publishMessage("zigbee2mqtt/light/state", "{\"power\": \"off\"}"); - assertState(component, Light.SWITCH_CHANNEL_ID_DEPRECATED, OnOffType.OFF); + assertState(component, Light.SWITCH_CHANNEL_ID, OnOffType.OFF); - sendCommand(component, Light.SWITCH_CHANNEL_ID_DEPRECATED, OnOffType.OFF); + sendCommand(component, Light.SWITCH_CHANNEL_ID, OnOffType.OFF); assertPublished("zigbee2mqtt/light/set/state", "off"); - sendCommand(component, Light.SWITCH_CHANNEL_ID_DEPRECATED, OnOffType.ON); + sendCommand(component, Light.SWITCH_CHANNEL_ID, OnOffType.ON); assertPublished("zigbee2mqtt/light/set/state", "on"); } diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/VacuumTests.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/VacuumTests.java index 60490f930f6..290e8addd38 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/VacuumTests.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/component/VacuumTests.java @@ -64,21 +64,21 @@ public class VacuumTests extends AbstractComponentTests { assertThat(component.channels.size(), is(6)); // command, state, fan speed, send command, battery, json attrs assertThat(component.getName(), is("Rockrobo")); - assertChannel(component, Vacuum.COMMAND_CH_ID, "", "valetudo/rockrobo/command", "Rockrobo", TextValue.class); - assertChannel(component, Vacuum.STATE_CH_ID, "valetudo/rockrobo/state", "", "Rockrobo", TextValue.class); - assertChannel(component, Vacuum.FAN_SPEED_CH_ID_DEPRECATED, "valetudo/rockrobo/state", - "valetudo/rockrobo/set_fan_speed", "Rockrobo", TextValue.class); - assertChannel(component, Vacuum.CUSTOM_COMMAND_CH_ID_DEPRECATED, "", "valetudo/rockrobo/custom_command", - "Rockrobo", TextValue.class); - assertChannel(component, Vacuum.BATTERY_LEVEL_CH_ID_DEPRECATED, "valetudo/rockrobo/state", "", "Rockrobo", + assertChannel(component, Vacuum.COMMAND_CH_ID, "", "valetudo/rockrobo/command", "Command", TextValue.class); + assertChannel(component, Vacuum.STATE_CH_ID, "valetudo/rockrobo/state", "", "State", TextValue.class); + assertChannel(component, Vacuum.FAN_SPEED_CH_ID, "valetudo/rockrobo/state", "valetudo/rockrobo/set_fan_speed", + "Fan Speed", TextValue.class); + assertChannel(component, Vacuum.CUSTOM_COMMAND_CH_ID, "", "valetudo/rockrobo/custom_command", "Custom Command", + TextValue.class); + assertChannel(component, Vacuum.BATTERY_LEVEL_CH_ID, "valetudo/rockrobo/state", "", "Battery Level", PercentageValue.class); - assertChannel(component, Vacuum.JSON_ATTRIBUTES_CH_ID_DEPRECATED, "valetudo/rockrobo/attributes", "", - "Rockrobo", TextValue.class); + assertChannel(component, Vacuum.JSON_ATTRIBUTES_CH_ID, "valetudo/rockrobo/attributes", "", "JSON Attributes", + TextValue.class); assertState(component, Vacuum.STATE_CH_ID, UnDefType.UNDEF); - assertState(component, Vacuum.FAN_SPEED_CH_ID_DEPRECATED, UnDefType.UNDEF); - assertState(component, Vacuum.BATTERY_LEVEL_CH_ID_DEPRECATED, UnDefType.UNDEF); - assertState(component, Vacuum.JSON_ATTRIBUTES_CH_ID_DEPRECATED, UnDefType.UNDEF); + assertState(component, Vacuum.FAN_SPEED_CH_ID, UnDefType.UNDEF); + assertState(component, Vacuum.BATTERY_LEVEL_CH_ID, UnDefType.UNDEF); + assertState(component, Vacuum.JSON_ATTRIBUTES_CH_ID, UnDefType.UNDEF); // @formatter:off String jsonValue; @@ -124,9 +124,9 @@ public class VacuumTests extends AbstractComponentTests { // @formatter:on assertState(component, Vacuum.STATE_CH_ID, new StringType(Vacuum.STATE_DOCKED)); - assertState(component, Vacuum.FAN_SPEED_CH_ID_DEPRECATED, new StringType("max")); - assertState(component, Vacuum.BATTERY_LEVEL_CH_ID_DEPRECATED, new PercentType(100)); - assertState(component, Vacuum.JSON_ATTRIBUTES_CH_ID_DEPRECATED, new StringType(jsonValue)); + assertState(component, Vacuum.FAN_SPEED_CH_ID, new StringType("max")); + assertState(component, Vacuum.BATTERY_LEVEL_CH_ID, new PercentType(100)); + assertState(component, Vacuum.JSON_ATTRIBUTES_CH_ID, new StringType(jsonValue)); component.getChannel(Vacuum.COMMAND_CH_ID).getState().publishValue(new StringType("start")); assertPublished("valetudo/rockrobo/command", "start"); @@ -142,11 +142,11 @@ public class VacuumTests extends AbstractComponentTests { // @formatter:on assertState(component, Vacuum.STATE_CH_ID, new StringType(Vacuum.STATE_CLEANING)); - assertState(component, Vacuum.FAN_SPEED_CH_ID_DEPRECATED, new StringType("max")); - assertState(component, Vacuum.BATTERY_LEVEL_CH_ID_DEPRECATED, new PercentType(99)); - assertState(component, Vacuum.JSON_ATTRIBUTES_CH_ID_DEPRECATED, new StringType(jsonValue)); + assertState(component, Vacuum.FAN_SPEED_CH_ID, new StringType("max")); + assertState(component, Vacuum.BATTERY_LEVEL_CH_ID, new PercentType(99)); + assertState(component, Vacuum.JSON_ATTRIBUTES_CH_ID, new StringType(jsonValue)); - component.getChannel(Vacuum.FAN_SPEED_CH_ID_DEPRECATED).getState().publishValue(new StringType("medium")); + component.getChannel(Vacuum.FAN_SPEED_CH_ID).getState().publishValue(new StringType("medium")); assertPublished("valetudo/rockrobo/set_fan_speed", "medium"); // @formatter:off @@ -160,9 +160,9 @@ public class VacuumTests extends AbstractComponentTests { // @formatter:on assertState(component, Vacuum.STATE_CH_ID, new StringType(Vacuum.STATE_RETURNING)); - assertState(component, Vacuum.FAN_SPEED_CH_ID_DEPRECATED, new StringType("medium")); - assertState(component, Vacuum.BATTERY_LEVEL_CH_ID_DEPRECATED, new PercentType(80)); - assertState(component, Vacuum.JSON_ATTRIBUTES_CH_ID_DEPRECATED, new StringType(jsonValue)); + assertState(component, Vacuum.FAN_SPEED_CH_ID, new StringType("medium")); + assertState(component, Vacuum.BATTERY_LEVEL_CH_ID, new PercentType(80)); + assertState(component, Vacuum.JSON_ATTRIBUTES_CH_ID, new StringType(jsonValue)); } @Override diff --git a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/handler/HomeAssistantThingHandlerTests.java b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/handler/HomeAssistantThingHandlerTests.java index 964bc638796..25b583be15f 100644 --- a/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/handler/HomeAssistantThingHandlerTests.java +++ b/bundles/org.openhab.binding.mqtt.homeassistant/src/test/java/org/openhab/binding/mqtt/homeassistant/internal/handler/HomeAssistantThingHandlerTests.java @@ -222,13 +222,13 @@ public class HomeAssistantThingHandlerTests extends AbstractHomeAssistantTests { // // verify that both channels are there and the label corresponds to newer discovery topic payload // - Channel corridorTempChannel = nonSpyThingHandler.getThing().getChannel("tempCorridor_5Fsensor#sensor"); + Channel corridorTempChannel = nonSpyThingHandler.getThing().getChannel("tempCorridor"); assertThat("Corridor temperature channel is created", corridorTempChannel, notNullValue()); Objects.requireNonNull(corridorTempChannel); // for compiler assertThat("Corridor temperature channel is having the updated label from 2nd discovery topic publish", corridorTempChannel.getLabel(), is("CorridorTemp NEW")); - Channel outsideTempChannel = nonSpyThingHandler.getThing().getChannel("tempOutside_5Fsensor#sensor"); + Channel outsideTempChannel = nonSpyThingHandler.getThing().getChannel("tempOutside"); assertThat("Outside temperature channel is created", outsideTempChannel, notNullValue()); verify(thingHandler, times(2)).componentDiscovered(eq(new HaID(configTopicTempCorridor)), any(Sensor.class)); @@ -347,7 +347,6 @@ public class HomeAssistantThingHandlerTests extends AbstractHomeAssistantTests { haThing = ThingBuilder.create(HA_TYPE_UID, HA_UID).withBridge(BRIDGE_UID).withChannel(channelBuilder.build()) .withConfiguration(thingConfiguration).build(); - haThing.setProperty("newStyleChannels", "true"); setupThingHandler(); thingHandler.initialize(); @@ -358,58 +357,6 @@ public class HomeAssistantThingHandlerTests extends AbstractHomeAssistantTests { @Test public void testDuplicateChannelId() { - thingHandler.initialize(); - - verify(callbackMock).statusUpdated(eq(haThing), any()); - // Expect a call to the bridge status changed, the start, the propertiesChanged method - verify(thingHandler).bridgeStatusChanged(any()); - verify(thingHandler, timeout(SUBSCRIBE_TIMEOUT)).start(any()); - - MQTT_TOPICS.forEach(t -> { - verify(bridgeConnection, timeout(SUBSCRIBE_TIMEOUT)).subscribe(eq(t), any()); - }); - - verify(thingHandler, never()).componentDiscovered(any(), any()); - assertThat(haThing.getChannels().size(), is(0)); - - thingHandler.discoverComponents.processMessage("homeassistant/number/abc/activeEnergyReports/config", """ - { - "name":"ActiveEnergyReports", - "object_id":"mud_room_cans_switch_(garage)_activeEnergyReports", - "state_topic":"zigbee2mqtt/Mud Room Cans Switch (Garage)", - "unique_id":"0x04cd15fffedb7f81_activeEnergyReports_zigbee2mqtt", - "value_template":"{{ value_json.activeEnergyReports }}" - } - """.getBytes(StandardCharsets.UTF_8)); - thingHandler.discoverComponents.processMessage("homeassistant/sensor/abc/activeEnergyReports/config", """ - { - "command_topic":"zigbee2mqtt/Mud Room Cans Switch (Garage)/set/activeEnergyReports", - "max":32767, - "min":0, - "name":"ActiveEnergyReports", - "object_id":"mud_room_cans_switch_(garage)_activeEnergyReports", - "state_topic":"zigbee2mqtt/Mud Room Cans Switch (Garage)", - "unique_id":"0x04cd15fffedb7f81_activeEnergyReports_zigbee2mqtt", - "value_template":"{{ value_json.activeEnergyReports }}" - } - """.getBytes(StandardCharsets.UTF_8)); - thingHandler.delayedProcessing.forceProcessNow(); - waitForAssert(() -> { - assertThat("2 channels created", nonSpyThingHandler.getThing().getChannels().size() == 2); - }); - - Channel numberChannel = nonSpyThingHandler.getThing() - .getChannel("0x04cd15fffedb7f81_5FactiveEnergyReports_5Fzigbee2mqtt_number#number"); - assertThat("Number channel is created", numberChannel, notNullValue()); - - Channel sensorChannel = nonSpyThingHandler.getThing() - .getChannel("0x04cd15fffedb7f81_5FactiveEnergyReports_5Fzigbee2mqtt_sensor#sensor"); - assertThat("Sensor channel is created", sensorChannel, notNullValue()); - } - - @Test - public void testDuplicateChannelIdNewStyleChannels() { - haThing.setProperty("newStyleChannels", "true"); thingHandler = new HomeAssistantThingHandler(haThing, channelTypeProvider, stateDescriptionProvider, channelTypeRegistry, new Jinjava(), unitProvider, SUBSCRIBE_TIMEOUT, ATTRIBUTE_RECEIVE_TIMEOUT); thingHandler.setConnection(bridgeConnection); @@ -465,8 +412,7 @@ public class HomeAssistantThingHandlerTests extends AbstractHomeAssistantTests { } @Test - public void testDuplicateChannelIdNewStyleChannelsComplex() { - haThing.setProperty("newStyleChannels", "true"); + public void testDuplicateChannelIdComplex() { thingHandler = new HomeAssistantThingHandler(haThing, channelTypeProvider, stateDescriptionProvider, channelTypeRegistry, new Jinjava(), unitProvider, SUBSCRIBE_TIMEOUT, ATTRIBUTE_RECEIVE_TIMEOUT); thingHandler.setConnection(bridgeConnection); diff --git a/itests/org.openhab.binding.mqtt.homeassistant.tests/src/main/java/org/openhab/binding/mqtt/homeassistant/DiscoverComponentsTest.java b/itests/org.openhab.binding.mqtt.homeassistant.tests/src/main/java/org/openhab/binding/mqtt/homeassistant/DiscoverComponentsTest.java index be1d2c73cb3..ac3f28d7fa2 100644 --- a/itests/org.openhab.binding.mqtt.homeassistant.tests/src/main/java/org/openhab/binding/mqtt/homeassistant/DiscoverComponentsTest.java +++ b/itests/org.openhab.binding.mqtt.homeassistant.tests/src/main/java/org/openhab/binding/mqtt/homeassistant/DiscoverComponentsTest.java @@ -85,7 +85,7 @@ public class DiscoverComponentsTest extends JavaOSGiTest { UnitProvider unitProvider = mock(UnitProvider.class); DiscoverComponents discover = spy(new DiscoverComponents(ThingChannelConstants.TEST_HOME_ASSISTANT_THING, - scheduler, channelStateUpdateListener, availabilityTracker, gson, jinjava, unitProvider, true)); + scheduler, channelStateUpdateListener, availabilityTracker, gson, jinjava, unitProvider)); HandlerConfiguration config = new HandlerConfiguration("homeassistant", List.of("switch/object")); diff --git a/itests/org.openhab.binding.mqtt.homeassistant.tests/src/main/java/org/openhab/binding/mqtt/homeassistant/HomeAssistantMQTTImplementationTest.java b/itests/org.openhab.binding.mqtt.homeassistant.tests/src/main/java/org/openhab/binding/mqtt/homeassistant/HomeAssistantMQTTImplementationTest.java index 6e73c11675e..fd5eb422513 100644 --- a/itests/org.openhab.binding.mqtt.homeassistant.tests/src/main/java/org/openhab/binding/mqtt/homeassistant/HomeAssistantMQTTImplementationTest.java +++ b/itests/org.openhab.binding.mqtt.homeassistant.tests/src/main/java/org/openhab/binding/mqtt/homeassistant/HomeAssistantMQTTImplementationTest.java @@ -170,7 +170,7 @@ public class HomeAssistantMQTTImplementationTest extends MqttOSGiTest { ScheduledExecutorService scheduler = new ScheduledThreadPoolExecutor(4); DiscoverComponents discover = spy(new DiscoverComponents(ThingChannelConstants.TEST_HOME_ASSISTANT_THING, - scheduler, channelStateUpdateListener, availabilityTracker, gson, jinjava, unitProvider, true)); + scheduler, channelStateUpdateListener, availabilityTracker, gson, jinjava, unitProvider)); // The DiscoverComponents object calls ComponentDiscovered callbacks. // In the following implementation we add the found component to the `haComponents` map