Skip to content

Commit

Permalink
Add support for group item type to window covering (openhab#10936)
Browse files Browse the repository at this point in the history
Add support for setting TARGET_POSITION of Window Covering accessories from groups with a baseItem type

Closes openhab#10812

Signed-off-by: Colin Keehan <github@colin.xyz>
Signed-off-by: dw-8 <davy.wong.on+github@gmail.com>
  • Loading branch information
ckeehan authored and dw-8 committed Jul 25, 2021
1 parent a0a9bc1 commit 508e6f9
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.items.GroupItem;
import org.openhab.core.items.Item;
import org.openhab.core.library.items.DimmerItem;
import org.openhab.core.library.items.NumberItem;
Expand Down Expand Up @@ -84,12 +85,19 @@ public CompletableFuture<Void> setTargetPosition(int value) {
getCharacteristic(TARGET_POSITION).ifPresentOrElse(taggedItem -> {
final Item item = taggedItem.getItem();
final int targetPosition = convertPosition(value, openPosition);

if (item instanceof RollershutterItem) {
((RollershutterItem) item).send(new PercentType(targetPosition));
} else if (item instanceof DimmerItem) {
((DimmerItem) item).send(new PercentType(targetPosition));
} else if (item instanceof NumberItem) {
((NumberItem) item).send(new DecimalType(targetPosition));
} else if (item instanceof GroupItem && ((GroupItem) item).getBaseItem() instanceof RollershutterItem) {
((GroupItem) item).send(new PercentType(targetPosition));
} else if (item instanceof GroupItem && ((GroupItem) item).getBaseItem() instanceof DimmerItem) {
((GroupItem) item).send(new PercentType(targetPosition));
} else if (item instanceof GroupItem && ((GroupItem) item).getBaseItem() instanceof NumberItem) {
((GroupItem) item).send(new DecimalType(targetPosition));
} else {
logger.warn(
"Unsupported item type for characteristic {} at accessory {}. Expected Rollershutter, Dimmer or Number item, got {}",
Expand Down

0 comments on commit 508e6f9

Please sign in to comment.