]> git.basschouten.com Git - openhab-addons.git/commitdiff
Added support for publishing ChannelDescriptionChangedEvents (#10900)
authorChristoph Weitkamp <github@christophweitkamp.de>
Wed, 23 Jun 2021 20:14:49 +0000 (22:14 +0200)
committerGitHub <noreply@github.com>
Wed, 23 Jun 2021 20:14:49 +0000 (22:14 +0200)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/CommandDescriptionProvider.java [deleted file]
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/DeconzDynamicCommandDescriptionProvider.java [new file with mode: 0644]
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/DeconzDynamicStateDescriptionProvider.java [new file with mode: 0644]
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/DeconzHandlerFactory.java
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/StateDescriptionProvider.java [deleted file]
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/dto/Scene.java
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/GroupThingHandler.java
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java
bundles/org.openhab.binding.deconz/src/test/java/org/openhab/binding/deconz/LightsTest.java

diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/CommandDescriptionProvider.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/CommandDescriptionProvider.java
deleted file mode 100644 (file)
index 143d827..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * Copyright (c) 2010-2021 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.deconz.internal;
-
-import java.util.Locale;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.eclipse.jdt.annotation.Nullable;
-import org.openhab.core.thing.Channel;
-import org.openhab.core.thing.ChannelUID;
-import org.openhab.core.thing.ThingUID;
-import org.openhab.core.thing.type.DynamicCommandDescriptionProvider;
-import org.openhab.core.types.CommandDescription;
-import org.osgi.service.component.annotations.Component;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Dynamic channel command description provider.
- * Overrides the command description for the controls, which receive its configuration in the runtime.
- *
- * @author Jan N. Klug - Initial contribution
- */
-@NonNullByDefault
-@Component(service = { DynamicCommandDescriptionProvider.class, CommandDescriptionProvider.class })
-public class CommandDescriptionProvider implements DynamicCommandDescriptionProvider {
-
-    private final Map<ChannelUID, CommandDescription> descriptions = new ConcurrentHashMap<>();
-    private final Logger logger = LoggerFactory.getLogger(CommandDescriptionProvider.class);
-
-    /**
-     * Set a command description for a channel. This description will be used when preparing the channel command by
-     * the framework for presentation. A previous description, if existed, will be replaced.
-     *
-     * @param channelUID
-     *            channel UID
-     * @param description
-     *            state description for the channel
-     */
-    public void setDescription(ChannelUID channelUID, CommandDescription description) {
-        logger.trace("adding command description for channel {}", channelUID);
-        descriptions.put(channelUID, description);
-    }
-
-    /**
-     * remove all descriptions for a given thing
-     *
-     * @param thingUID the thing's UID
-     */
-    public void removeDescriptionsForThing(ThingUID thingUID) {
-        logger.trace("removing state description for thing {}", thingUID);
-        descriptions.entrySet().removeIf(entry -> entry.getKey().getThingUID().equals(thingUID));
-    }
-
-    @Override
-    public @Nullable CommandDescription getCommandDescription(Channel channel,
-            @Nullable CommandDescription originalStateDescription, @Nullable Locale locale) {
-        if (descriptions.containsKey(channel.getUID())) {
-            logger.trace("returning new stateDescription for {}", channel.getUID());
-            return descriptions.get(channel.getUID());
-        } else {
-            return null;
-        }
-    }
-}
diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/DeconzDynamicCommandDescriptionProvider.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/DeconzDynamicCommandDescriptionProvider.java
new file mode 100644 (file)
index 0000000..5f33194
--- /dev/null
@@ -0,0 +1,43 @@
+/**
+ * Copyright (c) 2010-2021 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.deconz.internal;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.core.thing.ThingUID;
+import org.openhab.core.thing.binding.BaseDynamicCommandDescriptionProvider;
+import org.openhab.core.thing.type.DynamicCommandDescriptionProvider;
+import org.osgi.service.component.annotations.Component;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Dynamic channel command description provider.
+ * Overrides the command description for the controls, which receive its configuration in the runtime.
+ *
+ * @author Jan N. Klug - Initial contribution
+ */
+@NonNullByDefault
+@Component(service = { DynamicCommandDescriptionProvider.class, DeconzDynamicCommandDescriptionProvider.class })
+public class DeconzDynamicCommandDescriptionProvider extends BaseDynamicCommandDescriptionProvider {
+    private final Logger logger = LoggerFactory.getLogger(DeconzDynamicCommandDescriptionProvider.class);
+
+    /**
+     * remove all descriptions for a given thing
+     *
+     * @param thingUID the thing's UID
+     */
+    public void removeDescriptionsForThing(ThingUID thingUID) {
+        logger.trace("removing state description for thing {}", thingUID);
+        channelOptionsMap.entrySet().removeIf(entry -> entry.getKey().getThingUID().equals(thingUID));
+    }
+}
diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/DeconzDynamicStateDescriptionProvider.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/DeconzDynamicStateDescriptionProvider.java
new file mode 100644 (file)
index 0000000..e576499
--- /dev/null
@@ -0,0 +1,88 @@
+/**
+ * Copyright (c) 2010-2021 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.deconz.internal;
+
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+import org.openhab.core.thing.Channel;
+import org.openhab.core.thing.ChannelUID;
+import org.openhab.core.thing.ThingUID;
+import org.openhab.core.thing.binding.BaseDynamicStateDescriptionProvider;
+import org.openhab.core.thing.events.ThingEventFactory;
+import org.openhab.core.thing.type.DynamicStateDescriptionProvider;
+import org.openhab.core.types.StateDescription;
+import org.openhab.core.types.StateDescriptionFragment;
+import org.osgi.service.component.annotations.Component;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Dynamic channel state description provider.
+ * Overrides the state description for the controls, which receive its configuration in the runtime.
+ *
+ * @author Jan N. Klug - Initial contribution
+ */
+@NonNullByDefault
+@Component(service = { DynamicStateDescriptionProvider.class, DeconzDynamicStateDescriptionProvider.class })
+public class DeconzDynamicStateDescriptionProvider extends BaseDynamicStateDescriptionProvider {
+    private final Logger logger = LoggerFactory.getLogger(DeconzDynamicStateDescriptionProvider.class);
+
+    private final Map<ChannelUID, StateDescriptionFragment> stateDescriptionFragments = new ConcurrentHashMap<>();
+
+    /**
+     * Set a state description for a channel. This description will be used when preparing the channel state by
+     * the framework for presentation. A previous description, if existed, will be replaced.
+     *
+     * @param channelUID
+     *            channel UID
+     * @param stateDescriptionFragment
+     *            state description for the channel
+     */
+    public void setDescriptionFragment(ChannelUID channelUID, StateDescriptionFragment stateDescriptionFragment) {
+        StateDescriptionFragment oldStateDescriptionFragment = stateDescriptionFragments.get(channelUID);
+        if (!stateDescriptionFragment.equals(oldStateDescriptionFragment)) {
+            logger.trace("adding state description for channel {}", channelUID);
+            stateDescriptionFragments.put(channelUID, stateDescriptionFragment);
+            postEvent(ThingEventFactory.createChannelDescriptionChangedEvent(channelUID,
+                    itemChannelLinkRegistry != null ? itemChannelLinkRegistry.getLinkedItemNames(channelUID) : Set.of(),
+                    stateDescriptionFragment, oldStateDescriptionFragment));
+        }
+    }
+
+    /**
+     * remove all descriptions for a given thing
+     *
+     * @param thingUID the thing's UID
+     */
+    public void removeDescriptionsForThing(ThingUID thingUID) {
+        logger.trace("removing state description for thing {}", thingUID);
+        stateDescriptionFragments.entrySet().removeIf(entry -> entry.getKey().getThingUID().equals(thingUID));
+    }
+
+    @Override
+    public @Nullable StateDescription getStateDescription(Channel channel,
+            @Nullable StateDescription originalStateDescription, @Nullable Locale locale) {
+        StateDescriptionFragment stateDescriptionFragment = stateDescriptionFragments.get(channel.getUID());
+        if (stateDescriptionFragment != null) {
+            logger.trace("returning new stateDescription for {}", channel.getUID());
+            return stateDescriptionFragment.toStateDescription();
+        } else {
+            return super.getStateDescription(channel, originalStateDescription, locale);
+        }
+    }
+}
index 93f5b974f2860bd4dac485ed5e3e598285062d81..74fe182307cfaf0be5baf30bafa801607f05c49c 100644 (file)
@@ -65,14 +65,14 @@ public class DeconzHandlerFactory extends BaseThingHandlerFactory {
     private final Gson gson;
     private final WebSocketFactory webSocketFactory;
     private final HttpClientFactory httpClientFactory;
-    private final StateDescriptionProvider stateDescriptionProvider;
-    private final CommandDescriptionProvider commandDescriptionProvider;
+    private final DeconzDynamicStateDescriptionProvider stateDescriptionProvider;
+    private final DeconzDynamicCommandDescriptionProvider commandDescriptionProvider;
 
     @Activate
     public DeconzHandlerFactory(final @Reference WebSocketFactory webSocketFactory,
             final @Reference HttpClientFactory httpClientFactory,
-            final @Reference StateDescriptionProvider stateDescriptionProvider,
-            final @Reference CommandDescriptionProvider commandDescriptionProvider) {
+            final @Reference DeconzDynamicStateDescriptionProvider stateDescriptionProvider,
+            final @Reference DeconzDynamicCommandDescriptionProvider commandDescriptionProvider) {
         this.webSocketFactory = webSocketFactory;
         this.httpClientFactory = httpClientFactory;
         this.stateDescriptionProvider = stateDescriptionProvider;
diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/StateDescriptionProvider.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/StateDescriptionProvider.java
deleted file mode 100644 (file)
index 90cda64..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * Copyright (c) 2010-2021 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.deconz.internal;
-
-import java.util.Locale;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.eclipse.jdt.annotation.Nullable;
-import org.openhab.core.thing.Channel;
-import org.openhab.core.thing.ChannelUID;
-import org.openhab.core.thing.ThingUID;
-import org.openhab.core.thing.type.DynamicStateDescriptionProvider;
-import org.openhab.core.types.StateDescription;
-import org.osgi.service.component.annotations.Component;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Dynamic channel state description provider.
- * Overrides the state description for the controls, which receive its configuration in the runtime.
- *
- * @author Jan N. Klug - Initial contribution
- */
-@NonNullByDefault
-@Component(service = { DynamicStateDescriptionProvider.class, StateDescriptionProvider.class })
-public class StateDescriptionProvider implements DynamicStateDescriptionProvider {
-
-    private final Map<ChannelUID, StateDescription> descriptions = new ConcurrentHashMap<>();
-    private final Logger logger = LoggerFactory.getLogger(StateDescriptionProvider.class);
-
-    /**
-     * Set a state description for a channel. This description will be used when preparing the channel state by
-     * the framework for presentation. A previous description, if existed, will be replaced.
-     *
-     * @param channelUID
-     *            channel UID
-     * @param description
-     *            state description for the channel
-     */
-    public void setDescription(ChannelUID channelUID, StateDescription description) {
-        logger.trace("adding state description for channel {}", channelUID);
-        descriptions.put(channelUID, description);
-    }
-
-    /**
-     * remove all descriptions for a given thing
-     *
-     * @param thingUID the thing's UID
-     */
-    public void removeDescriptionsForThing(ThingUID thingUID) {
-        logger.trace("removing state description for thing {}", thingUID);
-        descriptions.entrySet().removeIf(entry -> entry.getKey().getThingUID().equals(thingUID));
-    }
-
-    @Override
-    public @Nullable StateDescription getStateDescription(Channel channel,
-            @Nullable StateDescription originalStateDescription, @Nullable Locale locale) {
-        if (descriptions.containsKey(channel.getUID())) {
-            logger.trace("returning new stateDescription for {}", channel.getUID());
-            return descriptions.get(channel.getUID());
-        } else {
-            return null;
-        }
-    }
-}
index e4e48d5c3863db5417da76dec1b3b80373fe4d2e..7747d996bb4132fe7d2911ebc868283410f28128 100644 (file)
@@ -13,6 +13,7 @@
 package org.openhab.binding.deconz.internal.dto;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.core.types.CommandOption;
 
 /**
  * The {@link Scene} is send by the websocket connection as well as the Rest API.
@@ -24,4 +25,13 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
 public class Scene {
     public String id = "";
     public String name = "";
+
+    public CommandOption toCommandOption() {
+        return new CommandOption(name, name);
+    }
+
+    @Override
+    public String toString() {
+        return "Scene{" + "id='" + id + '\'' + ", name='" + name + '\'' + '}';
+    }
 }
index ad2f51409b5761ba9adb21fd23cfc277b9a302d8..7a30eb98d04ab8b1adc9fd539ea3c8a4bb3d1f9f 100644 (file)
@@ -19,12 +19,13 @@ import java.util.Set;
 import java.util.stream.Collectors;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.openhab.binding.deconz.internal.CommandDescriptionProvider;
+import org.openhab.binding.deconz.internal.DeconzDynamicCommandDescriptionProvider;
 import org.openhab.binding.deconz.internal.Util;
 import org.openhab.binding.deconz.internal.dto.DeconzBaseMessage;
 import org.openhab.binding.deconz.internal.dto.GroupAction;
 import org.openhab.binding.deconz.internal.dto.GroupMessage;
 import org.openhab.binding.deconz.internal.dto.GroupState;
+import org.openhab.binding.deconz.internal.dto.Scene;
 import org.openhab.binding.deconz.internal.types.ResourceType;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.HSBType;
@@ -36,8 +37,6 @@ import org.openhab.core.thing.Thing;
 import org.openhab.core.thing.ThingStatus;
 import org.openhab.core.thing.ThingTypeUID;
 import org.openhab.core.types.Command;
-import org.openhab.core.types.CommandDescriptionBuilder;
-import org.openhab.core.types.CommandOption;
 import org.openhab.core.types.RefreshType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -56,12 +55,13 @@ import com.google.gson.Gson;
 public class GroupThingHandler extends DeconzBaseThingHandler {
     public static final Set<ThingTypeUID> SUPPORTED_THING_TYPE_UIDS = Set.of(THING_TYPE_LIGHTGROUP);
     private final Logger logger = LoggerFactory.getLogger(GroupThingHandler.class);
-    private final CommandDescriptionProvider commandDescriptionProvider;
+    private final DeconzDynamicCommandDescriptionProvider commandDescriptionProvider;
 
     private Map<String, String> scenes = Map.of();
     private GroupState groupStateCache = new GroupState();
 
-    public GroupThingHandler(Thing thing, Gson gson, CommandDescriptionProvider commandDescriptionProvider) {
+    public GroupThingHandler(Thing thing, Gson gson,
+            DeconzDynamicCommandDescriptionProvider commandDescriptionProvider) {
         super(thing, gson, ResourceType.GROUPS);
         this.commandDescriptionProvider = commandDescriptionProvider;
     }
@@ -142,10 +142,8 @@ public class GroupThingHandler extends DeconzBaseThingHandler {
             GroupMessage groupMessage = (GroupMessage) stateResponse;
             scenes = groupMessage.scenes.stream().collect(Collectors.toMap(scene -> scene.name, scene -> scene.id));
             ChannelUID channelUID = new ChannelUID(thing.getUID(), CHANNEL_SCENE);
-            commandDescriptionProvider.setDescription(channelUID,
-                    CommandDescriptionBuilder.create().withCommandOptions(groupMessage.scenes.stream()
-                            .map(scene -> new CommandOption(scene.name, scene.name)).collect(Collectors.toList()))
-                            .build());
+            commandDescriptionProvider.setCommandOptions(channelUID,
+                    groupMessage.scenes.stream().map(Scene::toCommandOption).collect(Collectors.toList()));
 
         }
         messageReceived(config.id, stateResponse);
index 25a267bcba7b066b043c1c44c343ff3169a12803..dab69ea8100b2865ba3c5f1b81be7170894859da 100644 (file)
@@ -24,8 +24,8 @@ import java.util.stream.Collectors;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.openhab.binding.deconz.internal.CommandDescriptionProvider;
-import org.openhab.binding.deconz.internal.StateDescriptionProvider;
+import org.openhab.binding.deconz.internal.DeconzDynamicCommandDescriptionProvider;
+import org.openhab.binding.deconz.internal.DeconzDynamicStateDescriptionProvider;
 import org.openhab.binding.deconz.internal.Util;
 import org.openhab.binding.deconz.internal.dto.DeconzBaseMessage;
 import org.openhab.binding.deconz.internal.dto.LightMessage;
@@ -49,10 +49,9 @@ import org.openhab.core.thing.ThingTypeUID;
 import org.openhab.core.thing.binding.builder.ChannelBuilder;
 import org.openhab.core.thing.binding.builder.ThingBuilder;
 import org.openhab.core.types.Command;
-import org.openhab.core.types.CommandDescriptionBuilder;
 import org.openhab.core.types.CommandOption;
 import org.openhab.core.types.RefreshType;
-import org.openhab.core.types.StateDescription;
+import org.openhab.core.types.StateDescriptionFragment;
 import org.openhab.core.types.StateDescriptionFragmentBuilder;
 import org.openhab.core.types.UnDefType;
 import org.slf4j.Logger;
@@ -85,8 +84,8 @@ public class LightThingHandler extends DeconzBaseThingHandler {
 
     private final Logger logger = LoggerFactory.getLogger(LightThingHandler.class);
 
-    private final StateDescriptionProvider stateDescriptionProvider;
-    private final CommandDescriptionProvider commandDescriptionProvider;
+    private final DeconzDynamicStateDescriptionProvider stateDescriptionProvider;
+    private final DeconzDynamicCommandDescriptionProvider commandDescriptionProvider;
 
     private long lastCommandExpireTimestamp = 0;
     private boolean needsPropertyUpdate = false;
@@ -104,8 +103,8 @@ public class LightThingHandler extends DeconzBaseThingHandler {
     private int ctMax = ZCL_CT_MAX;
     private int ctMin = ZCL_CT_MIN;
 
-    public LightThingHandler(Thing thing, Gson gson, StateDescriptionProvider stateDescriptionProvider,
-            CommandDescriptionProvider commandDescriptionProvider) {
+    public LightThingHandler(Thing thing, Gson gson, DeconzDynamicStateDescriptionProvider stateDescriptionProvider,
+            DeconzDynamicCommandDescriptionProvider commandDescriptionProvider) {
         super(thing, gson, ResourceType.LIGHTS);
         this.stateDescriptionProvider = stateDescriptionProvider;
         this.commandDescriptionProvider = commandDescriptionProvider;
@@ -123,15 +122,11 @@ public class LightThingHandler extends DeconzBaseThingHandler {
                 ctMin = ctMinString == null ? ZCL_CT_MIN : Integer.parseInt(ctMinString);
 
                 // minimum and maximum are inverted due to mired/kelvin conversion!
-                StateDescription stateDescription = StateDescriptionFragmentBuilder.create()
+                StateDescriptionFragment stateDescriptionFragment = StateDescriptionFragmentBuilder.create()
                         .withMinimum(new BigDecimal(miredToKelvin(ctMax)))
-                        .withMaximum(new BigDecimal(miredToKelvin(ctMin))).build().toStateDescription();
-                if (stateDescription != null) {
-                    stateDescriptionProvider.setDescription(new ChannelUID(thing.getUID(), CHANNEL_COLOR_TEMPERATURE),
-                            stateDescription);
-                } else {
-                    logger.warn("Failed to create state description in thing {}", thing.getUID());
-                }
+                        .withMaximum(new BigDecimal(miredToKelvin(ctMin))).build();
+                stateDescriptionProvider.setDescriptionFragment(
+                        new ChannelUID(thing.getUID(), CHANNEL_COLOR_TEMPERATURE), stateDescriptionFragment);
             } catch (NumberFormatException e) {
                 needsPropertyUpdate = true;
             }
@@ -370,20 +365,16 @@ public class LightThingHandler extends DeconzBaseThingHandler {
                 List<String> options = List.of("none", "steady", "snow", "rainbow", "snake", "tinkle", "fireworks",
                         "flag", "waves", "updown", "vintage", "fading", "collide", "strobe", "sparkles", "carnival",
                         "glow");
-                commandDescriptionProvider.setDescription(effectChannelUID,
-                        CommandDescriptionBuilder.create().withCommandOptions(toCommandOptionList(options)).build());
+                commandDescriptionProvider.setCommandOptions(effectChannelUID, toCommandOptionList(options));
                 break;
             case TINT_MUELLER:
                 options = List.of("none", "colorloop", "sunset", "party", "worklight", "campfire", "romance",
                         "nightlight");
-                commandDescriptionProvider.setDescription(effectChannelUID,
-                        CommandDescriptionBuilder.create().withCommandOptions(toCommandOptionList(options)).build());
+                commandDescriptionProvider.setCommandOptions(effectChannelUID, toCommandOptionList(options));
                 break;
             default:
                 options = List.of("none", "colorloop");
-                commandDescriptionProvider.setDescription(effectChannelUID,
-                        CommandDescriptionBuilder.create().withCommandOptions(toCommandOptionList(options)).build());
-
+                commandDescriptionProvider.setCommandOptions(effectChannelUID, toCommandOptionList(options));
         }
     }
 
index 2e90d778ce301dc65ab2687382fb7ec265dcca0e..b58a8335fff2587621509a9e0c65013f7eb6efdf 100644 (file)
@@ -28,8 +28,8 @@ import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.junit.jupiter.MockitoExtension;
-import org.openhab.binding.deconz.internal.CommandDescriptionProvider;
-import org.openhab.binding.deconz.internal.StateDescriptionProvider;
+import org.openhab.binding.deconz.internal.DeconzDynamicCommandDescriptionProvider;
+import org.openhab.binding.deconz.internal.DeconzDynamicStateDescriptionProvider;
 import org.openhab.binding.deconz.internal.dto.LightMessage;
 import org.openhab.binding.deconz.internal.handler.LightThingHandler;
 import org.openhab.binding.deconz.internal.types.LightType;
@@ -60,8 +60,8 @@ public class LightsTest {
     private @NonNullByDefault({}) Gson gson;
 
     private @Mock @NonNullByDefault({}) ThingHandlerCallback thingHandlerCallback;
-    private @Mock @NonNullByDefault({}) StateDescriptionProvider stateDescriptionProvider;
-    private @Mock @NonNullByDefault({}) CommandDescriptionProvider commandDescriptionProvider;
+    private @Mock @NonNullByDefault({}) DeconzDynamicStateDescriptionProvider stateDescriptionProvider;
+    private @Mock @NonNullByDefault({}) DeconzDynamicCommandDescriptionProvider commandDescriptionProvider;
 
     @BeforeEach
     public void initialize() {
@@ -116,7 +116,7 @@ public class LightsTest {
 
         lightThingHandler.initialize();
 
-        Mockito.verify(stateDescriptionProvider).setDescription(eq(channelUID_ct), any());
+        Mockito.verify(stateDescriptionProvider).setDescriptionFragment(eq(channelUID_ct), any());
     }
 
     @Test