Setpoint can't edit the value with fractional digit

It seems that Android app has a bug with sitemap’s setpoint element.
I have two of them on my sitemap, one with fractional “step” value. This element with fractional value is incorrectly displayed on the edit dialog on Android: the edit dialog displays zero instead of actual value. Also it’s not possible to select any other values, data just disappears. The neighbor element with non-fractional value behaves fine.
Web version of sitemap works as should.

Please fix.

Setpoint item=DryerT1Start label=“Starts at” minValue=0.0 maxValue=23.5 step=0.5
Setpoint item=DryerT1Duration label=“Duration” minValue=0 maxValue=120 step=10

Can you please post your items file?

Of course!

Number DryerT1Start “[MAP(hours_timer_30.map):%s]” (StartPersist,DryerT1)
Number DryerT1Duration “[%d min]” (StartPersist,DryerT1)

And maybe the hours_timer_30.map will be useful too. The idea of this trick is to have only one UI control to select hours and minutes of the day. A little ugly, but unfortunately OpenHAB sitemap elements doesn’t have more useful control. Or at least, I don’t see it.

0=00:00
1=01:00
2=02:00
3=03:00
4=04:00
5=05:00
6=06:00
7=07:00
8=08:00
9=09:00
10=10:00
11=11:00
12=12:00
13=13:00
14=14:00
15=15:00
16=16:00
17=17:00
18=18:00
19=19:00
20=20:00
21=21:00
22=22:00
23=23:00

0.0=00:00
0.5=00:30
1.0=01:00
1.5=01:30
2.0=02:00
2.5=02:30
3.0=03:00
3.5=03:30
4.0=04:00
4.5=04:30
5.0=05:00
5.5=05:30
6.0=06:00
6.5=06:30
7.0=07:00
7.5=07:30
8.0=08:00
8.5=08:30
9.0=09:00
9.5=09:30
10.0=10:00
10.5=10:30
11.0=11:00
11.5=11:30
12.0=12:00
12.5=12:30
13.0=13:00
13.5=13:30
14.0=14:00
14.5=14:30
15.0=15:00
15.5=15:30
16.0=16:00
16.5=16:30
17.0=17:00
17.5=17:30
18.0=18:00
18.5=18:30
19.0=19:00
19.5=19:30
20.0=20:00
20.5=20:30
21.0=21:00
21.5=21:30
22.0=22:00
22.5=22:30
23.0=23:00
23.5=23:30

Can you try Number DryerT1Duration "[%0.2d min]" (StartPersist,DryerT1)? I’ll have a close look at this when I have more time.

Tried, the suggested formatter change causes an error:
2019-03-25 21:49:09.863 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value ‘40’ of item DryerT1Duration with format ‘%0.2d min’: %0.2d

And the issue is not related to DryerT1Duration item. The trouble is with DryerT1Start and the value picker dialog. It should display the set of values from 0.0 to 23.5 but only shows zero as a single choice. And, when attempt to scroll the value in this dialog up or down, even this orphan zero completely disappears.

Guessing - the MAP was added for cosmetic reasons. It worked before that? (albeit with messy number representation)

It’s a neat idea, but I think the whole principle may be flawed. You want to display a string “20:30” that is not readily converted to a number for use in a setpoint widget, it cannot “know” that is supposed to be 20.5 numeric.
It all rather depends if the setpoint widget fetches textual representation separately from umm, widget-action representation.

How well does the widget in Basic UI work with all this?

I can reproduce the issue and I’ll look into it.

Edit: I get this from the sitemap rest API:

    {
    "widgetId": "00",
    "type": "Setpoint",
    "label": "Starts at [6.5]",
    "icon": "number",
    "mappings": [
    ],
    "minValue": 0.0,
    "maxValue": 23.5,
    "step": 0.5,
    "item": {
        "link": "http://localhost:8080/rest/items/DryerT1Start",
        "state": "6.5",
        "stateDescription": {
            "pattern": "",
            "readOnly": false,
            "options": [

            ]
        },
        "editable": false,
        "type": "Number",
        "name": "DryerT1Start",
        "label": "",
        "tags": [

        ],
        "groupNames": [

        ]
    },
    "widgets": [

    ]
},

I don’t think there’s much we can do here, except the picker should start at 6.5 (in that case) instead of 0. After all, the app only has the REST API response above to figure out the items to be displayed … it has no chance of knowing the mapping for formatting.
Additionally, we need to parse the duration as integer (‘100’), not float (‘100.0’) … we currently do the latter, which breaks the formatting pattern. I’ll submit a PR for those items.

Guys, thank you for your attention to this issue!

If you have any better idea how to make just one UI control to pick the value of hours and minutes - please share your ideas. Create two pickers, one for hours and other for minutes, ates too many screen space (especially on mobile devices) and in general looks ugly.

Yep, the MAP is for cosmetic formatting. I wish to have one UI widget as a hours+minutes picker. Didn’t found any solution so imagined this one.

On the Basic UI it works perfect. Also the Basic UI does’nt have a dialog to edit the value. It directly changes it using buttons with arrows.

1 Like

See Improve number handling by maniac103 · Pull Request #1269 · openhab/openhab-android · GitHub for the fix.

On the Basic UI it works perfect. Also the Basic UI does’nt have a dialog to edit the value. It directly changes it using buttons with arrows.

@mueller-ma has a PR open for adding a preference for selecting between the two setpoint widget styles: Add up/down buttons to setpoint widgets by mueller-ma · Pull Request #1052 · openhab/openhab-android · GitHub … we probably should finish & ship this at some point.