From b217ed3df437c61e4e3852fd31d6be0515c0b311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Thu, 26 Dec 2019 15:16:29 +0100 Subject: [PATCH] implement support for thing actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So far only transition time for color channels is supported Signed-off-by: Thomas Weißschuh --- .../zigbee/ZigBeeCommandParameter.java | 9 +++ .../zigbee/ZigBeeCommandParameters.java | 22 ++++++ .../binding/zigbee/ZigBeeThingActions.java | 48 ++++++++++++ .../converter/ZigBeeBaseChannelConverter.java | 4 +- .../zigbee/handler/ZigBeeThingHandler.java | 21 +++++- .../internal/ZigBeeCommandParameterImpl.java | 31 ++++++++ .../internal/ZigBeeCommandParametersImpl.java | 73 +++++++++++++++++++ .../converter/ZigBeeConverterColorColor.java | 34 +++++---- .../ZigBeeConverterColorTemperature.java | 29 ++++---- .../converter/ZigBeeConverterDoorLock.java | 20 ++--- .../converter/ZigBeeConverterFanControl.java | 4 +- .../converter/ZigBeeConverterSwitchLevel.java | 3 +- .../converter/ZigBeeConverterSwitchOnoff.java | 3 +- ...BeeConverterThermostatOccupiedCooling.java | 18 ++--- ...BeeConverterThermostatOccupiedHeating.java | 18 ++--- .../ZigBeeConverterThermostatSystemMode.java | 3 +- ...eConverterThermostatUnoccupiedCooling.java | 18 ++--- ...eConverterThermostatUnoccupiedHeating.java | 18 ++--- .../ZigBeeConverterWarningDevice.java | 3 +- .../ZigBeeConverterWarningDeviceTest.java | 10 ++- 20 files changed, 302 insertions(+), 87 deletions(-) create mode 100644 org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeCommandParameter.java create mode 100644 org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeCommandParameters.java create mode 100644 org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeThingActions.java create mode 100644 org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/ZigBeeCommandParameterImpl.java create mode 100644 org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/ZigBeeCommandParametersImpl.java diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeCommandParameter.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeCommandParameter.java new file mode 100644 index 000000000..7fc18c5a7 --- /dev/null +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeCommandParameter.java @@ -0,0 +1,9 @@ +package org.openhab.binding.zigbee; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +@NonNullByDefault +public interface ZigBeeCommandParameter { + String getName(); + Class getType(); +} diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeCommandParameters.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeCommandParameters.java new file mode 100644 index 000000000..551302755 --- /dev/null +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeCommandParameters.java @@ -0,0 +1,22 @@ +package org.openhab.binding.zigbee; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.zigbee.internal.ZigBeeCommandParameterImpl; +import org.openhab.binding.zigbee.internal.ZigBeeCommandParametersImpl; + +import java.util.Collection; +import java.util.Optional; + +@NonNullByDefault +public interface ZigBeeCommandParameters { + static ZigBeeCommandParameters empty() { + return new ZigBeeCommandParametersImpl(); + } + + ZigBeeCommandParameters add(final ZigBeeCommandParameter param, final T value); + Optional get(final ZigBeeCommandParameter param); + Collection> setParameters(); + + ZigBeeCommandParameter TRANSITION_TIME = + new ZigBeeCommandParameterImpl<>(Integer.class, "transitionTime"); +} diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeThingActions.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeThingActions.java new file mode 100644 index 000000000..5c03ea2db --- /dev/null +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeThingActions.java @@ -0,0 +1,48 @@ +package org.openhab.binding.zigbee; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.smarthome.core.thing.ChannelUID; +import org.eclipse.smarthome.core.thing.binding.ThingActions; +import org.eclipse.smarthome.core.thing.binding.ThingActionsScope; +import org.eclipse.smarthome.core.thing.binding.ThingHandler; +import org.eclipse.smarthome.core.types.Command; +import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; +import org.openhab.core.automation.annotation.ActionInput; +import org.openhab.core.automation.annotation.RuleAction; + +import static org.eclipse.jdt.annotation.Checks.requireNonNull; + +@SuppressWarnings("unused") +@ThingActionsScope(name="zigbee") +@NonNullByDefault +public final class ZigBeeThingActions implements ThingActions { + private @Nullable ZigBeeThingHandler handler; + + @Override + public void setThingHandler(@Nullable final ThingHandler handler) { + this.handler = (ZigBeeThingHandler) handler; + } + + @Override + public @Nullable ThingHandler getThingHandler() { + return handler; + } + + @RuleAction(label = "sendCommand") + public void sendCommand( + @ActionInput(name = "channelId", required = true) final String channelId, + @ActionInput(name = "command", required = true) final Command command, + @ActionInput(name = "params") @Nullable final ZigBeeCommandParameters params + ) { + handleCommand(getChannel(channelId), command, params != null ? params : ZigBeeCommandParameters.empty()); + } + + private void handleCommand(final ChannelUID channel, final Command command, final ZigBeeCommandParameters params) { + requireNonNull(handler).handleCommand(channel, command, params); + } + + private ChannelUID getChannel(final String channelId) { + return new ChannelUID(requireNonNull(handler).getThing().getUID(), channelId); + } +} diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/converter/ZigBeeBaseChannelConverter.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/converter/ZigBeeBaseChannelConverter.java index aa8b62cfa..26e66c2ae 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/converter/ZigBeeBaseChannelConverter.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/converter/ZigBeeBaseChannelConverter.java @@ -14,6 +14,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -34,6 +35,7 @@ import org.eclipse.smarthome.core.types.State; import org.eclipse.smarthome.core.types.StateDescription; import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.ZigBeeCommandParameters; import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler; import org.openhab.binding.zigbee.handler.ZigBeeThingHandler; import org.slf4j.Logger; @@ -251,7 +253,7 @@ public void handleRefresh() { * * @param command the {@link Command} to send */ - public void handleCommand(final Command command) { + public void handleCommand(final Command command, final ZigBeeCommandParameters params) { // Overridable if a channel can be commanded } diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeThingHandler.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeThingHandler.java index bf7768c59..9f8ed2961 100755 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeThingHandler.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeThingHandler.java @@ -48,6 +48,7 @@ import org.eclipse.smarthome.core.thing.ThingStatusDetail; import org.eclipse.smarthome.core.thing.ThingStatusInfo; import org.eclipse.smarthome.core.thing.binding.BaseThingHandler; +import org.eclipse.smarthome.core.thing.binding.ThingHandlerService; import org.eclipse.smarthome.core.thing.binding.builder.ThingBuilder; import org.eclipse.smarthome.core.thing.binding.firmware.Firmware; import org.eclipse.smarthome.core.thing.binding.firmware.FirmwareUpdateHandler; @@ -59,11 +60,15 @@ import org.eclipse.smarthome.core.types.State; import org.eclipse.smarthome.core.types.StateDescription; import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.ZigBeeCommandParameter; +import org.openhab.binding.zigbee.ZigBeeCommandParameters; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; import org.openhab.binding.zigbee.converter.ZigBeeChannelConverterFactory; import org.openhab.binding.zigbee.discovery.ZigBeeNodePropertyDiscoverer; +import org.openhab.binding.zigbee.internal.ZigBeeCommandParametersImpl; import org.openhab.binding.zigbee.internal.ZigBeeConfigDescriptionParameters; import org.openhab.binding.zigbee.internal.ZigBeeDeviceConfigHandler; +import org.openhab.binding.zigbee.ZigBeeThingActions; import org.openhab.binding.zigbee.internal.converter.config.ZclClusterConfigFactory; import org.openhab.binding.zigbee.internal.converter.config.ZclClusterConfigHandler; import org.openhab.binding.zigbee.internal.converter.config.ZclReportingConfig; @@ -694,6 +699,10 @@ public void handleConfigurationUpdate(Map configurationParameter @Override public void handleCommand(final ChannelUID channelUID, final Command command) { + handleCommand(channelUID, command, ZigBeeCommandParameters.empty()); + } + + public void handleCommand(final ChannelUID channelUID, final Command command, final ZigBeeCommandParameters params) { logger.debug("{}: Command for channel {} --> {} [{}]", nodeIeeeAddress, channelUID, command, command.getClass().getSimpleName()); @@ -718,7 +727,12 @@ public void run() { if (command == RefreshType.REFRESH) { handler.handleRefresh(); } else { - handler.handleCommand(command); + ZigBeeCommandParametersImpl.UsageTracker parameterTracker = new ZigBeeCommandParametersImpl.UsageTracker(params); + handler.handleCommand(command, parameterTracker); + Set> unusedParams = parameterTracker.unusedParams(); + if (!unusedParams.isEmpty() && logger.isWarnEnabled()) { + logger.warn("Handler {} did not use given parameters {}", handler, unusedParams); + } } } catch (Exception e) { logger.debug("{}: Exception sending command to channel {}", nodeIeeeAddress, channelUID, e); @@ -1006,4 +1020,9 @@ public boolean isUpdateExecutable() { // Always allow the firmware to be updated return true; } + + @Override + public Collection> getServices() { + return Collections.singleton(ZigBeeThingActions.class); + } } diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/ZigBeeCommandParameterImpl.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/ZigBeeCommandParameterImpl.java new file mode 100644 index 000000000..e069326b2 --- /dev/null +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/ZigBeeCommandParameterImpl.java @@ -0,0 +1,31 @@ +package org.openhab.binding.zigbee.internal; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.zigbee.ZigBeeCommandParameter; + +@NonNullByDefault +public final class ZigBeeCommandParameterImpl implements ZigBeeCommandParameter { + + private final String name; + private final Class klazz; + + public ZigBeeCommandParameterImpl(final Class klazz, final String name) { + this.klazz = klazz; + this.name = name; + } + + @Override + public String getName() { + return name; + } + + @Override + public Class getType() { + return klazz; + } + + @Override + public String toString() { + return name; + } +} diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/ZigBeeCommandParametersImpl.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/ZigBeeCommandParametersImpl.java new file mode 100644 index 000000000..e1e1adf50 --- /dev/null +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/ZigBeeCommandParametersImpl.java @@ -0,0 +1,73 @@ +package org.openhab.binding.zigbee.internal; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.zigbee.ZigBeeCommandParameter; +import org.openhab.binding.zigbee.ZigBeeCommandParameters; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.*; + +@NonNullByDefault +public class ZigBeeCommandParametersImpl implements ZigBeeCommandParameters { + private static final Logger logger = LoggerFactory.getLogger(ZigBeeCommandParametersImpl.class); + + private final Map, Object> params = new HashMap<>(); + + @Override + public ZigBeeCommandParameters add(final ZigBeeCommandParameter param, final T value) { + params.put(param, value); + return this; + } + + @Override + public Optional get(final ZigBeeCommandParameter param) { + Object v = params.get(param); + if (v == null) { + return Optional.empty(); + } else if (!param.getType().isInstance(param)) { + logger.debug("Can not retrieve param {}: object of type {} ({}) can not be casted to {}", + param.getName(), param.getClass(), param, param.getType().getName() + ); + return Optional.empty(); + } else { + return Optional.of(param.getType().cast(param)); + } + } + + @Override + public Collection> setParameters() { + return Collections.unmodifiableSet(params.keySet()); + } + + public static class UsageTracker implements ZigBeeCommandParameters { + private final Set> usedParams = new HashSet<>(); + private final ZigBeeCommandParameters delegate; + + public UsageTracker(ZigBeeCommandParameters delegate) { + this.delegate = delegate; + } + + public Set> unusedParams() { + Set> unusedParams = new HashSet<>(setParameters()); + unusedParams.removeAll(usedParams); + return Collections.unmodifiableSet(unusedParams); + } + + @Override + public ZigBeeCommandParameters add(ZigBeeCommandParameter param, T value) { + return delegate.add(param, value); + } + + @Override + public Optional get(ZigBeeCommandParameter param) { + usedParams.add(param); + return delegate.get(param); + } + + @Override + public Collection> setParameters() { + return delegate.setParameters(); + } + } +} diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorColor.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorColor.java index d5617621c..3d06ffcbd 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorColor.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorColor.java @@ -34,6 +34,7 @@ import org.eclipse.smarthome.core.types.Command; import org.eclipse.smarthome.core.types.UnDefType; import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.ZigBeeCommandParameters; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; import org.openhab.binding.zigbee.internal.converter.config.ZclLevelControlConfig; import org.slf4j.Logger; @@ -274,14 +275,14 @@ public void handleRefresh() { clusterColorControl.getColorMode(0); } - private void changeOnOff(OnOffType onoff) throws InterruptedException, ExecutionException { + private void changeOnOff(OnOffType onoff, int transitionTime) throws InterruptedException, ExecutionException { boolean on = onoff == OnOffType.ON; if (clusterOnOff == null) { if (clusterLevelControl == null) { logger.warn("{}: ignoring on/off command", endpoint.getIeeeAddress()); } else { - changeBrightness(on ? PercentType.HUNDRED : PercentType.ZERO); + changeBrightness(on ? PercentType.HUNDRED : PercentType.ZERO, transitionTime); } return; } @@ -293,12 +294,12 @@ private void changeOnOff(OnOffType onoff) throws InterruptedException, Execution } } - private void changeBrightness(PercentType brightness) throws InterruptedException, ExecutionException { + private void changeBrightness(PercentType brightness, int transitionTime) throws InterruptedException, ExecutionException { if (clusterLevelControl == null) { if (clusterOnOff == null) { logger.warn("{}: ignoring brightness command", endpoint.getIeeeAddress()); } else { - changeOnOff(brightness.intValue() == 0 ? OnOffType.OFF : OnOffType.ON); + changeOnOff(brightness.intValue() == 0 ? OnOffType.OFF : OnOffType.ON, transitionTime); } return; } @@ -309,23 +310,23 @@ private void changeBrightness(PercentType brightness) throws InterruptedExceptio if (brightness.equals(PercentType.ZERO)) { clusterOnOff.offCommand(); } else { - clusterLevelControl.moveToLevelWithOnOffCommand(level, configLevelControl.getDefaultTransitionTime()) + clusterLevelControl.moveToLevelWithOnOffCommand(level, transitionTime) .get(); } } else { - clusterLevelControl.moveToLevelCommand(level, configLevelControl.getDefaultTransitionTime()).get(); + clusterLevelControl.moveToLevelCommand(level, transitionTime).get(); } } - private void changeColorHueSaturation(HSBType color) throws InterruptedException, ExecutionException { + private void changeColorHueSaturation(HSBType color, int transitionTime) throws InterruptedException, ExecutionException { int hue = (int) (color.getHue().floatValue() * 254.0f / 360.0f + 0.5f); int saturation = percentToLevel(color.getSaturation()); clusterColorControl - .moveToHueAndSaturationCommand(hue, saturation, configLevelControl.getDefaultTransitionTime()).get(); + .moveToHueAndSaturationCommand(hue, saturation, transitionTime).get(); } - private void changeColorXY(HSBType color) throws InterruptedException, ExecutionException { + private void changeColorXY(HSBType color, int transitionTime) throws InterruptedException, ExecutionException { PercentType xy[] = color.toXY(); logger.debug("{}: Change Color HSV ({}, {}, {}) -> XY ({}, {})", endpoint.getIeeeAddress(), color.getHue(), @@ -333,31 +334,32 @@ private void changeColorXY(HSBType color) throws InterruptedException, Execution int x = (int) (xy[0].floatValue() / 100.0f * 65536.0f + 0.5f); // up to 65279 int y = (int) (xy[1].floatValue() / 100.0f * 65536.0f + 0.5f); // up to 65279 - clusterColorControl.moveToColorCommand(x, y, configLevelControl.getDefaultTransitionTime()).get(); + clusterColorControl.moveToColorCommand(x, y, transitionTime).get(); } @Override - public void handleCommand(final Command command) { + public void handleCommand(final Command command, final ZigBeeCommandParameters params) { + int transitionTime = params.get(ZigBeeCommandParameters.TRANSITION_TIME).orElseGet(configLevelControl::getDefaultTransitionTime); try { if (command instanceof HSBType) { HSBType color = (HSBType) command; PercentType brightness = color.getBrightness(); - changeBrightness(brightness); + changeBrightness(brightness, transitionTime); if (delayedColorChange && brightness.intValue() != lastHSB.getBrightness().intValue()) { Thread.sleep(1100); } if (supportsHue) { - changeColorHueSaturation(color); + changeColorHueSaturation(color, transitionTime); } else { - changeColorXY(color); + changeColorXY(color, transitionTime); } } else if (command instanceof PercentType) { - changeBrightness((PercentType) command); + changeBrightness((PercentType) command, transitionTime); } else if (command instanceof OnOffType) { - changeOnOff((OnOffType) command); + changeOnOff((OnOffType) command, transitionTime); } } catch (InterruptedException | ExecutionException e) { logger.warn("{}: Exception processing command", endpoint.getIeeeAddress(), e); diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperature.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperature.java index 91078ab69..1b874e1b1 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperature.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterColorTemperature.java @@ -12,10 +12,14 @@ */ package org.openhab.binding.zigbee.internal.converter; -import static com.zsmartsystems.zigbee.zcl.clusters.ZclColorControlCluster.ATTR_COLORTEMPERATURE; - -import java.util.concurrent.ExecutionException; - +import com.zsmartsystems.zigbee.CommandResult; +import com.zsmartsystems.zigbee.ZigBeeEndpoint; +import com.zsmartsystems.zigbee.zcl.ZclAttribute; +import com.zsmartsystems.zigbee.zcl.ZclAttributeListener; +import com.zsmartsystems.zigbee.zcl.clusters.ZclColorControlCluster; +import com.zsmartsystems.zigbee.zcl.clusters.colorcontrol.ColorCapabilitiesEnum; +import com.zsmartsystems.zigbee.zcl.clusters.colorcontrol.ColorModeEnum; +import com.zsmartsystems.zigbee.zcl.protocol.ZclClusterType; import org.eclipse.smarthome.core.library.types.OnOffType; import org.eclipse.smarthome.core.library.types.PercentType; import org.eclipse.smarthome.core.thing.Channel; @@ -24,18 +28,14 @@ import org.eclipse.smarthome.core.types.Command; import org.eclipse.smarthome.core.types.UnDefType; import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.ZigBeeCommandParameters; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.zsmartsystems.zigbee.CommandResult; -import com.zsmartsystems.zigbee.ZigBeeEndpoint; -import com.zsmartsystems.zigbee.zcl.ZclAttribute; -import com.zsmartsystems.zigbee.zcl.ZclAttributeListener; -import com.zsmartsystems.zigbee.zcl.clusters.ZclColorControlCluster; -import com.zsmartsystems.zigbee.zcl.clusters.colorcontrol.ColorCapabilitiesEnum; -import com.zsmartsystems.zigbee.zcl.clusters.colorcontrol.ColorModeEnum; -import com.zsmartsystems.zigbee.zcl.protocol.ZclClusterType; +import java.util.concurrent.ExecutionException; + +import static com.zsmartsystems.zigbee.zcl.clusters.ZclColorControlCluster.ATTR_COLORTEMPERATURE; /** * Channel converter for color temperature, converting between the color control cluster and a percent-typed channel. @@ -119,7 +119,8 @@ public void handleRefresh() { } @Override - public void handleCommand(final Command command) { + public void handleCommand(final Command command, final ZigBeeCommandParameters params) { + int transitionTime = params.get(ZigBeeCommandParameters.TRANSITION_TIME).orElse(10); PercentType colorTemperaturePercentage = PercentType.ZERO; if (command instanceof PercentType) { colorTemperaturePercentage = (PercentType) command; @@ -128,7 +129,7 @@ public void handleCommand(final Command command) { return; } - clusterColorControl.moveToColorTemperatureCommand(percentToMired(colorTemperaturePercentage), 10); + clusterColorControl.moveToColorTemperatureCommand(percentToMired(colorTemperaturePercentage), transitionTime); } @Override diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterDoorLock.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterDoorLock.java index 5d0d5f0b0..55547f08a 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterDoorLock.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterDoorLock.java @@ -12,25 +12,25 @@ */ package org.openhab.binding.zigbee.internal.converter; -import java.util.concurrent.ExecutionException; - +import com.zsmartsystems.zigbee.CommandResult; +import com.zsmartsystems.zigbee.ZigBeeEndpoint; +import com.zsmartsystems.zigbee.zcl.ZclAttribute; +import com.zsmartsystems.zigbee.zcl.ZclAttributeListener; +import com.zsmartsystems.zigbee.zcl.clusters.ZclDoorLockCluster; +import com.zsmartsystems.zigbee.zcl.field.ByteArray; +import com.zsmartsystems.zigbee.zcl.protocol.ZclClusterType; import org.eclipse.smarthome.core.library.types.OnOffType; import org.eclipse.smarthome.core.thing.Channel; import org.eclipse.smarthome.core.thing.ThingUID; import org.eclipse.smarthome.core.thing.binding.builder.ChannelBuilder; import org.eclipse.smarthome.core.types.Command; import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.ZigBeeCommandParameters; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.zsmartsystems.zigbee.CommandResult; -import com.zsmartsystems.zigbee.ZigBeeEndpoint; -import com.zsmartsystems.zigbee.zcl.ZclAttribute; -import com.zsmartsystems.zigbee.zcl.ZclAttributeListener; -import com.zsmartsystems.zigbee.zcl.clusters.ZclDoorLockCluster; -import com.zsmartsystems.zigbee.zcl.field.ByteArray; -import com.zsmartsystems.zigbee.zcl.protocol.ZclClusterType; +import java.util.concurrent.ExecutionException; /** * This channel supports changes through attribute updates to the door lock state. ON=Locked, OFF=Unlocked. @@ -95,7 +95,7 @@ public void handleRefresh() { } @Override - public void handleCommand(final Command command) { + public void handleCommand(final Command command, final ZigBeeCommandParameters params) { if (command == OnOffType.ON) { cluster.lockDoorCommand(new ByteArray(new byte[0])); } else { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterFanControl.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterFanControl.java index 715f1708a..c25c9a7c0 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterFanControl.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterFanControl.java @@ -12,6 +12,7 @@ */ package org.openhab.binding.zigbee.internal.converter; +import java.util.Map; import java.util.concurrent.ExecutionException; import org.eclipse.smarthome.core.library.types.DecimalType; @@ -21,6 +22,7 @@ import org.eclipse.smarthome.core.thing.binding.builder.ChannelBuilder; import org.eclipse.smarthome.core.types.Command; import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.ZigBeeCommandParameters; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -106,7 +108,7 @@ public void handleRefresh() { } @Override - public void handleCommand(final Command command) { + public void handleCommand(final Command command, final ZigBeeCommandParameters params) { int value; if (command instanceof OnOffType) { value = command == OnOffType.ON ? MODE_ON : MODE_OFF; diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchLevel.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchLevel.java index 112ba3df1..bb9c243a0 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchLevel.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchLevel.java @@ -31,6 +31,7 @@ import org.eclipse.smarthome.core.thing.binding.builder.ChannelBuilder; import org.eclipse.smarthome.core.types.Command; import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.ZigBeeCommandParameters; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; import org.openhab.binding.zigbee.internal.converter.config.ZclLevelControlConfig; import org.openhab.binding.zigbee.internal.converter.config.ZclReportingConfig; @@ -331,7 +332,7 @@ public void handleRefresh() { } @Override - public void handleCommand(final Command command) { + public void handleCommand(final Command command, final ZigBeeCommandParameters params) { if (command instanceof OnOffType) { handleOnOffCommand((OnOffType) command); } else if (command instanceof PercentType) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchOnoff.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchOnoff.java index abd6bdbe9..1eb4cc932 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchOnoff.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterSwitchOnoff.java @@ -30,6 +30,7 @@ import org.eclipse.smarthome.core.thing.binding.builder.ChannelBuilder; import org.eclipse.smarthome.core.types.Command; import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.ZigBeeCommandParameters; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; import org.openhab.binding.zigbee.internal.converter.config.ZclOnOffSwitchConfig; import org.openhab.binding.zigbee.internal.converter.config.ZclReportingConfig; @@ -194,7 +195,7 @@ public void handleRefresh() { } @Override - public void handleCommand(final Command command) { + public void handleCommand(final Command command, final ZigBeeCommandParameters params) { if (clusterOnOffServer == null) { logger.warn("{}: OnOff converter is not linked to a server and cannot accept commands", endpoint.getIeeeAddress()); diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatOccupiedCooling.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatOccupiedCooling.java index 3e0c37e45..002db7228 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatOccupiedCooling.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatOccupiedCooling.java @@ -12,23 +12,23 @@ */ package org.openhab.binding.zigbee.internal.converter; -import java.util.concurrent.ExecutionException; - +import com.zsmartsystems.zigbee.CommandResult; +import com.zsmartsystems.zigbee.ZigBeeEndpoint; +import com.zsmartsystems.zigbee.zcl.ZclAttribute; +import com.zsmartsystems.zigbee.zcl.ZclAttributeListener; +import com.zsmartsystems.zigbee.zcl.clusters.ZclThermostatCluster; +import com.zsmartsystems.zigbee.zcl.protocol.ZclClusterType; import org.eclipse.smarthome.core.thing.Channel; import org.eclipse.smarthome.core.thing.ThingUID; import org.eclipse.smarthome.core.thing.binding.builder.ChannelBuilder; import org.eclipse.smarthome.core.types.Command; import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.ZigBeeCommandParameters; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.zsmartsystems.zigbee.CommandResult; -import com.zsmartsystems.zigbee.ZigBeeEndpoint; -import com.zsmartsystems.zigbee.zcl.ZclAttribute; -import com.zsmartsystems.zigbee.zcl.ZclAttributeListener; -import com.zsmartsystems.zigbee.zcl.clusters.ZclThermostatCluster; -import com.zsmartsystems.zigbee.zcl.protocol.ZclClusterType; +import java.util.concurrent.ExecutionException; /** * Converter for the thermostat occupied cooling setpoint channel. This specifies the cooling mode setpoint when the @@ -99,7 +99,7 @@ public void disposeConverter() { } @Override - public void handleCommand(final Command command) { + public void handleCommand(final Command command, ZigBeeCommandParameters params) { Integer value = temperatureToValue(command); if (value == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatOccupiedHeating.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatOccupiedHeating.java index ef860f0ee..25ca4ec2c 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatOccupiedHeating.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatOccupiedHeating.java @@ -12,23 +12,23 @@ */ package org.openhab.binding.zigbee.internal.converter; -import java.util.concurrent.ExecutionException; - +import com.zsmartsystems.zigbee.CommandResult; +import com.zsmartsystems.zigbee.ZigBeeEndpoint; +import com.zsmartsystems.zigbee.zcl.ZclAttribute; +import com.zsmartsystems.zigbee.zcl.ZclAttributeListener; +import com.zsmartsystems.zigbee.zcl.clusters.ZclThermostatCluster; +import com.zsmartsystems.zigbee.zcl.protocol.ZclClusterType; import org.eclipse.smarthome.core.thing.Channel; import org.eclipse.smarthome.core.thing.ThingUID; import org.eclipse.smarthome.core.thing.binding.builder.ChannelBuilder; import org.eclipse.smarthome.core.types.Command; import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.ZigBeeCommandParameters; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.zsmartsystems.zigbee.CommandResult; -import com.zsmartsystems.zigbee.ZigBeeEndpoint; -import com.zsmartsystems.zigbee.zcl.ZclAttribute; -import com.zsmartsystems.zigbee.zcl.ZclAttributeListener; -import com.zsmartsystems.zigbee.zcl.clusters.ZclThermostatCluster; -import com.zsmartsystems.zigbee.zcl.protocol.ZclClusterType; +import java.util.concurrent.ExecutionException; /** * Converter for the thermostat occupied heating setpoint channel @@ -95,7 +95,7 @@ public void disposeConverter() { } @Override - public void handleCommand(final Command command) { + public void handleCommand(final Command command, final ZigBeeCommandParameters params) { Integer value = temperatureToValue(command); if (value == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatSystemMode.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatSystemMode.java index 84ead8e99..c1e18d2eb 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatSystemMode.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatSystemMode.java @@ -26,6 +26,7 @@ import org.eclipse.smarthome.core.types.StateDescription; import org.eclipse.smarthome.core.types.StateOption; import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.ZigBeeCommandParameters; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -107,7 +108,7 @@ public void disposeConverter() { } @Override - public void handleCommand(final Command command) { + public void handleCommand(final Command command, final ZigBeeCommandParameters params) { Integer value = null; if (command instanceof OnOffType) { // OnOff switches between OFF=OFF and ON=AUTO diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatUnoccupiedCooling.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatUnoccupiedCooling.java index daecda6b9..d76118cbe 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatUnoccupiedCooling.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatUnoccupiedCooling.java @@ -12,23 +12,23 @@ */ package org.openhab.binding.zigbee.internal.converter; -import java.util.concurrent.ExecutionException; - +import com.zsmartsystems.zigbee.CommandResult; +import com.zsmartsystems.zigbee.ZigBeeEndpoint; +import com.zsmartsystems.zigbee.zcl.ZclAttribute; +import com.zsmartsystems.zigbee.zcl.ZclAttributeListener; +import com.zsmartsystems.zigbee.zcl.clusters.ZclThermostatCluster; +import com.zsmartsystems.zigbee.zcl.protocol.ZclClusterType; import org.eclipse.smarthome.core.thing.Channel; import org.eclipse.smarthome.core.thing.ThingUID; import org.eclipse.smarthome.core.thing.binding.builder.ChannelBuilder; import org.eclipse.smarthome.core.types.Command; import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.ZigBeeCommandParameters; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.zsmartsystems.zigbee.CommandResult; -import com.zsmartsystems.zigbee.ZigBeeEndpoint; -import com.zsmartsystems.zigbee.zcl.ZclAttribute; -import com.zsmartsystems.zigbee.zcl.ZclAttributeListener; -import com.zsmartsystems.zigbee.zcl.clusters.ZclThermostatCluster; -import com.zsmartsystems.zigbee.zcl.protocol.ZclClusterType; +import java.util.concurrent.ExecutionException; /** * Converter for the thermostat unoccupied cooling setpoint channel @@ -96,7 +96,7 @@ public void disposeConverter() { } @Override - public void handleCommand(final Command command) { + public void handleCommand(final Command command, final ZigBeeCommandParameters params) { Integer value = temperatureToValue(command); if (value == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatUnoccupiedHeating.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatUnoccupiedHeating.java index c86534a5e..d1d6f46b9 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatUnoccupiedHeating.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/ZigBeeConverterThermostatUnoccupiedHeating.java @@ -12,23 +12,23 @@ */ package org.openhab.binding.zigbee.internal.converter; -import java.util.concurrent.ExecutionException; - +import com.zsmartsystems.zigbee.CommandResult; +import com.zsmartsystems.zigbee.ZigBeeEndpoint; +import com.zsmartsystems.zigbee.zcl.ZclAttribute; +import com.zsmartsystems.zigbee.zcl.ZclAttributeListener; +import com.zsmartsystems.zigbee.zcl.clusters.ZclThermostatCluster; +import com.zsmartsystems.zigbee.zcl.protocol.ZclClusterType; import org.eclipse.smarthome.core.thing.Channel; import org.eclipse.smarthome.core.thing.ThingUID; import org.eclipse.smarthome.core.thing.binding.builder.ChannelBuilder; import org.eclipse.smarthome.core.types.Command; import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.ZigBeeCommandParameters; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.zsmartsystems.zigbee.CommandResult; -import com.zsmartsystems.zigbee.ZigBeeEndpoint; -import com.zsmartsystems.zigbee.zcl.ZclAttribute; -import com.zsmartsystems.zigbee.zcl.ZclAttributeListener; -import com.zsmartsystems.zigbee.zcl.clusters.ZclThermostatCluster; -import com.zsmartsystems.zigbee.zcl.protocol.ZclClusterType; +import java.util.concurrent.ExecutionException; /** * Converter for the thermostat unoccupied heating setpoint channel @@ -98,7 +98,7 @@ public void disposeConverter() { } @Override - public void handleCommand(final Command command) { + public void handleCommand(final Command command, final ZigBeeCommandParameters params) { Integer value = temperatureToValue(command); if (value == null) { diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/warningdevice/ZigBeeConverterWarningDevice.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/warningdevice/ZigBeeConverterWarningDevice.java index 79d76054e..ab57b24d4 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/warningdevice/ZigBeeConverterWarningDevice.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/internal/converter/warningdevice/ZigBeeConverterWarningDevice.java @@ -26,6 +26,7 @@ import org.eclipse.smarthome.core.thing.binding.builder.ChannelBuilder; import org.eclipse.smarthome.core.types.Command; import org.openhab.binding.zigbee.ZigBeeBindingConstants; +import org.openhab.binding.zigbee.ZigBeeCommandParameters; import org.openhab.binding.zigbee.converter.ZigBeeBaseChannelConverter; import org.openhab.binding.zigbee.converter.warningdevice.SquawkType; import org.openhab.binding.zigbee.converter.warningdevice.WarningType; @@ -113,7 +114,7 @@ private void updateConfigParameter(Configuration currentConfiguration, Entry