mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 07:02:02 +01:00
[mqtt.homeassistant] Remove newStyleChannels temporary back-compat (#17908)
This includes removing deprecated channel IDs controlled by the same flag. Signed-off-by: Cody Cutrer <cody@cutrer.us>
This commit is contained in:
parent
d4cbc5f839
commit
36802db90e
@ -53,7 +53,6 @@ public class DiscoverComponents implements MqttMessageSubscriber {
|
|||||||
private final ScheduledExecutorService scheduler;
|
private final ScheduledExecutorService scheduler;
|
||||||
private final ChannelStateUpdateListener updateListener;
|
private final ChannelStateUpdateListener updateListener;
|
||||||
private final AvailabilityTracker tracker;
|
private final AvailabilityTracker tracker;
|
||||||
private final boolean newStyleChannels;
|
|
||||||
|
|
||||||
protected final CompletableFuture<@Nullable Void> discoverFinishedFuture = new CompletableFuture<>();
|
protected final CompletableFuture<@Nullable Void> discoverFinishedFuture = new CompletableFuture<>();
|
||||||
private final Gson gson;
|
private final Gson gson;
|
||||||
@ -84,7 +83,7 @@ public class DiscoverComponents implements MqttMessageSubscriber {
|
|||||||
*/
|
*/
|
||||||
public DiscoverComponents(ThingUID thingUID, ScheduledExecutorService scheduler,
|
public DiscoverComponents(ThingUID thingUID, ScheduledExecutorService scheduler,
|
||||||
ChannelStateUpdateListener channelStateUpdateListener, AvailabilityTracker tracker, Gson gson,
|
ChannelStateUpdateListener channelStateUpdateListener, AvailabilityTracker tracker, Gson gson,
|
||||||
Jinjava jinjava, UnitProvider unitProvider, boolean newStyleChannels) {
|
Jinjava jinjava, UnitProvider unitProvider) {
|
||||||
this.thingUID = thingUID;
|
this.thingUID = thingUID;
|
||||||
this.scheduler = scheduler;
|
this.scheduler = scheduler;
|
||||||
this.updateListener = channelStateUpdateListener;
|
this.updateListener = channelStateUpdateListener;
|
||||||
@ -92,7 +91,6 @@ public class DiscoverComponents implements MqttMessageSubscriber {
|
|||||||
this.jinjava = jinjava;
|
this.jinjava = jinjava;
|
||||||
this.unitProvider = unitProvider;
|
this.unitProvider = unitProvider;
|
||||||
this.tracker = tracker;
|
this.tracker = tracker;
|
||||||
this.newStyleChannels = newStyleChannels;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -108,7 +106,7 @@ public class DiscoverComponents implements MqttMessageSubscriber {
|
|||||||
if (config.length() > 0) {
|
if (config.length() > 0) {
|
||||||
try {
|
try {
|
||||||
component = ComponentFactory.createComponent(thingUID, haID, config, updateListener, tracker, scheduler,
|
component = ComponentFactory.createComponent(thingUID, haID, config, updateListener, tracker, scheduler,
|
||||||
gson, jinjava, unitProvider, newStyleChannels);
|
gson, jinjava, unitProvider);
|
||||||
component.setConfigSeen();
|
component.setConfigSeen();
|
||||||
|
|
||||||
logger.trace("Found HomeAssistant component {}", haID);
|
logger.trace("Found HomeAssistant component {}", haID);
|
||||||
|
@ -187,19 +187,9 @@ public class HaID {
|
|||||||
*
|
*
|
||||||
* @return group id
|
* @return group id
|
||||||
*/
|
*/
|
||||||
public String getGroupId(@Nullable final String uniqueId, boolean newStyleChannels) {
|
public String getGroupId(@Nullable final String uniqueId) {
|
||||||
String result = 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
|
// the null test is only here so the compile knows, result is not null afterwards
|
||||||
if (result == null || result.isBlank()) {
|
if (result == null || result.isBlank()) {
|
||||||
StringBuilder str = new StringBuilder();
|
StringBuilder str = new StringBuilder();
|
||||||
|
@ -111,7 +111,6 @@ public abstract class AbstractComponent<C extends AbstractChannelConfiguration>
|
|||||||
protected final C channelConfiguration;
|
protected final C channelConfiguration;
|
||||||
|
|
||||||
protected boolean configSeen;
|
protected boolean configSeen;
|
||||||
protected final boolean newStyleChannels;
|
|
||||||
protected final String uniqueId;
|
protected final String uniqueId;
|
||||||
protected @Nullable String groupId;
|
protected @Nullable String groupId;
|
||||||
protected String componentId;
|
protected String componentId;
|
||||||
@ -121,14 +120,10 @@ public abstract class AbstractComponent<C extends AbstractChannelConfiguration>
|
|||||||
*
|
*
|
||||||
* @param componentConfiguration generic componentConfiguration with not parsed JSON config
|
* @param componentConfiguration generic componentConfiguration with not parsed JSON config
|
||||||
* @param clazz target configuration type
|
* @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
|
* @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<C> clazz,
|
public AbstractComponent(ComponentFactory.ComponentConfiguration componentConfiguration, Class<C> clazz) {
|
||||||
boolean newStyleChannels) {
|
|
||||||
this.componentConfiguration = componentConfiguration;
|
this.componentConfiguration = componentConfiguration;
|
||||||
this.newStyleChannels = newStyleChannels;
|
|
||||||
|
|
||||||
this.channelConfigurationJson = componentConfiguration.getConfigJSON();
|
this.channelConfigurationJson = componentConfiguration.getConfigJSON();
|
||||||
this.channelConfiguration = componentConfiguration.getConfig(clazz);
|
this.channelConfiguration = componentConfiguration.getConfig(clazz);
|
||||||
@ -137,18 +132,11 @@ public abstract class AbstractComponent<C extends AbstractChannelConfiguration>
|
|||||||
this.haID = componentConfiguration.getHaID();
|
this.haID = componentConfiguration.getHaID();
|
||||||
|
|
||||||
String name = channelConfiguration.getName();
|
String name = channelConfiguration.getName();
|
||||||
if (newStyleChannels) {
|
// try for a simple component/group ID first; if there are conflicts
|
||||||
// try for a simple component/group ID first; if there are conflicts
|
// (components of different types, but the same object id)
|
||||||
// (components of different types, but the same object id)
|
// we'll resolve them later
|
||||||
// we'll resolve them later
|
groupId = componentId = haID.objectID.replace('-', '_');
|
||||||
groupId = componentId = haID.objectID.replace('-', '_');
|
uniqueId = haID.component + "_" + haID.getGroupId(channelConfiguration.getUniqueId());
|
||||||
} 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);
|
|
||||||
|
|
||||||
this.configSeen = false;
|
this.configSeen = false;
|
||||||
|
|
||||||
@ -199,9 +187,6 @@ public abstract class AbstractComponent<C extends AbstractChannelConfiguration>
|
|||||||
|
|
||||||
protected void finalizeChannels() {
|
protected void finalizeChannels() {
|
||||||
addJsonAttributesChannel();
|
addJsonAttributesChannel();
|
||||||
if (!newStyleChannels) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (channels.size() == 1) {
|
if (channels.size() == 1) {
|
||||||
groupId = null;
|
groupId = null;
|
||||||
channels.values().forEach(c -> c.resetUID(buildChannelUID(componentId)));
|
channels.values().forEach(c -> c.resetUID(buildChannelUID(componentId)));
|
||||||
@ -214,7 +199,7 @@ public abstract class AbstractComponent<C extends AbstractChannelConfiguration>
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void resolveConflict() {
|
public void resolveConflict() {
|
||||||
if (newStyleChannels && channels.size() == 1) {
|
if (channels.size() == 1) {
|
||||||
componentId = componentId + "_" + haID.component;
|
componentId = componentId + "_" + haID.component;
|
||||||
channels.values().forEach(c -> c.resetUID(buildChannelUID(componentId)));
|
channels.values().forEach(c -> c.resetUID(buildChannelUID(componentId)));
|
||||||
} else {
|
} else {
|
||||||
|
@ -33,8 +33,8 @@ abstract class AbstractRawSchemaLight extends Light {
|
|||||||
protected ComponentChannel rawChannel;
|
protected ComponentChannel rawChannel;
|
||||||
protected TextValue colorModeValue;
|
protected TextValue colorModeValue;
|
||||||
|
|
||||||
public AbstractRawSchemaLight(ComponentFactory.ComponentConfiguration builder, boolean newStyleChannels) {
|
public AbstractRawSchemaLight(ComponentFactory.ComponentConfiguration builder) {
|
||||||
super(builder, newStyleChannels);
|
super(builder);
|
||||||
hiddenChannels.add(rawChannel = buildChannel(RAW_CHANNEL_ID, ComponentChannelType.STRING, new TextValue(),
|
hiddenChannels.add(rawChannel = buildChannel(RAW_CHANNEL_ID, ComponentChannelType.STRING, new TextValue(),
|
||||||
"Raw state", this).stateTopic(channelConfiguration.stateTopic)
|
"Raw state", this).stateTopic(channelConfiguration.stateTopic)
|
||||||
.commandTopic(channelConfiguration.commandTopic, channelConfiguration.isRetain(),
|
.commandTopic(channelConfiguration.commandTopic, channelConfiguration.isRetain(),
|
||||||
|
@ -35,7 +35,6 @@ import com.google.gson.annotations.SerializedName;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class AlarmControlPanel extends AbstractComponent<AlarmControlPanel.ChannelConfiguration> {
|
public class AlarmControlPanel extends AbstractComponent<AlarmControlPanel.ChannelConfiguration> {
|
||||||
public static final String STATE_CHANNEL_ID = "state";
|
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_DISARM_CHANNEL_ID = "disarm";
|
||||||
public static final String SWITCH_ARM_HOME_CHANNEL_ID = "armhome";
|
public static final String SWITCH_ARM_HOME_CHANNEL_ID = "armhome";
|
||||||
public static final String SWITCH_ARM_AWAY_CHANNEL_ID = "armaway";
|
public static final String SWITCH_ARM_AWAY_CHANNEL_ID = "armaway";
|
||||||
@ -93,8 +92,8 @@ public class AlarmControlPanel extends AbstractComponent<AlarmControlPanel.Chann
|
|||||||
FEATURE_ARM_VACATION, FEATURE_ARM_CUSTOM_BYPASS, FEATURE_TRIGGER);
|
FEATURE_ARM_VACATION, FEATURE_ARM_CUSTOM_BYPASS, FEATURE_TRIGGER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlarmControlPanel(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public AlarmControlPanel(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
|
|
||||||
List<String> stateEnum = new ArrayList(List.of(STATE_DISARMED, STATE_TRIGGERED, STATE_ARMING, STATE_DISARMING,
|
List<String> stateEnum = new ArrayList(List.of(STATE_DISARMED, STATE_TRIGGERED, STATE_ARMING, STATE_DISARMING,
|
||||||
STATE_PENDING, STATE_TRIGGERED));
|
STATE_PENDING, STATE_TRIGGERED));
|
||||||
@ -124,35 +123,18 @@ public class AlarmControlPanel extends AbstractComponent<AlarmControlPanel.Chann
|
|||||||
}
|
}
|
||||||
|
|
||||||
String commandTopic = channelConfiguration.commandTopic;
|
String commandTopic = channelConfiguration.commandTopic;
|
||||||
TextValue value = (newStyleChannels && commandTopic != null)
|
TextValue value = (commandTopic != null)
|
||||||
? new TextValue(stateEnum.toArray(new String[0]), commandEnum.toArray(new String[0]))
|
? new TextValue(stateEnum.toArray(new String[0]), commandEnum.toArray(new String[0]))
|
||||||
: new TextValue(stateEnum.toArray(new String[0]));
|
: new TextValue(stateEnum.toArray(new String[0]));
|
||||||
var builder = buildChannel(newStyleChannels ? STATE_CHANNEL_ID : STATE_CHANNEL_ID_DEPRECATED,
|
var builder = buildChannel(STATE_CHANNEL_ID, ComponentChannelType.STRING, value, getName(),
|
||||||
ComponentChannelType.STRING, value, getName(), componentConfiguration.getUpdateListener())
|
componentConfiguration.getUpdateListener())
|
||||||
.stateTopic(channelConfiguration.stateTopic, channelConfiguration.getValueTemplate());
|
.stateTopic(channelConfiguration.stateTopic, channelConfiguration.getValueTemplate());
|
||||||
|
|
||||||
if (newStyleChannels && commandTopic != null) {
|
if (commandTopic != null) {
|
||||||
builder.commandTopic(commandTopic, channelConfiguration.isRetain(), channelConfiguration.getQos());
|
builder.commandTopic(commandTopic, channelConfiguration.isRetain(), channelConfiguration.getQos());
|
||||||
}
|
}
|
||||||
builder.build();
|
builder.build();
|
||||||
|
|
||||||
if (!newStyleChannels && commandTopic != null) {
|
|
||||||
buildChannel(SWITCH_DISARM_CHANNEL_ID, ComponentChannelType.STRING,
|
|
||||||
new TextValue(new String[] { channelConfiguration.payloadDisarm }), getName(),
|
|
||||||
componentConfiguration.getUpdateListener())
|
|
||||||
.commandTopic(commandTopic, channelConfiguration.isRetain(), channelConfiguration.getQos()).build();
|
|
||||||
|
|
||||||
buildChannel(SWITCH_ARM_HOME_CHANNEL_ID, ComponentChannelType.STRING,
|
|
||||||
new TextValue(new String[] { channelConfiguration.payloadArmHome }), getName(),
|
|
||||||
componentConfiguration.getUpdateListener())
|
|
||||||
.commandTopic(commandTopic, channelConfiguration.isRetain(), channelConfiguration.getQos()).build();
|
|
||||||
|
|
||||||
buildChannel(SWITCH_ARM_AWAY_CHANNEL_ID, ComponentChannelType.STRING,
|
|
||||||
new TextValue(new String[] { channelConfiguration.payloadArmAway }), getName(),
|
|
||||||
componentConfiguration.getUpdateListener())
|
|
||||||
.commandTopic(commandTopic, channelConfiguration.isRetain(), channelConfiguration.getQos()).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
finalizeChannels();
|
finalizeChannels();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,8 @@ public class BinarySensor extends AbstractComponent<BinarySensor.ChannelConfigur
|
|||||||
protected String payloadOff = "OFF";
|
protected String payloadOff = "OFF";
|
||||||
}
|
}
|
||||||
|
|
||||||
public BinarySensor(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public BinarySensor(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
|
|
||||||
OnOffValue value = new OnOffValue(channelConfiguration.payloadOn, channelConfiguration.payloadOff);
|
OnOffValue value = new OnOffValue(channelConfiguration.payloadOn, channelConfiguration.payloadOff);
|
||||||
|
|
||||||
|
@ -47,8 +47,8 @@ public class Button extends AbstractComponent<Button.ChannelConfiguration> {
|
|||||||
protected String payloadPress = "PRESS";
|
protected String payloadPress = "PRESS";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Button(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public Button(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
|
|
||||||
TextValue value = new TextValue(new String[] { channelConfiguration.payloadPress });
|
TextValue value = new TextValue(new String[] { channelConfiguration.payloadPress });
|
||||||
|
|
||||||
|
@ -39,8 +39,8 @@ public class Camera extends AbstractComponent<Camera.ChannelConfiguration> {
|
|||||||
protected String topic = "";
|
protected String topic = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Camera(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public Camera(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
|
|
||||||
ImageValue value = new ImageValue();
|
ImageValue value = new ImageValue();
|
||||||
|
|
||||||
|
@ -49,12 +49,9 @@ public class Climate extends AbstractComponent<Climate.ChannelConfiguration> {
|
|||||||
public static final String ACTION_CH_ID = "action";
|
public static final String ACTION_CH_ID = "action";
|
||||||
public static final String AUX_CH_ID = "aux";
|
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 = "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_HUMIDITY_CH_ID = "current-humidity";
|
||||||
public static final String CURRENT_TEMPERATURE_CH_ID = "current-temperature";
|
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 = "fan-mode";
|
||||||
public static final String FAN_MODE_CH_ID_DEPRECATED = "fanMode";
|
|
||||||
public static final String HOLD_CH_ID = "hold";
|
public static final String HOLD_CH_ID = "hold";
|
||||||
public static final String MODE_CH_ID = "mode";
|
public static final String MODE_CH_ID = "mode";
|
||||||
public static final String PRESET_MODE_CH_ID = "preset-mode";
|
public static final String PRESET_MODE_CH_ID = "preset-mode";
|
||||||
@ -62,9 +59,7 @@ public class Climate extends AbstractComponent<Climate.ChannelConfiguration> {
|
|||||||
public static final String TARGET_HUMIDITY_CH_ID = "target-humidity";
|
public static final String TARGET_HUMIDITY_CH_ID = "target-humidity";
|
||||||
public static final String TEMPERATURE_CH_ID = "temperature";
|
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 = "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 = "temperature-low";
|
||||||
public static final String TEMPERATURE_LOW_CH_ID_DEPRECATED = "temperatureLow";
|
|
||||||
public static final String POWER_CH_ID = "power";
|
public static final String POWER_CH_ID = "power";
|
||||||
|
|
||||||
private static final String ACTION_OFF = "off";
|
private static final String ACTION_OFF = "off";
|
||||||
@ -224,8 +219,8 @@ public class Climate extends AbstractComponent<Climate.ChannelConfiguration> {
|
|||||||
protected Boolean sendIfOff = true;
|
protected Boolean sendIfOff = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Climate(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public Climate(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
|
|
||||||
TemperatureUnit temperatureUnit = channelConfiguration.temperatureUnit;
|
TemperatureUnit temperatureUnit = channelConfiguration.temperatureUnit;
|
||||||
if (channelConfiguration.temperatureUnit == null) {
|
if (channelConfiguration.temperatureUnit == null) {
|
||||||
@ -250,8 +245,7 @@ public class Climate extends AbstractComponent<Climate.ChannelConfiguration> {
|
|||||||
channelConfiguration.auxCommandTopic, channelConfiguration.auxStateTemplate,
|
channelConfiguration.auxCommandTopic, channelConfiguration.auxStateTemplate,
|
||||||
channelConfiguration.auxStateTopic, commandFilter);
|
channelConfiguration.auxStateTopic, commandFilter);
|
||||||
|
|
||||||
buildOptionalChannel(newStyleChannels ? AWAY_MODE_CH_ID : AWAY_MODE_CH_ID_DEPRECATED,
|
buildOptionalChannel(AWAY_MODE_CH_ID, ComponentChannelType.SWITCH, new OnOffValue(), updateListener, null,
|
||||||
ComponentChannelType.SWITCH, new OnOffValue(), updateListener, null,
|
|
||||||
channelConfiguration.awayModeCommandTopic, channelConfiguration.awayModeStateTemplate,
|
channelConfiguration.awayModeCommandTopic, channelConfiguration.awayModeStateTemplate,
|
||||||
channelConfiguration.awayModeStateTopic, commandFilter);
|
channelConfiguration.awayModeStateTopic, commandFilter);
|
||||||
|
|
||||||
@ -259,12 +253,12 @@ public class Climate extends AbstractComponent<Climate.ChannelConfiguration> {
|
|||||||
new NumberValue(new BigDecimal(0), new BigDecimal(100), null, Units.PERCENT), updateListener, null,
|
new NumberValue(new BigDecimal(0), new BigDecimal(100), null, Units.PERCENT), updateListener, null,
|
||||||
null, channelConfiguration.currentHumidityTemplate, channelConfiguration.currentHumidityTopic, null);
|
null, channelConfiguration.currentHumidityTemplate, channelConfiguration.currentHumidityTopic, null);
|
||||||
|
|
||||||
buildOptionalChannel(newStyleChannels ? CURRENT_TEMPERATURE_CH_ID : CURRENT_TEMPERATURE_CH_ID_DEPRECATED,
|
buildOptionalChannel(CURRENT_TEMPERATURE_CH_ID, ComponentChannelType.TEMPERATURE,
|
||||||
ComponentChannelType.TEMPERATURE, new NumberValue(null, null, precision, temperatureUnit.getUnit()),
|
new NumberValue(null, null, precision, temperatureUnit.getUnit()), updateListener, null, null,
|
||||||
updateListener, null, null, channelConfiguration.currentTemperatureTemplate,
|
channelConfiguration.currentTemperatureTemplate, channelConfiguration.currentTemperatureTopic,
|
||||||
channelConfiguration.currentTemperatureTopic, commandFilter);
|
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,
|
new TextValue(channelConfiguration.fanModes.toArray(new String[0])), updateListener,
|
||||||
channelConfiguration.fanModeCommandTemplate, channelConfiguration.fanModeCommandTopic,
|
channelConfiguration.fanModeCommandTemplate, channelConfiguration.fanModeCommandTopic,
|
||||||
channelConfiguration.fanModeStateTemplate, channelConfiguration.fanModeStateTopic, commandFilter);
|
channelConfiguration.fanModeStateTemplate, channelConfiguration.fanModeStateTopic, commandFilter);
|
||||||
@ -306,16 +300,14 @@ public class Climate extends AbstractComponent<Climate.ChannelConfiguration> {
|
|||||||
channelConfiguration.temperatureCommandTopic, channelConfiguration.temperatureStateTemplate,
|
channelConfiguration.temperatureCommandTopic, channelConfiguration.temperatureStateTemplate,
|
||||||
channelConfiguration.temperatureStateTopic, commandFilter);
|
channelConfiguration.temperatureStateTopic, commandFilter);
|
||||||
|
|
||||||
buildOptionalChannel(newStyleChannels ? TEMPERATURE_HIGH_CH_ID : TEMPERATURE_HIGH_CH_ID_DEPRECATED,
|
buildOptionalChannel(TEMPERATURE_HIGH_CH_ID, ComponentChannelType.TEMPERATURE,
|
||||||
ComponentChannelType.TEMPERATURE,
|
|
||||||
new NumberValue(channelConfiguration.minTemp, channelConfiguration.maxTemp,
|
new NumberValue(channelConfiguration.minTemp, channelConfiguration.maxTemp,
|
||||||
channelConfiguration.tempStep, temperatureUnit.getUnit()),
|
channelConfiguration.tempStep, temperatureUnit.getUnit()),
|
||||||
updateListener, channelConfiguration.temperatureHighCommandTemplate,
|
updateListener, channelConfiguration.temperatureHighCommandTemplate,
|
||||||
channelConfiguration.temperatureHighCommandTopic, channelConfiguration.temperatureHighStateTemplate,
|
channelConfiguration.temperatureHighCommandTopic, channelConfiguration.temperatureHighStateTemplate,
|
||||||
channelConfiguration.temperatureHighStateTopic, commandFilter);
|
channelConfiguration.temperatureHighStateTopic, commandFilter);
|
||||||
|
|
||||||
buildOptionalChannel(newStyleChannels ? TEMPERATURE_LOW_CH_ID : TEMPERATURE_LOW_CH_ID_DEPRECATED,
|
buildOptionalChannel(TEMPERATURE_LOW_CH_ID, ComponentChannelType.TEMPERATURE,
|
||||||
ComponentChannelType.TEMPERATURE,
|
|
||||||
new NumberValue(channelConfiguration.minTemp, channelConfiguration.maxTemp,
|
new NumberValue(channelConfiguration.minTemp, channelConfiguration.maxTemp,
|
||||||
channelConfiguration.tempStep, temperatureUnit.getUnit()),
|
channelConfiguration.tempStep, temperatureUnit.getUnit()),
|
||||||
updateListener, channelConfiguration.temperatureLowCommandTemplate,
|
updateListener, channelConfiguration.temperatureLowCommandTemplate,
|
||||||
|
@ -48,59 +48,58 @@ public class ComponentFactory {
|
|||||||
*/
|
*/
|
||||||
public static AbstractComponent<?> createComponent(ThingUID thingUID, HaID haID, String channelConfigurationJSON,
|
public static AbstractComponent<?> createComponent(ThingUID thingUID, HaID haID, String channelConfigurationJSON,
|
||||||
ChannelStateUpdateListener updateListener, AvailabilityTracker tracker, ScheduledExecutorService scheduler,
|
ChannelStateUpdateListener updateListener, AvailabilityTracker tracker, ScheduledExecutorService scheduler,
|
||||||
Gson gson, Jinjava jinjava, UnitProvider unitProvider, boolean newStyleChannels)
|
Gson gson, Jinjava jinjava, UnitProvider unitProvider) throws ConfigurationException {
|
||||||
throws ConfigurationException {
|
|
||||||
ComponentConfiguration componentConfiguration = new ComponentConfiguration(thingUID, haID,
|
ComponentConfiguration componentConfiguration = new ComponentConfiguration(thingUID, haID,
|
||||||
channelConfigurationJSON, gson, jinjava, updateListener, tracker, scheduler, unitProvider);
|
channelConfigurationJSON, gson, jinjava, updateListener, tracker, scheduler, unitProvider);
|
||||||
switch (haID.component) {
|
switch (haID.component) {
|
||||||
case "alarm_control_panel":
|
case "alarm_control_panel":
|
||||||
return new AlarmControlPanel(componentConfiguration, newStyleChannels);
|
return new AlarmControlPanel(componentConfiguration);
|
||||||
case "binary_sensor":
|
case "binary_sensor":
|
||||||
return new BinarySensor(componentConfiguration, newStyleChannels);
|
return new BinarySensor(componentConfiguration);
|
||||||
case "button":
|
case "button":
|
||||||
return new Button(componentConfiguration, newStyleChannels);
|
return new Button(componentConfiguration);
|
||||||
case "camera":
|
case "camera":
|
||||||
return new Camera(componentConfiguration, newStyleChannels);
|
return new Camera(componentConfiguration);
|
||||||
case "climate":
|
case "climate":
|
||||||
return new Climate(componentConfiguration, newStyleChannels);
|
return new Climate(componentConfiguration);
|
||||||
case "cover":
|
case "cover":
|
||||||
return new Cover(componentConfiguration, newStyleChannels);
|
return new Cover(componentConfiguration);
|
||||||
case "device_automation":
|
case "device_automation":
|
||||||
return new DeviceTrigger(componentConfiguration, newStyleChannels);
|
return new DeviceTrigger(componentConfiguration);
|
||||||
case "device_tracker":
|
case "device_tracker":
|
||||||
return new DeviceTracker(componentConfiguration, newStyleChannels);
|
return new DeviceTracker(componentConfiguration);
|
||||||
case "event":
|
case "event":
|
||||||
return new Event(componentConfiguration, newStyleChannels);
|
return new Event(componentConfiguration);
|
||||||
case "fan":
|
case "fan":
|
||||||
return new Fan(componentConfiguration, newStyleChannels);
|
return new Fan(componentConfiguration);
|
||||||
case "humidifier":
|
case "humidifier":
|
||||||
return new Humidifier(componentConfiguration, newStyleChannels);
|
return new Humidifier(componentConfiguration);
|
||||||
case "light":
|
case "light":
|
||||||
return Light.create(componentConfiguration, newStyleChannels);
|
return Light.create(componentConfiguration);
|
||||||
case "lock":
|
case "lock":
|
||||||
return new Lock(componentConfiguration, newStyleChannels);
|
return new Lock(componentConfiguration);
|
||||||
case "number":
|
case "number":
|
||||||
return new Number(componentConfiguration, newStyleChannels);
|
return new Number(componentConfiguration);
|
||||||
case "scene":
|
case "scene":
|
||||||
return new Scene(componentConfiguration, newStyleChannels);
|
return new Scene(componentConfiguration);
|
||||||
case "select":
|
case "select":
|
||||||
return new Select(componentConfiguration, newStyleChannels);
|
return new Select(componentConfiguration);
|
||||||
case "sensor":
|
case "sensor":
|
||||||
return new Sensor(componentConfiguration, newStyleChannels);
|
return new Sensor(componentConfiguration);
|
||||||
case "switch":
|
case "switch":
|
||||||
return new Switch(componentConfiguration, newStyleChannels);
|
return new Switch(componentConfiguration);
|
||||||
case "tag":
|
case "tag":
|
||||||
return new Tag(componentConfiguration, newStyleChannels);
|
return new Tag(componentConfiguration);
|
||||||
case "text":
|
case "text":
|
||||||
return new Text(componentConfiguration, newStyleChannels);
|
return new Text(componentConfiguration);
|
||||||
case "update":
|
case "update":
|
||||||
return new Update(componentConfiguration, newStyleChannels);
|
return new Update(componentConfiguration);
|
||||||
case "vacuum":
|
case "vacuum":
|
||||||
return new Vacuum(componentConfiguration, newStyleChannels);
|
return new Vacuum(componentConfiguration);
|
||||||
case "valve":
|
case "valve":
|
||||||
return new Valve(componentConfiguration, newStyleChannels);
|
return new Valve(componentConfiguration);
|
||||||
case "water_heater":
|
case "water_heater":
|
||||||
return new WaterHeater(componentConfiguration, newStyleChannels);
|
return new WaterHeater(componentConfiguration);
|
||||||
default:
|
default:
|
||||||
throw new UnsupportedComponentException("Component '" + haID + "' is unsupported!");
|
throw new UnsupportedComponentException("Component '" + haID + "' is unsupported!");
|
||||||
}
|
}
|
||||||
|
@ -88,8 +88,8 @@ public class Cover extends AbstractComponent<Cover.ChannelConfiguration> {
|
|||||||
@Nullable
|
@Nullable
|
||||||
ComponentChannel stateChannel = null;
|
ComponentChannel stateChannel = null;
|
||||||
|
|
||||||
public Cover(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public Cover(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
|
|
||||||
boolean optimistic = false;
|
boolean optimistic = false;
|
||||||
Boolean localOptimistic = channelConfiguration.optimistic;
|
Boolean localOptimistic = channelConfiguration.optimistic;
|
||||||
|
@ -55,17 +55,16 @@ public class DefaultSchemaLight extends Light {
|
|||||||
protected @Nullable ComponentChannel rgbChannel;
|
protected @Nullable ComponentChannel rgbChannel;
|
||||||
protected @Nullable ComponentChannel xyChannel;
|
protected @Nullable ComponentChannel xyChannel;
|
||||||
|
|
||||||
public DefaultSchemaLight(ComponentFactory.ComponentConfiguration builder, boolean newStyleChannels) {
|
public DefaultSchemaLight(ComponentFactory.ComponentConfiguration builder) {
|
||||||
super(builder, newStyleChannels);
|
super(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void buildChannels() {
|
protected void buildChannels() {
|
||||||
AutoUpdatePolicy autoUpdatePolicy = optimistic ? AutoUpdatePolicy.RECOMMEND : null;
|
AutoUpdatePolicy autoUpdatePolicy = optimistic ? AutoUpdatePolicy.RECOMMEND : null;
|
||||||
ComponentChannel localOnOffChannel;
|
ComponentChannel localOnOffChannel;
|
||||||
localOnOffChannel = onOffChannel = buildChannel(
|
localOnOffChannel = onOffChannel = buildChannel(SWITCH_CHANNEL_ID, ComponentChannelType.SWITCH, onOffValue,
|
||||||
newStyleChannels ? SWITCH_CHANNEL_ID : SWITCH_CHANNEL_ID_DEPRECATED, ComponentChannelType.SWITCH,
|
"On/Off State", this)
|
||||||
onOffValue, "On/Off State", this)
|
|
||||||
.stateTopic(channelConfiguration.stateTopic, channelConfiguration.stateValueTemplate)
|
.stateTopic(channelConfiguration.stateTopic, channelConfiguration.stateValueTemplate)
|
||||||
.commandTopic(channelConfiguration.commandTopic, channelConfiguration.isRetain(),
|
.commandTopic(channelConfiguration.commandTopic, channelConfiguration.isRetain(),
|
||||||
channelConfiguration.getQos())
|
channelConfiguration.getQos())
|
||||||
@ -92,15 +91,14 @@ public class DefaultSchemaLight extends Light {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (channelConfiguration.colorModeStateTopic != null) {
|
if (channelConfiguration.colorModeStateTopic != null) {
|
||||||
buildChannel(newStyleChannels ? COLOR_MODE_CHANNEL_ID : COLOR_MODE_CHANNEL_ID_DEPRECATED,
|
buildChannel(COLOR_MODE_CHANNEL_ID, ComponentChannelType.STRING, new TextValue(), "Current color mode",
|
||||||
ComponentChannelType.STRING, new TextValue(), "Current color mode", this)
|
this)
|
||||||
.stateTopic(channelConfiguration.colorModeStateTopic, channelConfiguration.colorModeValueTemplate)
|
.stateTopic(channelConfiguration.colorModeStateTopic, channelConfiguration.colorModeValueTemplate)
|
||||||
.inferOptimistic(channelConfiguration.optimistic).build();
|
.inferOptimistic(channelConfiguration.optimistic).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channelConfiguration.colorTempStateTopic != null || channelConfiguration.colorTempCommandTopic != null) {
|
if (channelConfiguration.colorTempStateTopic != null || channelConfiguration.colorTempCommandTopic != null) {
|
||||||
buildChannel(newStyleChannels ? COLOR_TEMP_CHANNEL_ID : COLOR_TEMP_CHANNEL_ID_DEPRECATED,
|
buildChannel(COLOR_TEMP_CHANNEL_ID, ComponentChannelType.NUMBER, colorTempValue, "Color Temperature", this)
|
||||||
ComponentChannelType.NUMBER, colorTempValue, "Color Temperature", this)
|
|
||||||
.stateTopic(channelConfiguration.colorTempStateTopic, channelConfiguration.colorTempValueTemplate)
|
.stateTopic(channelConfiguration.colorTempStateTopic, channelConfiguration.colorTempValueTemplate)
|
||||||
.commandTopic(channelConfiguration.colorTempCommandTopic, channelConfiguration.isRetain(),
|
.commandTopic(channelConfiguration.colorTempCommandTopic, channelConfiguration.isRetain(),
|
||||||
channelConfiguration.getQos())
|
channelConfiguration.getQos())
|
||||||
@ -180,7 +178,7 @@ public class DefaultSchemaLight extends Light {
|
|||||||
hiddenChannels.add(localOnOffChannel);
|
hiddenChannels.add(localOnOffChannel);
|
||||||
channels.put(BRIGHTNESS_CHANNEL_ID, localBrightnessChannel);
|
channels.put(BRIGHTNESS_CHANNEL_ID, localBrightnessChannel);
|
||||||
} else {
|
} 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 {
|
} else {
|
||||||
listener.updateChannelState(primaryChannelUID, state);
|
listener.updateChannelState(primaryChannelUID, state);
|
||||||
}
|
}
|
||||||
} else if (id.equals(newStyleChannels ? COLOR_TEMP_CHANNEL_ID : COLOR_TEMP_CHANNEL_ID_DEPRECATED)
|
} else if (id.equals(COLOR_TEMP_CHANNEL_ID) || channel.getIdWithoutGroup().equals(EFFECT_CHANNEL_ID)) {
|
||||||
|| channel.getIdWithoutGroup().equals(EFFECT_CHANNEL_ID)) {
|
|
||||||
// Real channels; pass through
|
// Real channels; pass through
|
||||||
listener.updateChannelState(channel, state);
|
listener.updateChannelState(channel, state);
|
||||||
} else if (id.equals(HS_CHANNEL_ID) || id.equals(XY_CHANNEL_ID)) {
|
} else if (id.equals(HS_CHANNEL_ID) || id.equals(XY_CHANNEL_ID)) {
|
||||||
|
@ -98,8 +98,8 @@ public class DeviceTracker extends AbstractComponent<DeviceTracker.ChannelConfig
|
|||||||
private final LocationValue locationValue = new LocationValue();
|
private final LocationValue locationValue = new LocationValue();
|
||||||
private final @Nullable ComponentChannel homeChannel, locationChannel, accuracyChannel;
|
private final @Nullable ComponentChannel homeChannel, locationChannel, accuracyChannel;
|
||||||
|
|
||||||
public DeviceTracker(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public DeviceTracker(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
this.channelStateUpdateListener = componentConfiguration.getUpdateListener();
|
this.channelStateUpdateListener = componentConfiguration.getUpdateListener();
|
||||||
|
|
||||||
if (channelConfiguration.stateTopic == null && channelConfiguration.getJsonAttributesTopic() == null) {
|
if (channelConfiguration.stateTopic == null && channelConfiguration.getJsonAttributesTopic() == null) {
|
||||||
|
@ -59,8 +59,8 @@ public class DeviceTrigger extends AbstractComponent<DeviceTrigger.ChannelConfig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeviceTrigger(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public DeviceTrigger(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
|
|
||||||
if (!"trigger".equals(channelConfiguration.automationType)) {
|
if (!"trigger".equals(channelConfiguration.automationType)) {
|
||||||
throw new ConfigurationException("Component:DeviceTrigger must have automation_type 'trigger'");
|
throw new ConfigurationException("Component:DeviceTrigger must have automation_type 'trigger'");
|
||||||
@ -72,13 +72,11 @@ public class DeviceTrigger extends AbstractComponent<DeviceTrigger.ChannelConfig
|
|||||||
throw new ConfigurationException("Component:DeviceTrigger must have a subtype");
|
throw new ConfigurationException("Component:DeviceTrigger must have a subtype");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newStyleChannels) {
|
// Name the channel after the subtype, not the component ID
|
||||||
// Name the channel after the subtype, not the component ID
|
// So that we only end up with a single channel for all possible events
|
||||||
// So that we only end up with a single channel for all possible events
|
// for a single button (subtype is the button, type is type of press)
|
||||||
// for a single button (subtype is the button, type is type of press)
|
componentId = channelConfiguration.subtype;
|
||||||
componentId = channelConfiguration.subtype;
|
groupId = null;
|
||||||
groupId = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
TextValue value;
|
TextValue value;
|
||||||
String payload = channelConfiguration.payload;
|
String payload = channelConfiguration.payload;
|
||||||
|
@ -54,8 +54,8 @@ public class Event extends AbstractComponent<Event.ChannelConfiguration> impleme
|
|||||||
|
|
||||||
private final HomeAssistantChannelTransformation transformation;
|
private final HomeAssistantChannelTransformation transformation;
|
||||||
|
|
||||||
public Event(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public Event(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
|
|
||||||
transformation = new HomeAssistantChannelTransformation(getJinjava(), this, "");
|
transformation = new HomeAssistantChannelTransformation(getJinjava(), this, "");
|
||||||
|
|
||||||
|
@ -44,7 +44,6 @@ import com.google.gson.annotations.SerializedName;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class Fan extends AbstractComponent<Fan.ChannelConfiguration> implements ChannelStateUpdateListener {
|
public class Fan extends AbstractComponent<Fan.ChannelConfiguration> implements ChannelStateUpdateListener {
|
||||||
public static final String SWITCH_CHANNEL_ID = "switch";
|
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 SPEED_CHANNEL_ID = "speed";
|
||||||
public static final String PRESET_MODE_CHANNEL_ID = "preset-mode";
|
public static final String PRESET_MODE_CHANNEL_ID = "preset-mode";
|
||||||
public static final String OSCILLATION_CHANNEL_ID = "oscillation";
|
public static final String OSCILLATION_CHANNEL_ID = "oscillation";
|
||||||
@ -131,16 +130,16 @@ public class Fan extends AbstractComponent<Fan.ChannelConfiguration> implements
|
|||||||
private final ComponentChannel primaryChannel;
|
private final ComponentChannel primaryChannel;
|
||||||
private final ChannelStateUpdateListener channelStateUpdateListener;
|
private final ChannelStateUpdateListener channelStateUpdateListener;
|
||||||
|
|
||||||
public Fan(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public Fan(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
this.channelStateUpdateListener = componentConfiguration.getUpdateListener();
|
this.channelStateUpdateListener = componentConfiguration.getUpdateListener();
|
||||||
|
|
||||||
onOffValue = new OnOffValue(channelConfiguration.payloadOn, channelConfiguration.payloadOff);
|
onOffValue = new OnOffValue(channelConfiguration.payloadOn, channelConfiguration.payloadOff);
|
||||||
ChannelStateUpdateListener onOffListener = channelConfiguration.percentageCommandTopic == null
|
ChannelStateUpdateListener onOffListener = channelConfiguration.percentageCommandTopic == null
|
||||||
? componentConfiguration.getUpdateListener()
|
? componentConfiguration.getUpdateListener()
|
||||||
: this;
|
: this;
|
||||||
onOffChannel = buildChannel(newStyleChannels ? SWITCH_CHANNEL_ID : SWITCH_CHANNEL_ID_DEPRECATED,
|
onOffChannel = buildChannel(SWITCH_CHANNEL_ID, ComponentChannelType.SWITCH, onOffValue, "On/Off State",
|
||||||
ComponentChannelType.SWITCH, onOffValue, "On/Off State", onOffListener)
|
onOffListener)
|
||||||
.stateTopic(channelConfiguration.stateTopic, channelConfiguration.stateValueTemplate)
|
.stateTopic(channelConfiguration.stateTopic, channelConfiguration.stateValueTemplate)
|
||||||
.commandTopic(channelConfiguration.commandTopic, channelConfiguration.isRetain(),
|
.commandTopic(channelConfiguration.commandTopic, channelConfiguration.isRetain(),
|
||||||
channelConfiguration.getQos(), channelConfiguration.commandTemplate)
|
channelConfiguration.getQos(), channelConfiguration.commandTemplate)
|
||||||
|
@ -108,8 +108,8 @@ public class Humidifier extends AbstractComponent<Humidifier.ChannelConfiguratio
|
|||||||
protected @Nullable List<String> modes;
|
protected @Nullable List<String> modes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Humidifier(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public Humidifier(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
|
|
||||||
if (!PLATFORM_HUMIDIFIER.equals(channelConfiguration.platform)) {
|
if (!PLATFORM_HUMIDIFIER.equals(channelConfiguration.platform)) {
|
||||||
throw new ConfigurationException("platform must be " + PLATFORM_HUMIDIFIER);
|
throw new ConfigurationException("platform must be " + PLATFORM_HUMIDIFIER);
|
||||||
|
@ -76,8 +76,8 @@ public class JSONSchemaLight extends AbstractRawSchemaLight {
|
|||||||
protected @Nullable Integer transition;
|
protected @Nullable Integer transition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONSchemaLight(ComponentFactory.ComponentConfiguration builder, boolean newStyleChannels) {
|
public JSONSchemaLight(ComponentFactory.ComponentConfiguration builder) {
|
||||||
super(builder, newStyleChannels);
|
super(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -91,17 +91,15 @@ public class JSONSchemaLight extends AbstractRawSchemaLight {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (supportedColorModes.contains(LightColorMode.COLOR_MODE_COLOR_TEMP)) {
|
if (supportedColorModes.contains(LightColorMode.COLOR_MODE_COLOR_TEMP)) {
|
||||||
colorTempChannel = buildChannel(
|
colorTempChannel = buildChannel(COLOR_TEMP_CHANNEL_ID, ComponentChannelType.NUMBER, colorTempValue,
|
||||||
newStyleChannels ? COLOR_TEMP_CHANNEL_ID : COLOR_TEMP_CHANNEL_ID_DEPRECATED,
|
"Color Temperature", this).commandTopic(DUMMY_TOPIC, true, 1)
|
||||||
ComponentChannelType.NUMBER, colorTempValue, "Color Temperature", this)
|
.commandFilter(command -> handleColorTempCommand(command))
|
||||||
.commandTopic(DUMMY_TOPIC, true, 1).commandFilter(command -> handleColorTempCommand(command))
|
|
||||||
.withAutoUpdatePolicy(autoUpdatePolicy).build();
|
.withAutoUpdatePolicy(autoUpdatePolicy).build();
|
||||||
|
|
||||||
if (hasColorChannel) {
|
if (hasColorChannel) {
|
||||||
colorModeValue = new TextValue(
|
colorModeValue = new TextValue(
|
||||||
supportedColorModes.stream().map(LightColorMode::serializedName).toArray(String[]::new));
|
supportedColorModes.stream().map(LightColorMode::serializedName).toArray(String[]::new));
|
||||||
buildChannel(newStyleChannels ? COLOR_MODE_CHANNEL_ID : COLOR_MODE_CHANNEL_ID_DEPRECATED,
|
buildChannel(COLOR_MODE_CHANNEL_ID, ComponentChannelType.STRING, colorModeValue, "Color Mode", this)
|
||||||
ComponentChannelType.STRING, colorModeValue, "Color Mode", this)
|
|
||||||
.withAutoUpdatePolicy(autoUpdatePolicy).isAdvanced(true).build();
|
.withAutoUpdatePolicy(autoUpdatePolicy).isAdvanced(true).build();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -117,9 +115,9 @@ public class JSONSchemaLight extends AbstractRawSchemaLight {
|
|||||||
"Brightness", this).commandTopic(DUMMY_TOPIC, true, 1).commandFilter(this::handleCommand)
|
"Brightness", this).commandTopic(DUMMY_TOPIC, true, 1).commandFilter(this::handleCommand)
|
||||||
.withAutoUpdatePolicy(autoUpdatePolicy).build();
|
.withAutoUpdatePolicy(autoUpdatePolicy).build();
|
||||||
} else {
|
} else {
|
||||||
onOffChannel = buildChannel(newStyleChannels ? SWITCH_CHANNEL_ID : SWITCH_CHANNEL_ID_DEPRECATED,
|
onOffChannel = buildChannel(SWITCH_CHANNEL_ID, ComponentChannelType.SWITCH, onOffValue, "On/Off State",
|
||||||
ComponentChannelType.SWITCH, onOffValue, "On/Off State", this).commandTopic(DUMMY_TOPIC, true, 1)
|
this).commandTopic(DUMMY_TOPIC, true, 1).commandFilter(this::handleCommand)
|
||||||
.commandFilter(this::handleCommand).withAutoUpdatePolicy(autoUpdatePolicy).build();
|
.withAutoUpdatePolicy(autoUpdatePolicy).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (effectValue != null) {
|
if (effectValue != null) {
|
||||||
@ -314,8 +312,7 @@ public class JSONSchemaLight extends AbstractRawSchemaLight {
|
|||||||
} else {
|
} else {
|
||||||
colorTempValue
|
colorTempValue
|
||||||
.update(new QuantityType(Objects.requireNonNull(jsonState.colorTemp), Units.MIRED));
|
.update(new QuantityType(Objects.requireNonNull(jsonState.colorTemp), Units.MIRED));
|
||||||
listener.updateChannelState(buildChannelUID(
|
listener.updateChannelState(buildChannelUID(COLOR_TEMP_CHANNEL_ID),
|
||||||
newStyleChannels ? COLOR_TEMP_CHANNEL_ID : COLOR_TEMP_CHANNEL_ID_DEPRECATED),
|
|
||||||
colorTempValue.getChannelState());
|
colorTempValue.getChannelState());
|
||||||
|
|
||||||
// Populate the color channel (if there is one) to match the color temperature.
|
// 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) {
|
if (colorTempChannel != null) {
|
||||||
double kelvin = ColorUtil.xyToKelvin(xy);
|
double kelvin = ColorUtil.xyToKelvin(xy);
|
||||||
colorTempValue.update(new QuantityType(kelvin, Units.KELVIN));
|
colorTempValue.update(new QuantityType(kelvin, Units.KELVIN));
|
||||||
listener.updateChannelState(buildChannelUID(
|
listener.updateChannelState(buildChannelUID(COLOR_TEMP_CHANNEL_ID),
|
||||||
newStyleChannels ? COLOR_TEMP_CHANNEL_ID : COLOR_TEMP_CHANNEL_ID_DEPRECATED),
|
|
||||||
colorTempValue.getChannelState());
|
colorTempValue.getChannelState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -378,9 +374,7 @@ public class JSONSchemaLight extends AbstractRawSchemaLight {
|
|||||||
final double[] xy = ColorUtil.hsbToXY(colorState);
|
final double[] xy = ColorUtil.hsbToXY(colorState);
|
||||||
double kelvin = ColorUtil.xyToKelvin(new double[] { xy[0], xy[1] });
|
double kelvin = ColorUtil.xyToKelvin(new double[] { xy[0], xy[1] });
|
||||||
colorTempValue.update(new QuantityType(kelvin, Units.KELVIN));
|
colorTempValue.update(new QuantityType(kelvin, Units.KELVIN));
|
||||||
listener.updateChannelState(
|
listener.updateChannelState(buildChannelUID(COLOR_TEMP_CHANNEL_ID),
|
||||||
buildChannelUID(
|
|
||||||
newStyleChannels ? COLOR_TEMP_CHANNEL_ID : COLOR_TEMP_CHANNEL_ID_DEPRECATED),
|
|
||||||
colorTempValue.getChannelState());
|
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
|
// https://github.com/home-assistant/core/blob/4f965f0eca09f0d12ae1c98c6786054063a36b44/homeassistant/components/mqtt/light/schema_json.py#L258
|
||||||
if (jsonState.colorTemp != null) {
|
if (jsonState.colorTemp != null) {
|
||||||
colorTempValue.update(new QuantityType(Objects.requireNonNull(jsonState.colorTemp), Units.MIRED));
|
colorTempValue.update(new QuantityType(Objects.requireNonNull(jsonState.colorTemp), Units.MIRED));
|
||||||
listener.updateChannelState(
|
listener.updateChannelState(buildChannelUID(COLOR_TEMP_CHANNEL_ID),
|
||||||
buildChannelUID(
|
|
||||||
newStyleChannels ? COLOR_TEMP_CHANNEL_ID : COLOR_TEMP_CHANNEL_ID_DEPRECATED),
|
|
||||||
colorTempValue.getChannelState());
|
colorTempValue.getChannelState());
|
||||||
|
|
||||||
colorModeValue.update(new StringType(LightColorMode.COLOR_MODE_COLOR_TEMP.serializedName()));
|
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());
|
logger.warn("Invalid color value for {}", getHaID());
|
||||||
}
|
}
|
||||||
|
|
||||||
listener.updateChannelState(
|
listener.updateChannelState(buildChannelUID(COLOR_MODE_CHANNEL_ID), colorModeValue.getChannelState());
|
||||||
buildChannelUID(newStyleChannels ? COLOR_MODE_CHANNEL_ID : COLOR_MODE_CHANNEL_ID_DEPRECATED),
|
|
||||||
colorModeValue.getChannelState());
|
|
||||||
|
|
||||||
if (localColorChannel != null) {
|
if (localColorChannel != null) {
|
||||||
listener.updateChannelState(localColorChannel.getChannel().getUID(), colorValue.getChannelState());
|
listener.updateChannelState(localColorChannel.getChannel().getUID(), colorValue.getChannelState());
|
||||||
|
@ -56,12 +56,9 @@ public abstract class Light extends AbstractComponent<Light.ChannelConfiguration
|
|||||||
|
|
||||||
protected static final String STATE_CHANNEL_ID = "state";
|
protected static final String STATE_CHANNEL_ID = "state";
|
||||||
protected static final String SWITCH_CHANNEL_ID = "switch";
|
protected static final String SWITCH_CHANNEL_ID = "switch";
|
||||||
protected static final String SWITCH_CHANNEL_ID_DEPRECATED = "on_off";
|
|
||||||
protected static final String BRIGHTNESS_CHANNEL_ID = "brightness";
|
protected static final String BRIGHTNESS_CHANNEL_ID = "brightness";
|
||||||
protected static final String COLOR_MODE_CHANNEL_ID = "color-mode";
|
protected static final String COLOR_MODE_CHANNEL_ID = "color-mode";
|
||||||
protected static final String COLOR_MODE_CHANNEL_ID_DEPRECATED = "color_mode";
|
|
||||||
protected static final String COLOR_TEMP_CHANNEL_ID = "color-temp";
|
protected static final String COLOR_TEMP_CHANNEL_ID = "color-temp";
|
||||||
protected static final String COLOR_TEMP_CHANNEL_ID_DEPRECATED = "color_temp";
|
|
||||||
protected static final String EFFECT_CHANNEL_ID = "effect";
|
protected static final String EFFECT_CHANNEL_ID = "effect";
|
||||||
// This channel is a synthetic channel that may send to other channels
|
// This channel is a synthetic channel that may send to other channels
|
||||||
// underneath
|
// underneath
|
||||||
@ -248,24 +245,23 @@ public abstract class Light extends AbstractComponent<Light.ChannelConfiguration
|
|||||||
|
|
||||||
protected final ChannelStateUpdateListener channelStateUpdateListener;
|
protected final ChannelStateUpdateListener channelStateUpdateListener;
|
||||||
|
|
||||||
public static Light create(ComponentFactory.ComponentConfiguration builder, boolean newStyleChannels)
|
public static Light create(ComponentFactory.ComponentConfiguration builder) throws UnsupportedComponentException {
|
||||||
throws UnsupportedComponentException {
|
|
||||||
String schema = builder.getConfig(ChannelConfiguration.class).schema;
|
String schema = builder.getConfig(ChannelConfiguration.class).schema;
|
||||||
switch (schema) {
|
switch (schema) {
|
||||||
case DEFAULT_SCHEMA:
|
case DEFAULT_SCHEMA:
|
||||||
return new DefaultSchemaLight(builder, newStyleChannels);
|
return new DefaultSchemaLight(builder);
|
||||||
case JSON_SCHEMA:
|
case JSON_SCHEMA:
|
||||||
return new JSONSchemaLight(builder, newStyleChannels);
|
return new JSONSchemaLight(builder);
|
||||||
case TEMPLATE_SCHEMA:
|
case TEMPLATE_SCHEMA:
|
||||||
return new TemplateSchemaLight(builder, newStyleChannels);
|
return new TemplateSchemaLight(builder);
|
||||||
default:
|
default:
|
||||||
throw new UnsupportedComponentException(
|
throw new UnsupportedComponentException(
|
||||||
"Component '" + builder.getHaID() + "' of schema '" + schema + "' is not supported!");
|
"Component '" + builder.getHaID() + "' of schema '" + schema + "' is not supported!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Light(ComponentFactory.ComponentConfiguration builder, boolean newStyleChannels) {
|
protected Light(ComponentFactory.ComponentConfiguration builder) {
|
||||||
super(builder, ChannelConfiguration.class, newStyleChannels);
|
super(builder, ChannelConfiguration.class);
|
||||||
this.channelStateUpdateListener = builder.getUpdateListener();
|
this.channelStateUpdateListener = builder.getUpdateListener();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -73,8 +73,8 @@ public class Lock extends AbstractComponent<Lock.ChannelConfiguration> {
|
|||||||
private OnOffValue lockValue;
|
private OnOffValue lockValue;
|
||||||
private TextValue stateValue;
|
private TextValue stateValue;
|
||||||
|
|
||||||
public Lock(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public Lock(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
|
|
||||||
this.optimistic = channelConfiguration.optimistic || channelConfiguration.stateTopic.isBlank();
|
this.optimistic = channelConfiguration.optimistic || channelConfiguration.stateTopic.isBlank();
|
||||||
|
|
||||||
|
@ -64,8 +64,8 @@ public class Number extends AbstractComponent<Number.ChannelConfiguration> {
|
|||||||
protected String mode = "auto";
|
protected String mode = "auto";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Number(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public Number(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
|
|
||||||
NumberValue value = new NumberValue(channelConfiguration.min, channelConfiguration.max,
|
NumberValue value = new NumberValue(channelConfiguration.min, channelConfiguration.max,
|
||||||
channelConfiguration.step, UnitUtils.parseUnit(channelConfiguration.unitOfMeasurement));
|
channelConfiguration.step, UnitUtils.parseUnit(channelConfiguration.unitOfMeasurement));
|
||||||
|
@ -45,8 +45,8 @@ public class Scene extends AbstractComponent<Scene.ChannelConfiguration> {
|
|||||||
protected String payloadOn = "ON";
|
protected String payloadOn = "ON";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Scene(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public Scene(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
|
|
||||||
TextValue value = new TextValue(new String[] { channelConfiguration.payloadOn });
|
TextValue value = new TextValue(new String[] { channelConfiguration.payloadOn });
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@ public class Select extends AbstractComponent<Select.ChannelConfiguration> {
|
|||||||
protected String[] options = new String[0];
|
protected String[] options = new String[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public Select(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public Select(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
|
|
||||||
TextValue value = new TextValue(channelConfiguration.options);
|
TextValue value = new TextValue(channelConfiguration.options);
|
||||||
|
|
||||||
|
@ -61,8 +61,8 @@ public class Sensor extends AbstractComponent<Sensor.ChannelConfiguration> {
|
|||||||
protected String stateTopic = "";
|
protected String stateTopic = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Sensor(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public Sensor(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
|
|
||||||
Value value;
|
Value value;
|
||||||
String uom = channelConfiguration.unitOfMeasurement;
|
String uom = channelConfiguration.unitOfMeasurement;
|
||||||
|
@ -54,8 +54,8 @@ public class Switch extends AbstractComponent<Switch.ChannelConfiguration> {
|
|||||||
protected String payloadOff = "OFF";
|
protected String payloadOff = "OFF";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Switch(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public Switch(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
|
|
||||||
OnOffValue value = new OnOffValue(channelConfiguration.stateOn, channelConfiguration.stateOff,
|
OnOffValue value = new OnOffValue(channelConfiguration.stateOn, channelConfiguration.stateOff,
|
||||||
channelConfiguration.payloadOn, channelConfiguration.payloadOff);
|
channelConfiguration.payloadOn, channelConfiguration.payloadOff);
|
||||||
|
@ -37,8 +37,8 @@ public class Tag extends AbstractComponent<Tag.ChannelConfiguration> {
|
|||||||
protected String topic = "";
|
protected String topic = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tag(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public Tag(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
|
|
||||||
buildChannel(TAG_CHANNEL_ID, ComponentChannelType.TRIGGER, new TextValue(), getName(),
|
buildChannel(TAG_CHANNEL_ID, ComponentChannelType.TRIGGER, new TextValue(), getName(),
|
||||||
componentConfiguration.getUpdateListener())
|
componentConfiguration.getUpdateListener())
|
||||||
|
@ -70,8 +70,8 @@ public class TemplateSchemaLight extends AbstractRawSchemaLight {
|
|||||||
public static final String EFFECT = "effect";
|
public static final String EFFECT = "effect";
|
||||||
}
|
}
|
||||||
|
|
||||||
public TemplateSchemaLight(ComponentFactory.ComponentConfiguration builder, boolean newStyleChannels) {
|
public TemplateSchemaLight(ComponentFactory.ComponentConfiguration builder) {
|
||||||
super(builder, newStyleChannels);
|
super(builder);
|
||||||
transformation = new HomeAssistantChannelTransformation(getJinjava(), this, "");
|
transformation = new HomeAssistantChannelTransformation(getJinjava(), this, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,14 +96,13 @@ public class TemplateSchemaLight extends AbstractRawSchemaLight {
|
|||||||
"Brightness", this).commandTopic(DUMMY_TOPIC, true, 1)
|
"Brightness", this).commandTopic(DUMMY_TOPIC, true, 1)
|
||||||
.commandFilter(command -> handleCommand(command)).withAutoUpdatePolicy(autoUpdatePolicy).build();
|
.commandFilter(command -> handleCommand(command)).withAutoUpdatePolicy(autoUpdatePolicy).build();
|
||||||
} else {
|
} else {
|
||||||
onOffChannel = buildChannel(newStyleChannels ? SWITCH_CHANNEL_ID : SWITCH_CHANNEL_ID_DEPRECATED,
|
onOffChannel = buildChannel(SWITCH_CHANNEL_ID, ComponentChannelType.SWITCH, onOffValue, "On/Off State",
|
||||||
ComponentChannelType.SWITCH, onOffValue, "On/Off State", this).commandTopic(DUMMY_TOPIC, true, 1)
|
this).commandTopic(DUMMY_TOPIC, true, 1).commandFilter(command -> handleCommand(command))
|
||||||
.commandFilter(command -> handleCommand(command)).withAutoUpdatePolicy(autoUpdatePolicy).build();
|
.withAutoUpdatePolicy(autoUpdatePolicy).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channelConfiguration.colorTempTemplate != null) {
|
if (channelConfiguration.colorTempTemplate != null) {
|
||||||
buildChannel(newStyleChannels ? COLOR_TEMP_CHANNEL_ID : COLOR_TEMP_CHANNEL_ID_DEPRECATED,
|
buildChannel(COLOR_TEMP_CHANNEL_ID, ComponentChannelType.NUMBER, colorTempValue, "Color Temperature", this)
|
||||||
ComponentChannelType.NUMBER, colorTempValue, "Color Temperature", this)
|
|
||||||
.commandTopic(DUMMY_TOPIC, true, 1).commandFilter(command -> handleColorTempCommand(command))
|
.commandTopic(DUMMY_TOPIC, true, 1).commandFilter(command -> handleColorTempCommand(command))
|
||||||
.withAutoUpdatePolicy(autoUpdatePolicy).build();
|
.withAutoUpdatePolicy(autoUpdatePolicy).build();
|
||||||
}
|
}
|
||||||
@ -285,9 +284,7 @@ public class TemplateSchemaLight extends AbstractRawSchemaLight {
|
|||||||
} else {
|
} else {
|
||||||
colorTempValue.update(new QuantityType(mireds, Units.MIRED));
|
colorTempValue.update(new QuantityType(mireds, Units.MIRED));
|
||||||
}
|
}
|
||||||
listener.updateChannelState(
|
listener.updateChannelState(buildChannelUID(COLOR_TEMP_CHANNEL_ID), colorTempValue.getChannelState());
|
||||||
buildChannelUID(newStyleChannels ? COLOR_TEMP_CHANNEL_ID : COLOR_TEMP_CHANNEL_ID_DEPRECATED),
|
|
||||||
colorTempValue.getChannelState());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,8 +54,8 @@ public class Text extends AbstractComponent<Text.ChannelConfiguration> {
|
|||||||
protected String mode = MODE_TEXT; // Presumably for a password, it should mask any controls in the UI
|
protected String mode = MODE_TEXT; // Presumably for a password, it should mask any controls in the UI
|
||||||
}
|
}
|
||||||
|
|
||||||
public Text(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public Text(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
|
|
||||||
TextValue value = new TextValue();
|
TextValue value = new TextValue();
|
||||||
|
|
||||||
|
@ -143,8 +143,8 @@ public class Update extends AbstractComponent<Update.ChannelConfiguration> imple
|
|||||||
private ReleaseState state = new ReleaseState();
|
private ReleaseState state = new ReleaseState();
|
||||||
private @Nullable ReleaseStateListener listener = null;
|
private @Nullable ReleaseStateListener listener = null;
|
||||||
|
|
||||||
public Update(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public Update(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
|
|
||||||
TextValue value = new TextValue();
|
TextValue value = new TextValue();
|
||||||
String commandTopic = channelConfiguration.commandTopic;
|
String commandTopic = channelConfiguration.commandTopic;
|
||||||
|
@ -58,13 +58,9 @@ public class Vacuum extends AbstractComponent<Vacuum.ChannelConfiguration> {
|
|||||||
|
|
||||||
public static final String COMMAND_CH_ID = "command";
|
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 = "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 = "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 = "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 = "json-attributes";
|
||||||
public static final String JSON_ATTRIBUTES_CH_ID_DEPRECATED = "jsonAttributes";
|
|
||||||
public static final String STATE_CH_ID = "state";
|
public static final String STATE_CH_ID = "state";
|
||||||
|
|
||||||
private static final String STATE_TEMPLATE = "{{ value_json.state }}";
|
private static final String STATE_TEMPLATE = "{{ value_json.state }}";
|
||||||
@ -122,8 +118,8 @@ public class Vacuum extends AbstractComponent<Vacuum.ChannelConfiguration> {
|
|||||||
*
|
*
|
||||||
* @param componentConfiguration generic componentConfiguration with not parsed JSON config
|
* @param componentConfiguration generic componentConfiguration with not parsed JSON config
|
||||||
*/
|
*/
|
||||||
public Vacuum(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public Vacuum(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
final ChannelStateUpdateListener updateListener = componentConfiguration.getUpdateListener();
|
final ChannelStateUpdateListener updateListener = componentConfiguration.getUpdateListener();
|
||||||
|
|
||||||
final var supportedFeatures = channelConfiguration.supportedFeatures;
|
final var supportedFeatures = channelConfiguration.supportedFeatures;
|
||||||
@ -137,7 +133,7 @@ public class Vacuum extends AbstractComponent<Vacuum.ChannelConfiguration> {
|
|||||||
addPayloadToList(supportedFeatures, FEATURE_PAUSE, channelConfiguration.payloadPause, commands);
|
addPayloadToList(supportedFeatures, FEATURE_PAUSE, channelConfiguration.payloadPause, commands);
|
||||||
|
|
||||||
buildOptionalChannel(COMMAND_CH_ID, ComponentChannelType.STRING, new TextValue(commands.toArray(new String[0])),
|
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;
|
final var fanSpeedList = channelConfiguration.fanSpeedList;
|
||||||
if (supportedFeatures.contains(FEATURE_FAN_SPEED) && fanSpeedList != null && !fanSpeedList.isEmpty()) {
|
if (supportedFeatures.contains(FEATURE_FAN_SPEED) && fanSpeedList != null && !fanSpeedList.isEmpty()) {
|
||||||
@ -147,21 +143,18 @@ public class Vacuum extends AbstractComponent<Vacuum.ChannelConfiguration> {
|
|||||||
}
|
}
|
||||||
var fanSpeedValue = new TextValue(fanSpeedList.toArray(new String[0]), fanSpeedCommandList);
|
var fanSpeedValue = new TextValue(fanSpeedList.toArray(new String[0]), fanSpeedCommandList);
|
||||||
if (supportedFeatures.contains(FEATURE_STATUS)) {
|
if (supportedFeatures.contains(FEATURE_STATUS)) {
|
||||||
buildOptionalChannel(newStyleChannels ? FAN_SPEED_CH_ID : FAN_SPEED_CH_ID_DEPRECATED,
|
buildOptionalChannel(FAN_SPEED_CH_ID, ComponentChannelType.STRING, fanSpeedValue, updateListener, null,
|
||||||
ComponentChannelType.STRING, fanSpeedValue, updateListener, null,
|
|
||||||
channelConfiguration.setFanSpeedTopic, "{{ value_json.fan_speed }}",
|
channelConfiguration.setFanSpeedTopic, "{{ value_json.fan_speed }}",
|
||||||
channelConfiguration.stateTopic);
|
channelConfiguration.stateTopic, "Fan Speed");
|
||||||
} else {
|
} else {
|
||||||
buildOptionalChannel(newStyleChannels ? FAN_SPEED_CH_ID : FAN_SPEED_CH_ID_DEPRECATED,
|
buildOptionalChannel(FAN_SPEED_CH_ID, ComponentChannelType.STRING, fanSpeedValue, updateListener, null,
|
||||||
ComponentChannelType.STRING, fanSpeedValue, updateListener, null,
|
channelConfiguration.setFanSpeedTopic, null, null, "Fan Speed");
|
||||||
channelConfiguration.setFanSpeedTopic, null, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supportedFeatures.contains(FEATURE_SEND_COMMAND)) {
|
if (supportedFeatures.contains(FEATURE_SEND_COMMAND)) {
|
||||||
buildOptionalChannel(newStyleChannels ? CUSTOM_COMMAND_CH_ID : CUSTOM_COMMAND_CH_ID_DEPRECATED,
|
buildOptionalChannel(CUSTOM_COMMAND_CH_ID, ComponentChannelType.STRING, new TextValue(), updateListener,
|
||||||
ComponentChannelType.STRING, new TextValue(), updateListener, null,
|
null, channelConfiguration.sendCommandTopic, null, null, "Custom Command");
|
||||||
channelConfiguration.sendCommandTopic, null, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supportedFeatures.contains(FEATURE_STATUS)) {
|
if (supportedFeatures.contains(FEATURE_STATUS)) {
|
||||||
@ -169,32 +162,24 @@ public class Vacuum extends AbstractComponent<Vacuum.ChannelConfiguration> {
|
|||||||
buildOptionalChannel(STATE_CH_ID, ComponentChannelType.STRING,
|
buildOptionalChannel(STATE_CH_ID, ComponentChannelType.STRING,
|
||||||
new TextValue(new String[] { STATE_CLEANING, STATE_DOCKED, STATE_PAUSED, STATE_IDLE,
|
new TextValue(new String[] { STATE_CLEANING, STATE_DOCKED, STATE_PAUSED, STATE_IDLE,
|
||||||
STATE_RETURNING, STATE_ERROR }),
|
STATE_RETURNING, STATE_ERROR }),
|
||||||
updateListener, null, null, STATE_TEMPLATE, channelConfiguration.stateTopic);
|
updateListener, null, null, STATE_TEMPLATE, channelConfiguration.stateTopic, "State");
|
||||||
if (supportedFeatures.contains(FEATURE_BATTERY)) {
|
if (supportedFeatures.contains(FEATURE_BATTERY)) {
|
||||||
buildOptionalChannel(newStyleChannels ? BATTERY_LEVEL_CH_ID : BATTERY_LEVEL_CH_ID_DEPRECATED,
|
buildOptionalChannel(BATTERY_LEVEL_CH_ID, ComponentChannelType.DIMMER,
|
||||||
ComponentChannelType.DIMMER,
|
|
||||||
new PercentageValue(BigDecimal.ZERO, BigDecimal.valueOf(100), BigDecimal.ONE, null, null, null),
|
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();
|
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
|
@Nullable
|
||||||
private ComponentChannel buildOptionalChannel(String channelId, ComponentChannelType channelType, Value valueState,
|
private ComponentChannel buildOptionalChannel(String channelId, ComponentChannelType channelType, Value valueState,
|
||||||
ChannelStateUpdateListener channelStateUpdateListener, @Nullable String commandTemplate,
|
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())) {
|
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())
|
.stateTopic(stateTopic, stateTemplate, channelConfiguration.getValueTemplate())
|
||||||
.commandTopic(commandTopic, channelConfiguration.isRetain(), channelConfiguration.getQos(),
|
.commandTopic(commandTopic, channelConfiguration.isRetain(), channelConfiguration.getQos(),
|
||||||
commandTemplate)
|
commandTemplate)
|
||||||
|
@ -110,8 +110,8 @@ public class Valve extends AbstractComponent<Valve.ChannelConfiguration> impleme
|
|||||||
private final ChannelStateUpdateListener channelStateUpdateListener;
|
private final ChannelStateUpdateListener channelStateUpdateListener;
|
||||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
public Valve(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public Valve(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
this.channelStateUpdateListener = componentConfiguration.getUpdateListener();
|
this.channelStateUpdateListener = componentConfiguration.getUpdateListener();
|
||||||
|
|
||||||
AutoUpdatePolicy autoUpdatePolicy = null;
|
AutoUpdatePolicy autoUpdatePolicy = null;
|
||||||
|
@ -113,8 +113,8 @@ public class WaterHeater extends AbstractComponent<WaterHeater.ChannelConfigurat
|
|||||||
protected List<String> modes = DEFAULT_MODES;
|
protected List<String> modes = DEFAULT_MODES;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WaterHeater(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
public WaterHeater(ComponentFactory.ComponentConfiguration componentConfiguration) {
|
||||||
super(componentConfiguration, ChannelConfiguration.class, newStyleChannels);
|
super(componentConfiguration, ChannelConfiguration.class);
|
||||||
|
|
||||||
if (!PLATFORM_WATER_HEATER.equals(channelConfiguration.platform)) {
|
if (!PLATFORM_WATER_HEATER.equals(channelConfiguration.platform)) {
|
||||||
throw new ConfigurationException("platform must be " + PLATFORM_WATER_HEATER);
|
throw new ConfigurationException("platform must be " + PLATFORM_WATER_HEATER);
|
||||||
|
@ -163,7 +163,6 @@ public class HomeAssistantDiscovery extends AbstractMQTTDiscovery {
|
|||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
properties = config.appendToProperties(properties);
|
properties = config.appendToProperties(properties);
|
||||||
properties.put("deviceId", thingID);
|
properties.put("deviceId", thingID);
|
||||||
properties.put("newStyleChannels", "true");
|
|
||||||
|
|
||||||
buildResult(thingID, thingUID, config.getThingName(), haID, properties, bridgeUID);
|
buildResult(thingID, thingUID, config.getThingName(), haID, properties, bridgeUID);
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,6 @@ public class HomeAssistantThingHandler extends AbstractMQTTThingHandler
|
|||||||
private Set<HaID> discoveryHomeAssistantIDs = new HashSet<>();
|
private Set<HaID> discoveryHomeAssistantIDs = new HashSet<>();
|
||||||
|
|
||||||
private boolean started;
|
private boolean started;
|
||||||
private boolean newStyleChannels;
|
|
||||||
private @Nullable Update updateComponent;
|
private @Nullable Update updateComponent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -135,11 +134,8 @@ public class HomeAssistantThingHandler extends AbstractMQTTThingHandler
|
|||||||
this.unitProvider = unitProvider;
|
this.unitProvider = unitProvider;
|
||||||
this.attributeReceiveTimeout = attributeReceiveTimeout;
|
this.attributeReceiveTimeout = attributeReceiveTimeout;
|
||||||
this.delayedProcessing = new DelayedBatchProcessing<>(attributeReceiveTimeout, this, scheduler);
|
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,
|
this.discoverComponents = new DiscoverComponents(thing.getUID(), scheduler, this, this, gson, jinjava,
|
||||||
unitProvider, newStyleChannels);
|
unitProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -187,8 +183,7 @@ public class HomeAssistantThingHandler extends AbstractMQTTThingHandler
|
|||||||
String channelConfigurationJSON = (String) channelConfig.get("config");
|
String channelConfigurationJSON = (String) channelConfig.get("config");
|
||||||
try {
|
try {
|
||||||
AbstractComponent<?> component = ComponentFactory.createComponent(thingUID, haID,
|
AbstractComponent<?> component = ComponentFactory.createComponent(thingUID, haID,
|
||||||
channelConfigurationJSON, this, this, scheduler, gson, jinjava, unitProvider,
|
channelConfigurationJSON, this, this, scheduler, gson, jinjava, unitProvider);
|
||||||
newStyleChannels);
|
|
||||||
if (typeID.equals(MqttBindingConstants.HOMEASSISTANT_MQTT_THING)) {
|
if (typeID.equals(MqttBindingConstants.HOMEASSISTANT_MQTT_THING)) {
|
||||||
typeID = calculateThingTypeUID(component);
|
typeID = calculateThingTypeUID(component);
|
||||||
}
|
}
|
||||||
|
@ -82,9 +82,6 @@ public abstract class AbstractComponentTests extends AbstractHomeAssistantTests
|
|||||||
|
|
||||||
when(callbackMock.getBridge(eq(BRIDGE_UID))).thenReturn(bridgeThing);
|
when(callbackMock.getBridge(eq(BRIDGE_UID))).thenReturn(bridgeThing);
|
||||||
|
|
||||||
if (useNewStyleChannels()) {
|
|
||||||
haThing.setProperty("newStyleChannels", "true");
|
|
||||||
}
|
|
||||||
thingHandler = new LatchThingHandler(haThing, channelTypeProvider, stateDescriptionProvider,
|
thingHandler = new LatchThingHandler(haThing, channelTypeProvider, stateDescriptionProvider,
|
||||||
channelTypeRegistry, unitProvider, SUBSCRIBE_TIMEOUT, ATTRIBUTE_RECEIVE_TIMEOUT);
|
channelTypeRegistry, unitProvider, SUBSCRIBE_TIMEOUT, ATTRIBUTE_RECEIVE_TIMEOUT);
|
||||||
thingHandler.setConnection(bridgeConnection);
|
thingHandler.setConnection(bridgeConnection);
|
||||||
@ -109,13 +106,6 @@ public abstract class AbstractComponentTests extends AbstractHomeAssistantTests
|
|||||||
*/
|
*/
|
||||||
protected abstract Set<String> getConfigTopics();
|
protected abstract Set<String> 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()}
|
* Process payload to discover and configure component. Topic should be added to {@link #getConfigTopics()}
|
||||||
*
|
*
|
||||||
|
@ -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<String> getConfigTopics() {
|
|
||||||
return Set.of(CONFIG_TOPIC);
|
|
||||||
}
|
|
||||||
}
|
|
@ -88,9 +88,4 @@ public class AlarmControlPanelTests extends AbstractComponentTests {
|
|||||||
protected Set<String> getConfigTopics() {
|
protected Set<String> getConfigTopics() {
|
||||||
return Set.of(CONFIG_TOPIC);
|
return Set.of(CONFIG_TOPIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean useNewStyleChannels() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public class BinarySensorTests extends AbstractComponentTests {
|
|||||||
|
|
||||||
assertThat(component.channels.size(), is(1));
|
assertThat(component.channels.size(), is(1));
|
||||||
assertThat(component.getName(), is("onoffsensor"));
|
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",
|
assertChannel(component, BinarySensor.SENSOR_CHANNEL_ID, "zigbee2mqtt/sensor/state", "", "onoffsensor",
|
||||||
OnOffValue.class);
|
OnOffValue.class);
|
||||||
|
@ -76,10 +76,9 @@ public class ClimateTests extends AbstractComponentTests {
|
|||||||
assertThat(component.getName(), is("th1"));
|
assertThat(component.getName(), is("th1"));
|
||||||
|
|
||||||
assertChannel(component, Climate.ACTION_CH_ID, "zigbee2mqtt/th1", "", "th1", TextValue.class);
|
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",
|
assertChannel(component, Climate.AWAY_MODE_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/set/away_mode", "th1",
|
||||||
"th1", OnOffValue.class);
|
OnOffValue.class);
|
||||||
assertChannel(component, Climate.CURRENT_TEMPERATURE_CH_ID_DEPRECATED, "zigbee2mqtt/th1", "", "th1",
|
assertChannel(component, Climate.CURRENT_TEMPERATURE_CH_ID, "zigbee2mqtt/th1", "", "th1", NumberValue.class);
|
||||||
NumberValue.class);
|
|
||||||
assertChannel(component, Climate.HOLD_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/set/preset", "th1",
|
assertChannel(component, Climate.HOLD_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/set/preset", "th1",
|
||||||
TextValue.class);
|
TextValue.class);
|
||||||
assertChannel(component, Climate.MODE_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/set/system_mode", "th1",
|
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"}\
|
"current_heating_setpoint": "24"}\
|
||||||
""");
|
""");
|
||||||
assertState(component, Climate.ACTION_CH_ID, new StringType("off"));
|
assertState(component, Climate.ACTION_CH_ID, new StringType("off"));
|
||||||
assertState(component, Climate.AWAY_MODE_CH_ID_DEPRECATED, OnOffType.ON);
|
assertState(component, Climate.AWAY_MODE_CH_ID, OnOffType.ON);
|
||||||
assertState(component, Climate.CURRENT_TEMPERATURE_CH_ID_DEPRECATED, new QuantityType<>(22.2, SIUnits.CELSIUS));
|
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.HOLD_CH_ID, new StringType("schedule"));
|
||||||
assertState(component, Climate.MODE_CH_ID, new StringType("heat"));
|
assertState(component, Climate.MODE_CH_ID, new StringType("heat"));
|
||||||
assertState(component, Climate.TEMPERATURE_CH_ID, new QuantityType<>(24, SIUnits.CELSIUS));
|
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");
|
assertPublished("zigbee2mqtt/th1/set/away_mode", "OFF");
|
||||||
component.getChannel(Climate.HOLD_CH_ID).getState().publishValue(new StringType("eco"));
|
component.getChannel(Climate.HOLD_CH_ID).getState().publishValue(new StringType("eco"));
|
||||||
assertPublished("zigbee2mqtt/th1/set/preset", "eco");
|
assertPublished("zigbee2mqtt/th1/set/preset", "eco");
|
||||||
@ -148,10 +147,9 @@ public class ClimateTests extends AbstractComponentTests {
|
|||||||
assertThat(component.getName(), is("th1"));
|
assertThat(component.getName(), is("th1"));
|
||||||
|
|
||||||
assertChannel(component, Climate.ACTION_CH_ID, "zigbee2mqtt/th1", "", "th1", TextValue.class);
|
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",
|
assertChannel(component, Climate.AWAY_MODE_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/set/away_mode", "th1",
|
||||||
"th1", OnOffValue.class);
|
OnOffValue.class);
|
||||||
assertChannel(component, Climate.CURRENT_TEMPERATURE_CH_ID_DEPRECATED, "zigbee2mqtt/th1", "", "th1",
|
assertChannel(component, Climate.CURRENT_TEMPERATURE_CH_ID, "zigbee2mqtt/th1", "", "th1", NumberValue.class);
|
||||||
NumberValue.class);
|
|
||||||
assertChannel(component, Climate.HOLD_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/set/preset", "th1",
|
assertChannel(component, Climate.HOLD_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/set/preset", "th1",
|
||||||
TextValue.class);
|
TextValue.class);
|
||||||
assertChannel(component, Climate.MODE_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/set/system_mode", "th1",
|
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"}\
|
"current_heating_setpoint": "24"}\
|
||||||
""");
|
""");
|
||||||
assertState(component, Climate.ACTION_CH_ID, new StringType("off"));
|
assertState(component, Climate.ACTION_CH_ID, new StringType("off"));
|
||||||
assertState(component, Climate.AWAY_MODE_CH_ID_DEPRECATED, OnOffType.ON);
|
assertState(component, Climate.AWAY_MODE_CH_ID, OnOffType.ON);
|
||||||
assertState(component, Climate.CURRENT_TEMPERATURE_CH_ID_DEPRECATED, new QuantityType<>(22.2, SIUnits.CELSIUS));
|
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.HOLD_CH_ID, new StringType("schedule"));
|
||||||
assertState(component, Climate.MODE_CH_ID, new StringType("heat"));
|
assertState(component, Climate.MODE_CH_ID, new StringType("heat"));
|
||||||
assertState(component, Climate.TEMPERATURE_CH_ID, new QuantityType<>(24, SIUnits.CELSIUS));
|
assertState(component, Climate.TEMPERATURE_CH_ID, new QuantityType<>(24, SIUnits.CELSIUS));
|
||||||
|
|
||||||
// Climate is in OFF state
|
// 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");
|
assertNotPublished("zigbee2mqtt/th1/set/away_mode", "OFF");
|
||||||
component.getChannel(Climate.HOLD_CH_ID).getState().publishValue(new StringType("eco"));
|
component.getChannel(Climate.HOLD_CH_ID).getState().publishValue(new StringType("eco"));
|
||||||
assertNotPublished("zigbee2mqtt/th1/set/preset", "eco");
|
assertNotPublished("zigbee2mqtt/th1/set/preset", "eco");
|
||||||
@ -193,7 +191,7 @@ public class ClimateTests extends AbstractComponentTests {
|
|||||||
""");
|
""");
|
||||||
|
|
||||||
// Climate is in ON state
|
// 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");
|
assertPublished("zigbee2mqtt/th1/set/away_mode", "OFF");
|
||||||
component.getChannel(Climate.HOLD_CH_ID).getState().publishValue(new StringType("eco"));
|
component.getChannel(Climate.HOLD_CH_ID).getState().publishValue(new StringType("eco"));
|
||||||
assertPublished("zigbee2mqtt/th1/set/preset", "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.ACTION_CH_ID, "zigbee2mqtt/th1", "", "MQTT HVAC", TextValue.class);
|
||||||
assertChannel(component, Climate.AUX_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/aux", "MQTT HVAC",
|
assertChannel(component, Climate.AUX_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/aux", "MQTT HVAC",
|
||||||
OnOffValue.class);
|
OnOffValue.class);
|
||||||
assertChannel(component, Climate.AWAY_MODE_CH_ID_DEPRECATED, "zigbee2mqtt/th1", "zigbee2mqtt/th1/away_mode",
|
assertChannel(component, Climate.AWAY_MODE_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/away_mode", "MQTT HVAC",
|
||||||
"MQTT HVAC", OnOffValue.class);
|
OnOffValue.class);
|
||||||
assertChannel(component, Climate.CURRENT_TEMPERATURE_CH_ID_DEPRECATED, "zigbee2mqtt/th1", "", "MQTT HVAC",
|
assertChannel(component, Climate.CURRENT_TEMPERATURE_CH_ID, "zigbee2mqtt/th1", "", "MQTT HVAC",
|
||||||
NumberValue.class);
|
NumberValue.class);
|
||||||
assertChannel(component, Climate.FAN_MODE_CH_ID_DEPRECATED, "zigbee2mqtt/th1", "zigbee2mqtt/th1/fan_mode",
|
assertChannel(component, Climate.FAN_MODE_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/fan_mode", "MQTT HVAC",
|
||||||
"MQTT HVAC", TextValue.class);
|
TextValue.class);
|
||||||
assertChannel(component, Climate.HOLD_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/hold", "MQTT HVAC",
|
assertChannel(component, Climate.HOLD_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/hold", "MQTT HVAC",
|
||||||
TextValue.class);
|
TextValue.class);
|
||||||
assertChannel(component, Climate.MODE_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/mode", "MQTT HVAC",
|
assertChannel(component, Climate.MODE_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/mode", "MQTT HVAC",
|
||||||
@ -270,10 +268,10 @@ public class ClimateTests extends AbstractComponentTests {
|
|||||||
TextValue.class);
|
TextValue.class);
|
||||||
assertChannel(component, Climate.TEMPERATURE_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/temperature",
|
assertChannel(component, Climate.TEMPERATURE_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/temperature",
|
||||||
"MQTT HVAC", NumberValue.class);
|
"MQTT HVAC", NumberValue.class);
|
||||||
assertChannel(component, Climate.TEMPERATURE_HIGH_CH_ID_DEPRECATED, "zigbee2mqtt/th1",
|
assertChannel(component, Climate.TEMPERATURE_HIGH_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/temperature_high",
|
||||||
"zigbee2mqtt/th1/temperature_high", "MQTT HVAC", NumberValue.class);
|
"MQTT HVAC", NumberValue.class);
|
||||||
assertChannel(component, Climate.TEMPERATURE_LOW_CH_ID_DEPRECATED, "zigbee2mqtt/th1",
|
assertChannel(component, Climate.TEMPERATURE_LOW_CH_ID, "zigbee2mqtt/th1", "zigbee2mqtt/th1/temperature_low",
|
||||||
"zigbee2mqtt/th1/temperature_low", "MQTT HVAC", NumberValue.class);
|
"MQTT HVAC", NumberValue.class);
|
||||||
assertChannel(component, Climate.POWER_CH_ID, "", "zigbee2mqtt/th1/power", "MQTT HVAC", OnOffValue.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",
|
assertChannel(component, Climate.JSON_ATTRIBUTES_CHANNEL_ID, "zigbee2mqtt/th1", "", "JSON Attributes",
|
||||||
TextValue.class);
|
TextValue.class);
|
||||||
@ -287,24 +285,21 @@ public class ClimateTests extends AbstractComponentTests {
|
|||||||
|
|
||||||
assertState(component, Climate.ACTION_CH_ID, new StringType("fan"));
|
assertState(component, Climate.ACTION_CH_ID, new StringType("fan"));
|
||||||
assertState(component, Climate.AUX_CH_ID, OnOffType.ON);
|
assertState(component, Climate.AUX_CH_ID, OnOffType.ON);
|
||||||
assertState(component, Climate.AWAY_MODE_CH_ID_DEPRECATED, OnOffType.OFF);
|
assertState(component, Climate.AWAY_MODE_CH_ID, OnOffType.OFF);
|
||||||
assertState(component, Climate.CURRENT_TEMPERATURE_CH_ID_DEPRECATED,
|
assertState(component, Climate.CURRENT_TEMPERATURE_CH_ID, new QuantityType<>(35.5, ImperialUnits.FAHRENHEIT));
|
||||||
new QuantityType<>(35.5, ImperialUnits.FAHRENHEIT));
|
assertState(component, Climate.FAN_MODE_CH_ID, new StringType("p2"));
|
||||||
assertState(component, Climate.FAN_MODE_CH_ID_DEPRECATED, new StringType("p2"));
|
|
||||||
assertState(component, Climate.HOLD_CH_ID, new StringType("u2"));
|
assertState(component, Climate.HOLD_CH_ID, new StringType("u2"));
|
||||||
assertState(component, Climate.MODE_CH_ID, new StringType("B1"));
|
assertState(component, Climate.MODE_CH_ID, new StringType("B1"));
|
||||||
assertState(component, Climate.SWING_CH_ID, new StringType("G1"));
|
assertState(component, Climate.SWING_CH_ID, new StringType("G1"));
|
||||||
assertState(component, Climate.TEMPERATURE_CH_ID, new QuantityType<>(30, ImperialUnits.FAHRENHEIT));
|
assertState(component, Climate.TEMPERATURE_CH_ID, new QuantityType<>(30, ImperialUnits.FAHRENHEIT));
|
||||||
assertState(component, Climate.TEMPERATURE_HIGH_CH_ID_DEPRECATED,
|
assertState(component, Climate.TEMPERATURE_HIGH_CH_ID, new QuantityType<>(37, ImperialUnits.FAHRENHEIT));
|
||||||
new QuantityType<>(37, ImperialUnits.FAHRENHEIT));
|
assertState(component, Climate.TEMPERATURE_LOW_CH_ID, new QuantityType<>(20, ImperialUnits.FAHRENHEIT));
|
||||||
assertState(component, Climate.TEMPERATURE_LOW_CH_ID_DEPRECATED,
|
|
||||||
new QuantityType<>(20, ImperialUnits.FAHRENHEIT));
|
|
||||||
|
|
||||||
component.getChannel(Climate.AUX_CH_ID).getState().publishValue(OnOffType.OFF);
|
component.getChannel(Climate.AUX_CH_ID).getState().publishValue(OnOffType.OFF);
|
||||||
assertPublished("zigbee2mqtt/th1/aux", "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");
|
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");
|
assertPublished("zigbee2mqtt/th1/fan_mode", "fan_mode=p1");
|
||||||
component.getChannel(Climate.HOLD_CH_ID).getState().publishValue(new StringType("u3"));
|
component.getChannel(Climate.HOLD_CH_ID).getState().publishValue(new StringType("u3"));
|
||||||
assertPublished("zigbee2mqtt/th1/hold", "hold=u3");
|
assertPublished("zigbee2mqtt/th1/hold", "hold=u3");
|
||||||
@ -314,9 +309,9 @@ public class ClimateTests extends AbstractComponentTests {
|
|||||||
assertPublished("zigbee2mqtt/th1/swing", "swing=G2");
|
assertPublished("zigbee2mqtt/th1/swing", "swing=G2");
|
||||||
component.getChannel(Climate.TEMPERATURE_CH_ID).getState().publishValue(new DecimalType(30.5));
|
component.getChannel(Climate.TEMPERATURE_CH_ID).getState().publishValue(new DecimalType(30.5));
|
||||||
assertPublished("zigbee2mqtt/th1/temperature", "temperature=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");
|
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");
|
assertPublished("zigbee2mqtt/th1/temperature_low", "temperature_low=19.5");
|
||||||
component.getChannel(Climate.POWER_CH_ID).getState().publishValue(OnOffType.OFF);
|
component.getChannel(Climate.POWER_CH_ID).getState().publishValue(OnOffType.OFF);
|
||||||
assertPublished("zigbee2mqtt/th1/power", "OFF");
|
assertPublished("zigbee2mqtt/th1/power", "OFF");
|
||||||
|
@ -274,16 +274,16 @@ public class DefaultSchemaLightTests extends AbstractComponentTests {
|
|||||||
assertThat(component.channels.size(), is(1));
|
assertThat(component.channels.size(), is(1));
|
||||||
assertThat(component.getName(), is("light"));
|
assertThat(component.getName(), is("light"));
|
||||||
|
|
||||||
assertChannel(component, Light.SWITCH_CHANNEL_ID_DEPRECATED, "zigbee2mqtt/light/state",
|
assertChannel(component, Light.SWITCH_CHANNEL_ID, "zigbee2mqtt/light/state", "zigbee2mqtt/light/set/state",
|
||||||
"zigbee2mqtt/light/set/state", "On/Off State", OnOffValue.class);
|
"On/Off State", OnOffValue.class);
|
||||||
assertThat(component.brightnessChannel, is(nullValue()));
|
assertThat(component.brightnessChannel, is(nullValue()));
|
||||||
|
|
||||||
publishMessage("zigbee2mqtt/light/state", "{\"power\": \"ON_\"}");
|
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_\"}");
|
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_");
|
assertPublished("zigbee2mqtt/light/set/state", "OFF_");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,17 +305,17 @@ public class DefaultSchemaLightTests extends AbstractComponentTests {
|
|||||||
assertThat(component.channels.size(), is(2));
|
assertThat(component.channels.size(), is(2));
|
||||||
assertThat(component.getName(), is("light"));
|
assertThat(component.getName(), is("light"));
|
||||||
|
|
||||||
assertChannel(component, Light.SWITCH_CHANNEL_ID_DEPRECATED, "zigbee2mqtt/light/state",
|
assertChannel(component, Light.SWITCH_CHANNEL_ID, "zigbee2mqtt/light/state", "zigbee2mqtt/light/set/state",
|
||||||
"zigbee2mqtt/light/set/state", "On/Off State", OnOffValue.class);
|
"On/Off State", OnOffValue.class);
|
||||||
assertChannel(component, Light.EFFECT_CHANNEL_ID, "zigbee2mqtt/light/effect", "zigbee2mqtt/light/set/effect",
|
assertChannel(component, Light.EFFECT_CHANNEL_ID, "zigbee2mqtt/light/effect", "zigbee2mqtt/light/set/effect",
|
||||||
"Lighting Effect", TextValue.class);
|
"Lighting Effect", TextValue.class);
|
||||||
|
|
||||||
publishMessage("zigbee2mqtt/light/state", "{\"power\": \"ON\"}");
|
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");
|
publishMessage("zigbee2mqtt/light/effect", "party");
|
||||||
assertState(component, Light.EFFECT_CHANNEL_ID, new StringType("party"));
|
assertState(component, Light.EFFECT_CHANNEL_ID, new StringType("party"));
|
||||||
publishMessage("zigbee2mqtt/light/state", "{\"power\": \"OFF\"}");
|
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"));
|
sendCommand(component, Light.EFFECT_CHANNEL_ID, new StringType("rainbow"));
|
||||||
assertPublished("zigbee2mqtt/light/set/effect", "rainbow");
|
assertPublished("zigbee2mqtt/light/set/effect", "rainbow");
|
||||||
|
@ -145,9 +145,4 @@ public class DeviceTriggerTests extends AbstractComponentTests {
|
|||||||
protected Set<String> getConfigTopics() {
|
protected Set<String> getConfigTopics() {
|
||||||
return Set.of(CONFIG_TOPIC_1, CONFIG_TOPIC_2);
|
return Set.of(CONFIG_TOPIC_1, CONFIG_TOPIC_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean useNewStyleChannels() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -73,21 +73,21 @@ public class FanTests extends AbstractComponentTests {
|
|||||||
assertThat(component.channels.size(), is(1));
|
assertThat(component.channels.size(), is(1));
|
||||||
assertThat(component.getName(), is("fan"));
|
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);
|
"On/Off State", OnOffValue.class, null);
|
||||||
|
|
||||||
publishMessage("zigbee2mqtt/fan/state", "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", "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_");
|
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_");
|
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_");
|
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_");
|
assertPublished("zigbee2mqtt/fan/set/state", "ON_");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ public class FanTests extends AbstractComponentTests {
|
|||||||
assertThat(component.channels.size(), is(1));
|
assertThat(component.channels.size(), is(1));
|
||||||
assertThat(component.getName(), is("fan"));
|
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);
|
OnOffValue.class, AutoUpdatePolicy.RECOMMEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ public class FanTests extends AbstractComponentTests {
|
|||||||
assertThat(component.channels.size(), is(1));
|
assertThat(component.channels.size(), is(1));
|
||||||
assertThat(component.getName(), is("fan"));
|
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);
|
"On/Off State", OnOffValue.class, AutoUpdatePolicy.RECOMMEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,7 +296,7 @@ public class FanTests extends AbstractComponentTests {
|
|||||||
|
|
||||||
assertThat(component.channels.size(), is(1));
|
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_");
|
assertPublished("zigbee2mqtt/fan/set/state", "set to OFF_");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,16 +203,16 @@ public class JSONSchemaLightTests extends AbstractComponentTests {
|
|||||||
assertThat(component.channels.size(), is(1));
|
assertThat(component.channels.size(), is(1));
|
||||||
assertThat(component.getName(), is("light"));
|
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\" }");
|
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\" }");
|
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\"}");
|
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\"}");
|
assertPublished("zigbee2mqtt/light/set/state", "{\"state\":\"ON\"}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ public class SensorTests extends AbstractComponentTests {
|
|||||||
|
|
||||||
assertThat(component.channels.size(), is(1));
|
assertThat(component.channels.size(), is(1));
|
||||||
assertThat(component.getName(), is("sensor1"));
|
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",
|
assertChannel(component, Sensor.SENSOR_CHANNEL_ID, "zigbee2mqtt/sensor/state", "", "sensor1",
|
||||||
NumberValue.class);
|
NumberValue.class);
|
||||||
|
@ -151,12 +151,11 @@ public class TemplateSchemaLightTests extends AbstractComponentTests {
|
|||||||
assertThat(component.getName(), is("Bulb-white"));
|
assertThat(component.getName(), is("Bulb-white"));
|
||||||
|
|
||||||
assertChannel(component, Light.BRIGHTNESS_CHANNEL_ID, "", "dummy", "Brightness", PercentageValue.class);
|
assertChannel(component, Light.BRIGHTNESS_CHANNEL_ID, "", "dummy", "Brightness", PercentageValue.class);
|
||||||
assertChannel(component, Light.COLOR_TEMP_CHANNEL_ID_DEPRECATED, "", "dummy", "Color Temperature",
|
assertChannel(component, Light.COLOR_TEMP_CHANNEL_ID, "", "dummy", "Color Temperature", NumberValue.class);
|
||||||
NumberValue.class);
|
|
||||||
|
|
||||||
publishMessage("shellies/bulb/color/0/status", "{ \"state\": \"on\", \"brightness\": 100 }");
|
publishMessage("shellies/bulb/color/0/status", "{ \"state\": \"on\", \"brightness\": 100 }");
|
||||||
assertState(component, Light.BRIGHTNESS_CHANNEL_ID, PercentType.HUNDRED);
|
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);
|
sendCommand(component, Light.BRIGHTNESS_CHANNEL_ID, PercentType.HUNDRED);
|
||||||
assertPublished("shellies/bulb/color/0/set", "{\"turn\": \"on\", \"mode\": \"white\", \"brightness\": 100}");
|
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);
|
sendCommand(component, Light.BRIGHTNESS_CHANNEL_ID, OnOffType.OFF);
|
||||||
assertPublished("shellies/bulb/color/0/set", "{\"turn\":\"off\", \"mode\": \"white\"}");
|
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}");
|
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.channels.size(), is(1));
|
||||||
assertThat(component.getName(), is("light"));
|
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\"}");
|
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\"}");
|
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");
|
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");
|
assertPublished("zigbee2mqtt/light/set/state", "on");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.channels.size(), is(6)); // command, state, fan speed, send command, battery, json attrs
|
||||||
assertThat(component.getName(), is("Rockrobo"));
|
assertThat(component.getName(), is("Rockrobo"));
|
||||||
assertChannel(component, Vacuum.COMMAND_CH_ID, "", "valetudo/rockrobo/command", "Rockrobo", TextValue.class);
|
assertChannel(component, Vacuum.COMMAND_CH_ID, "", "valetudo/rockrobo/command", "Command", TextValue.class);
|
||||||
assertChannel(component, Vacuum.STATE_CH_ID, "valetudo/rockrobo/state", "", "Rockrobo", TextValue.class);
|
assertChannel(component, Vacuum.STATE_CH_ID, "valetudo/rockrobo/state", "", "State", TextValue.class);
|
||||||
assertChannel(component, Vacuum.FAN_SPEED_CH_ID_DEPRECATED, "valetudo/rockrobo/state",
|
assertChannel(component, Vacuum.FAN_SPEED_CH_ID, "valetudo/rockrobo/state", "valetudo/rockrobo/set_fan_speed",
|
||||||
"valetudo/rockrobo/set_fan_speed", "Rockrobo", TextValue.class);
|
"Fan Speed", TextValue.class);
|
||||||
assertChannel(component, Vacuum.CUSTOM_COMMAND_CH_ID_DEPRECATED, "", "valetudo/rockrobo/custom_command",
|
assertChannel(component, Vacuum.CUSTOM_COMMAND_CH_ID, "", "valetudo/rockrobo/custom_command", "Custom Command",
|
||||||
"Rockrobo", TextValue.class);
|
TextValue.class);
|
||||||
assertChannel(component, Vacuum.BATTERY_LEVEL_CH_ID_DEPRECATED, "valetudo/rockrobo/state", "", "Rockrobo",
|
assertChannel(component, Vacuum.BATTERY_LEVEL_CH_ID, "valetudo/rockrobo/state", "", "Battery Level",
|
||||||
PercentageValue.class);
|
PercentageValue.class);
|
||||||
assertChannel(component, Vacuum.JSON_ATTRIBUTES_CH_ID_DEPRECATED, "valetudo/rockrobo/attributes", "",
|
assertChannel(component, Vacuum.JSON_ATTRIBUTES_CH_ID, "valetudo/rockrobo/attributes", "", "JSON Attributes",
|
||||||
"Rockrobo", TextValue.class);
|
TextValue.class);
|
||||||
|
|
||||||
assertState(component, Vacuum.STATE_CH_ID, UnDefType.UNDEF);
|
assertState(component, Vacuum.STATE_CH_ID, UnDefType.UNDEF);
|
||||||
assertState(component, Vacuum.FAN_SPEED_CH_ID_DEPRECATED, UnDefType.UNDEF);
|
assertState(component, Vacuum.FAN_SPEED_CH_ID, UnDefType.UNDEF);
|
||||||
assertState(component, Vacuum.BATTERY_LEVEL_CH_ID_DEPRECATED, UnDefType.UNDEF);
|
assertState(component, Vacuum.BATTERY_LEVEL_CH_ID, UnDefType.UNDEF);
|
||||||
assertState(component, Vacuum.JSON_ATTRIBUTES_CH_ID_DEPRECATED, UnDefType.UNDEF);
|
assertState(component, Vacuum.JSON_ATTRIBUTES_CH_ID, UnDefType.UNDEF);
|
||||||
|
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
String jsonValue;
|
String jsonValue;
|
||||||
@ -124,9 +124,9 @@ public class VacuumTests extends AbstractComponentTests {
|
|||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
|
||||||
assertState(component, Vacuum.STATE_CH_ID, new StringType(Vacuum.STATE_DOCKED));
|
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.FAN_SPEED_CH_ID, new StringType("max"));
|
||||||
assertState(component, Vacuum.BATTERY_LEVEL_CH_ID_DEPRECATED, new PercentType(100));
|
assertState(component, Vacuum.BATTERY_LEVEL_CH_ID, new PercentType(100));
|
||||||
assertState(component, Vacuum.JSON_ATTRIBUTES_CH_ID_DEPRECATED, new StringType(jsonValue));
|
assertState(component, Vacuum.JSON_ATTRIBUTES_CH_ID, new StringType(jsonValue));
|
||||||
|
|
||||||
component.getChannel(Vacuum.COMMAND_CH_ID).getState().publishValue(new StringType("start"));
|
component.getChannel(Vacuum.COMMAND_CH_ID).getState().publishValue(new StringType("start"));
|
||||||
assertPublished("valetudo/rockrobo/command", "start");
|
assertPublished("valetudo/rockrobo/command", "start");
|
||||||
@ -142,11 +142,11 @@ public class VacuumTests extends AbstractComponentTests {
|
|||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
|
||||||
assertState(component, Vacuum.STATE_CH_ID, new StringType(Vacuum.STATE_CLEANING));
|
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.FAN_SPEED_CH_ID, new StringType("max"));
|
||||||
assertState(component, Vacuum.BATTERY_LEVEL_CH_ID_DEPRECATED, new PercentType(99));
|
assertState(component, Vacuum.BATTERY_LEVEL_CH_ID, new PercentType(99));
|
||||||
assertState(component, Vacuum.JSON_ATTRIBUTES_CH_ID_DEPRECATED, new StringType(jsonValue));
|
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");
|
assertPublished("valetudo/rockrobo/set_fan_speed", "medium");
|
||||||
|
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
@ -160,9 +160,9 @@ public class VacuumTests extends AbstractComponentTests {
|
|||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
|
||||||
assertState(component, Vacuum.STATE_CH_ID, new StringType(Vacuum.STATE_RETURNING));
|
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.FAN_SPEED_CH_ID, new StringType("medium"));
|
||||||
assertState(component, Vacuum.BATTERY_LEVEL_CH_ID_DEPRECATED, new PercentType(80));
|
assertState(component, Vacuum.BATTERY_LEVEL_CH_ID, new PercentType(80));
|
||||||
assertState(component, Vacuum.JSON_ATTRIBUTES_CH_ID_DEPRECATED, new StringType(jsonValue));
|
assertState(component, Vacuum.JSON_ATTRIBUTES_CH_ID, new StringType(jsonValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -222,13 +222,13 @@ public class HomeAssistantThingHandlerTests extends AbstractHomeAssistantTests {
|
|||||||
//
|
//
|
||||||
// verify that both channels are there and the label corresponds to newer discovery topic payload
|
// 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());
|
assertThat("Corridor temperature channel is created", corridorTempChannel, notNullValue());
|
||||||
Objects.requireNonNull(corridorTempChannel); // for compiler
|
Objects.requireNonNull(corridorTempChannel); // for compiler
|
||||||
assertThat("Corridor temperature channel is having the updated label from 2nd discovery topic publish",
|
assertThat("Corridor temperature channel is having the updated label from 2nd discovery topic publish",
|
||||||
corridorTempChannel.getLabel(), is("CorridorTemp NEW"));
|
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());
|
assertThat("Outside temperature channel is created", outsideTempChannel, notNullValue());
|
||||||
|
|
||||||
verify(thingHandler, times(2)).componentDiscovered(eq(new HaID(configTopicTempCorridor)), any(Sensor.class));
|
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())
|
haThing = ThingBuilder.create(HA_TYPE_UID, HA_UID).withBridge(BRIDGE_UID).withChannel(channelBuilder.build())
|
||||||
.withConfiguration(thingConfiguration).build();
|
.withConfiguration(thingConfiguration).build();
|
||||||
haThing.setProperty("newStyleChannels", "true");
|
|
||||||
|
|
||||||
setupThingHandler();
|
setupThingHandler();
|
||||||
thingHandler.initialize();
|
thingHandler.initialize();
|
||||||
@ -358,58 +357,6 @@ public class HomeAssistantThingHandlerTests extends AbstractHomeAssistantTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDuplicateChannelId() {
|
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,
|
thingHandler = new HomeAssistantThingHandler(haThing, channelTypeProvider, stateDescriptionProvider,
|
||||||
channelTypeRegistry, new Jinjava(), unitProvider, SUBSCRIBE_TIMEOUT, ATTRIBUTE_RECEIVE_TIMEOUT);
|
channelTypeRegistry, new Jinjava(), unitProvider, SUBSCRIBE_TIMEOUT, ATTRIBUTE_RECEIVE_TIMEOUT);
|
||||||
thingHandler.setConnection(bridgeConnection);
|
thingHandler.setConnection(bridgeConnection);
|
||||||
@ -465,8 +412,7 @@ public class HomeAssistantThingHandlerTests extends AbstractHomeAssistantTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDuplicateChannelIdNewStyleChannelsComplex() {
|
public void testDuplicateChannelIdComplex() {
|
||||||
haThing.setProperty("newStyleChannels", "true");
|
|
||||||
thingHandler = new HomeAssistantThingHandler(haThing, channelTypeProvider, stateDescriptionProvider,
|
thingHandler = new HomeAssistantThingHandler(haThing, channelTypeProvider, stateDescriptionProvider,
|
||||||
channelTypeRegistry, new Jinjava(), unitProvider, SUBSCRIBE_TIMEOUT, ATTRIBUTE_RECEIVE_TIMEOUT);
|
channelTypeRegistry, new Jinjava(), unitProvider, SUBSCRIBE_TIMEOUT, ATTRIBUTE_RECEIVE_TIMEOUT);
|
||||||
thingHandler.setConnection(bridgeConnection);
|
thingHandler.setConnection(bridgeConnection);
|
||||||
|
@ -85,7 +85,7 @@ public class DiscoverComponentsTest extends JavaOSGiTest {
|
|||||||
UnitProvider unitProvider = mock(UnitProvider.class);
|
UnitProvider unitProvider = mock(UnitProvider.class);
|
||||||
|
|
||||||
DiscoverComponents discover = spy(new DiscoverComponents(ThingChannelConstants.TEST_HOME_ASSISTANT_THING,
|
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"));
|
HandlerConfiguration config = new HandlerConfiguration("homeassistant", List.of("switch/object"));
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ public class HomeAssistantMQTTImplementationTest extends MqttOSGiTest {
|
|||||||
|
|
||||||
ScheduledExecutorService scheduler = new ScheduledThreadPoolExecutor(4);
|
ScheduledExecutorService scheduler = new ScheduledThreadPoolExecutor(4);
|
||||||
DiscoverComponents discover = spy(new DiscoverComponents(ThingChannelConstants.TEST_HOME_ASSISTANT_THING,
|
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.
|
// The DiscoverComponents object calls ComponentDiscovered callbacks.
|
||||||
// In the following implementation we add the found component to the `haComponents` map
|
// In the following implementation we add the found component to the `haComponents` map
|
||||||
|
Loading…
Reference in New Issue
Block a user