Skip to content

Commit

Permalink
[hdpowerview] Refresh battery level when receiving refresh command (o…
Browse files Browse the repository at this point in the history
…penhab#11933)

* Refresh battery level when receiving REFRESH command.

Fixes openhab#11932

Update README with shade refresh logic.

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
  • Loading branch information
jlaur authored and andan67 committed Nov 5, 2022
1 parent fa75430 commit d0b9346
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
11 changes: 11 additions & 0 deletions bundles/org.openhab.binding.hdpowerview/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,25 @@ public void initialize() {

@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());
Expand Down

0 comments on commit d0b9346

Please sign in to comment.