-
-
Notifications
You must be signed in to change notification settings - Fork 425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rollershutter slider has incorrect value #4358
Comments
I'd say that the actual issue is not within the client, but the widget state being |
Because it's a switch, I guess. |
Good point. Any reason for not making this a |
There's no explicit The client handles |
Oh, I completely forgot about that :-/ Anyways, the reason why widget state is preferred over item state is outlined in the commit that introduced it: openhab/openhab-android@68cff1f ... AFAICT, that rationale also applies to roller shutters, doesn't it? |
In this special case I'd prefer the Item state over the Widget state. As the Widget state is only ON/OFF, there cannot be any UoM or number formatting applied. |
I understand and agree for this specific special case, but the question is: how do you intend to separate this special case from all others properly? |
Thinking about it more, I think this needs to be fixed in core, since otherwise there'll be inconsistencies between the various clients (and special case code tends to become hard to maintain). diff --git a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/items/ItemUIRegistryImpl.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/items/ItemUIRegistryImpl.jav+a
index f5eccaf2b..cb4764d8c 100644
--- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/items/ItemUIRegistryImpl.java
+++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/items/ItemUIRegistryImpl.java
@@ -733,19 +733,22 @@ public class ItemUIRegistryImpl implements ItemUIRegistry {
itemState = convertStateToWidgetUnit(quantityTypeState, w);
}
- if (w instanceof Switch && i instanceof RollershutterItem) {
- // RollerShutter are represented as Switch in a Sitemap but need a PercentType state
- returnState = itemState.as(PercentType.class);
- } else if (w instanceof Slider) {
+ if (w instanceof Slider) {
if (i.getAcceptedDataTypes().contains(PercentType.class)) {
returnState = itemState.as(PercentType.class);
} else if (!(itemState instanceof QuantityType<?>)) {
returnState = itemState.as(DecimalType.class);
}
} else if (w instanceof Switch sw) {
- StateDescription stateDescr = i.getStateDescription();
- if (sw.getMappings().isEmpty() && (stateDescr == null || stateDescr.getOptions().isEmpty())) {
- returnState = itemState.as(OnOffType.class);
+ if (i instanceof RollershutterItem
+ || (i instanceof GroupItem gi && gi.getBaseItem() instanceof RollershutterItem)) {
+ // RollerShutter are represented as Switch in a Sitemap but need a PercentType state
+ returnState = itemState.as(PercentType.class);
+ } else {
+ StateDescription stateDescr = i.getStateDescription();
+ if (sw.getMappings().isEmpty() && (stateDescr == null || stateDescr.getOptions().isEmpty())) {
+ returnState = itemState.as(OnOffType.class);
+ }
}
} |
I also think it should be fixed at core. @openhab/core-maintainers can you move this issue to the core repo? |
Actual behaviour
I have a group Item with the following config:
And a Sitemap widget configured as
Switch item=MyGroup
When the average is let's say 50, I expect the slider in the bottom sheet to be at 50, but it's either at 0 (when the actual value is 0) or 100 otherwise.
Here's what gets passed to
Widget.updateFromEvent()
:The state for the widget is
ON
, which translates to the numeric value100
. But the item state is3.00000
, which is correct.Is there any metadata I need to set? Or should the client make a special handling for Rollershutter group switches?
Expected behaviour
The slider has the correct value.
The text was updated successfully, but these errors were encountered: