]> git.basschouten.com Git - openhab-addons.git/commitdiff
[hdpowerview] Refresh battery level when receiving refresh command (#11933)
authorJacob Laursen <jacob-github@vindvejr.dk>
Sun, 2 Jan 2022 12:44:51 +0000 (13:44 +0100)
committerGitHub <noreply@github.com>
Sun, 2 Jan 2022 12:44:51 +0000 (13:44 +0100)
* Refresh battery level when receiving REFRESH command.

Fixes #11932

Update README with shade refresh logic.

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/handler/HDPowerViewShadeHandler.java

index 023e6213991169bb363ed531e1ec8b8fdc320dbc..180bbc6120a08ec6478059317b613a95c6610803 100644 (file)
@@ -156,6 +156,17 @@ then
 end
 ```
 
+For single shades the refresh takes the item's channel into consideration:
+
+| Channel        | Hard refresh kind |
+|----------------|-------------------|
+| position       | Position          |
+| secondary      | Position          |
+| vane           | Position          |
+| lowBattery     | Battery           |
+| batteryLevel   | Battery           |
+| batteryVoltage | Battery           |
+
 ## Full Example
 
 ### `demo.things` File
index 038b4f71a370a3722f8823e5c5960303eeb233ea..e996b58ce33d5f8815b231d5bea9b1d138877dda 100644 (file)
@@ -104,12 +104,25 @@ public class HDPowerViewShadeHandler extends AbstractHubbedThingHandler {
 
     @Override
     public void handleCommand(ChannelUID channelUID, Command command) {
-        if (RefreshType.REFRESH.equals(command)) {
-            requestRefreshShadePosition();
+        String channelId = channelUID.getId();
+
+        if (RefreshType.REFRESH == command) {
+            switch (channelId) {
+                case CHANNEL_SHADE_POSITION:
+                case CHANNEL_SHADE_SECONDARY_POSITION:
+                case CHANNEL_SHADE_VANE:
+                    requestRefreshShadePosition();
+                    break;
+                case CHANNEL_SHADE_LOW_BATTERY:
+                case CHANNEL_SHADE_BATTERY_LEVEL:
+                case CHANNEL_SHADE_BATTERY_VOLTAGE:
+                    requestRefreshShadeBatteryLevel();
+                    break;
+            }
             return;
         }
 
-        switch (channelUID.getId()) {
+        switch (channelId) {
             case CHANNEL_SHADE_POSITION:
                 if (command instanceof PercentType) {
                     moveShade(PRIMARY_ACTUATOR, ZERO_IS_CLOSED, ((PercentType) command).intValue());