]> git.basschouten.com Git - openhab-addons.git/commitdiff
[hdpowerview] Fix autoupdate quirk. (#12141)
authorJacob Laursen <jacob-github@vindvejr.dk>
Thu, 27 Jan 2022 20:38:29 +0000 (21:38 +0100)
committerGitHub <noreply@github.com>
Thu, 27 Jan 2022 20:38:29 +0000 (21:38 +0100)
Fixes #12140

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
bundles/org.openhab.binding.hdpowerview/README.md
bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/builders/SceneChannelBuilder.java
bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/builders/SceneGroupChannelBuilder.java
bundles/org.openhab.binding.hdpowerview/src/test/java/org/openhab/binding/hdpowerview/SceneChannelBuilderTest.java
bundles/org.openhab.binding.hdpowerview/src/test/java/org/openhab/binding/hdpowerview/SceneGroupChannelBuilderTest.java

index 85d358fbacee7c2aed9e8e2346fa23becf45ccef..d913d53416a82a8aecb1260462d593486efac260 100644 (file)
@@ -76,8 +76,8 @@ have different `id` values:
 
 | Channel Group | Channel | Item Type | Description |
 |---------------|---------|-----------|-------------|
-| scenes        | id      | Switch    | Setting this to ON will activate the scene. Scenes are stateless in the PowerView hub; they have no on/off state. Note: include `{autoupdate="false"}` in the item configuration to avoid having to reset it to off after use. |
-| sceneGroups   | id      | Switch    | Setting this to ON will activate the scene group. Scene groups are stateless in the PowerView hub; they have no on/off state. Note: include `{autoupdate="false"}` in the item configuration to avoid having to reset it to off after use. |
+| scenes        | id      | Switch    | Setting this to ON will activate the scene. Scenes are stateless in the PowerView hub; they have no on/off state. |
+| sceneGroups   | id      | Switch    | Setting this to ON will activate the scene group. Scene groups are stateless in the PowerView hub; they have no on/off state. |
 | automations   | id      | Switch    | Setting this to ON will enable the automation, while OFF will disable it. |
 
 ### Channels for Shades (Thing type `shade`)
@@ -239,7 +239,7 @@ Switch Bedroom_Repeater_BlinkingEnabled "Bedroom Repeater Blinking Enabled [%s]"
 Scene items:
 
 ```
-Switch Living_Room_Shades_Scene_Heart "Living Room Shades Scene Heart" <blinds> (g_Shades_Scene_Trigger) {channel="hdpowerview:hub:g24:scenes#22663", autoupdate="false"}
+Switch Living_Room_Shades_Scene_Heart "Living Room Shades Scene Heart" <blinds> (g_Shades_Scene_Trigger) {channel="hdpowerview:hub:g24:scenes#22663"}
 ```
 
 ### `demo.sitemap` File
index ad11985cb4cdc22044e44673b85fe4455d1412aa..01c05137e9eced3e22c54c3345c9b1d3b6518023 100644 (file)
@@ -24,6 +24,7 @@ import org.openhab.core.thing.Channel;
 import org.openhab.core.thing.ChannelGroupUID;
 import org.openhab.core.thing.ChannelUID;
 import org.openhab.core.thing.binding.builder.ChannelBuilder;
+import org.openhab.core.thing.type.AutoUpdatePolicy;
 
 /**
  * The {@link SceneChannelBuilder} class creates scene channels
@@ -95,6 +96,7 @@ public class SceneChannelBuilder extends BaseChannelBuilder {
         ChannelUID channelUid = new ChannelUID(channelGroupUid, Integer.toString(scene.id));
         String description = translationProvider.getText("dynamic-channel.scene-activate.description", scene.getName());
         return ChannelBuilder.create(channelUid, CoreItemFactory.SWITCH).withType(channelTypeUid)
-                .withLabel(scene.getName()).withDescription(description).build();
+                .withLabel(scene.getName()).withDescription(description).withAutoUpdatePolicy(AutoUpdatePolicy.VETO)
+                .build();
     }
 }
index 2b70b21d2e6a06287fecbf85f01e822dccf67a6d..4cc4436ea2f32eda9abfea4eaa9a51ab5f745b60 100644 (file)
@@ -24,6 +24,7 @@ import org.openhab.core.thing.Channel;
 import org.openhab.core.thing.ChannelGroupUID;
 import org.openhab.core.thing.ChannelUID;
 import org.openhab.core.thing.binding.builder.ChannelBuilder;
+import org.openhab.core.thing.type.AutoUpdatePolicy;
 
 /**
  * The {@link SceneGroupChannelBuilder} class creates scene group channels
@@ -97,6 +98,7 @@ public class SceneGroupChannelBuilder extends BaseChannelBuilder {
         String description = translationProvider.getText("dynamic-channel.scene-group-activate.description",
                 sceneCollection.getName());
         return ChannelBuilder.create(channelUid, CoreItemFactory.SWITCH).withType(channelTypeUid)
-                .withLabel(sceneCollection.getName()).withDescription(description).build();
+                .withLabel(sceneCollection.getName()).withDescription(description)
+                .withAutoUpdatePolicy(AutoUpdatePolicy.VETO).build();
     }
 }
index 94065aa07f0436dc031f920a54a3f647a230178e..80f867423e93185841c7e40a224e18734537aeef 100644 (file)
@@ -29,6 +29,7 @@ import org.openhab.binding.hdpowerview.internal.builders.SceneChannelBuilder;
 import org.openhab.core.thing.Channel;
 import org.openhab.core.thing.ChannelGroupUID;
 import org.openhab.core.thing.ThingUID;
+import org.openhab.core.thing.type.AutoUpdatePolicy;
 import org.osgi.framework.Bundle;
 
 /**
@@ -80,6 +81,15 @@ public class SceneChannelBuilderTest {
         assertEquals(Integer.toString(scenes.get(0).id), channels.get(0).getUID().getIdWithoutGroup());
     }
 
+    @Test
+    public void autoUpdatePolicyIsCorrect() {
+        List<Scene> scenes = createScenes();
+        List<Channel> channels = builder.withScenes(scenes).build();
+
+        assertEquals(1, channels.size());
+        assertEquals(AutoUpdatePolicy.VETO, channels.get(0).getAutoUpdatePolicy());
+    }
+
     @Test
     public void suppliedListIsUsed() {
         List<Scene> scenes = createScenes();
index 16286650d59fe293efc5e4e1b37a4a87beb1c08a..f5566e4c5b58bf522cd26efe88d57c6b7b2fcfa6 100644 (file)
@@ -29,6 +29,7 @@ import org.openhab.binding.hdpowerview.internal.builders.SceneGroupChannelBuilde
 import org.openhab.core.thing.Channel;
 import org.openhab.core.thing.ChannelGroupUID;
 import org.openhab.core.thing.ThingUID;
+import org.openhab.core.thing.type.AutoUpdatePolicy;
 import org.osgi.framework.Bundle;
 
 /**
@@ -80,6 +81,15 @@ public class SceneGroupChannelBuilderTest {
         assertEquals(Integer.toString(sceneCollections.get(0).id), channels.get(0).getUID().getIdWithoutGroup());
     }
 
+    @Test
+    public void autoUpdatePolicyIsCorrect() {
+        List<SceneCollection> sceneCollections = createSceneCollections();
+        List<Channel> channels = builder.withSceneCollections(sceneCollections).build();
+
+        assertEquals(1, channels.size());
+        assertEquals(AutoUpdatePolicy.VETO, channels.get(0).getAutoUpdatePolicy());
+    }
+
     @Test
     public void suppliedListIsUsed() {
         List<SceneCollection> sceneCollections = createSceneCollections();