From 47f242e709c4e58871b45babf2ea338f30d0bf4c Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Sun, 2 Jan 2022 12:46:26 +0100 Subject: [PATCH 1/3] Refresh battery level when receiving REFRESH command. Fixes #11932 Signed-off-by: Jacob Laursen --- .../hdpowerview/internal/handler/HDPowerViewShadeHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewShadeHandler.java b/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewShadeHandler.java index 038b4f71a370a..5f3ccf63da8f9 100644 --- a/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewShadeHandler.java +++ b/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewShadeHandler.java @@ -104,8 +104,9 @@ public void initialize() { @Override public void handleCommand(ChannelUID channelUID, Command command) { - if (RefreshType.REFRESH.equals(command)) { + if (RefreshType.REFRESH == command) { requestRefreshShadePosition(); + requestRefreshShadeBatteryLevel(); return; } From 2165e2829783ac1c8b8490cd0563a62b93f56307 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Sun, 2 Jan 2022 13:26:22 +0100 Subject: [PATCH 2/3] Refresh information relative to item type. Signed-off-by: Jacob Laursen --- .../handler/HDPowerViewShadeHandler.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewShadeHandler.java b/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewShadeHandler.java index 5f3ccf63da8f9..e996b58ce33d5 100644 --- a/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewShadeHandler.java +++ b/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewShadeHandler.java @@ -104,13 +104,25 @@ public void initialize() { @Override public void handleCommand(ChannelUID channelUID, Command command) { + String channelId = channelUID.getId(); + if (RefreshType.REFRESH == command) { - requestRefreshShadePosition(); - requestRefreshShadeBatteryLevel(); + 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()); From 859cb7167dacdaa577d5d675fab12a8c489245fa Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Sun, 2 Jan 2022 13:34:03 +0100 Subject: [PATCH 3/3] Update README with shade refresh logic. Signed-off-by: Jacob Laursen --- bundles/org.openhab.binding.hdpowerview/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bundles/org.openhab.binding.hdpowerview/README.md b/bundles/org.openhab.binding.hdpowerview/README.md index 023e621399116..180bbc6120a08 100644 --- a/bundles/org.openhab.binding.hdpowerview/README.md +++ b/bundles/org.openhab.binding.hdpowerview/README.md @@ -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