[hdpowerview] Refresh battery level when receiving refresh command (#11933)
* Refresh battery level when receiving REFRESH command. Fixes #11932 Update README with shade refresh logic. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
e4cd27f623
commit
e8df66f1d0
|
@ -156,6 +156,17 @@ then
|
||||||
end
|
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
|
## Full Example
|
||||||
|
|
||||||
### `demo.things` File
|
### `demo.things` File
|
||||||
|
|
|
@ -104,12 +104,25 @@ public class HDPowerViewShadeHandler extends AbstractHubbedThingHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(ChannelUID channelUID, Command command) {
|
public void handleCommand(ChannelUID channelUID, Command command) {
|
||||||
if (RefreshType.REFRESH.equals(command)) {
|
String channelId = channelUID.getId();
|
||||||
requestRefreshShadePosition();
|
|
||||||
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (channelUID.getId()) {
|
switch (channelId) {
|
||||||
case CHANNEL_SHADE_POSITION:
|
case CHANNEL_SHADE_POSITION:
|
||||||
if (command instanceof PercentType) {
|
if (command instanceof PercentType) {
|
||||||
moveShade(PRIMARY_ACTUATOR, ZERO_IS_CLOSED, ((PercentType) command).intValue());
|
moveShade(PRIMARY_ACTUATOR, ZERO_IS_CLOSED, ((PercentType) command).intValue());
|
||||||
|
|
Loading…
Reference in New Issue