Skip to content

Support new chart parameter: interpolation#3920

Merged
maniac103 merged 6 commits intoopenhab:mainfrom
holgerfriedrich:pr-chart-interpolation
Dec 22, 2025
Merged

Support new chart parameter: interpolation#3920
maniac103 merged 6 commits intoopenhab:mainfrom
holgerfriedrich:pr-chart-interpolation

Conversation

@holgerfriedrich
Copy link
Copy Markdown
Member

Support new core feature openhab/openhab-core#4610

Partly fixes openhab/openhab-webui#3277

This is totally untested, I don't have proper dev setup at hand.

Copy link
Copy Markdown
Member

@mueller-ma mueller-ma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So interpolation is a new Sitemap chart parameter that just needs to be added to the URL when getting charts from the server? It case this change would be fine, however since the last release of the app, @maniac103 implemented client-side charts, which should also use this new parameter.

@holgerfriedrich
Copy link
Copy Markdown
Member Author

Yes, exactly, this is a new parameter to be appended to the URL.
I have done it similar to the yAxisDecimalPattern option, both described here in docs.
I thought I have added interpolation to all places, where yAxisDecimalPattern was used.

I don't know about then new client-side rendering. Maybe @maniac103 could give me some guidance.

@mueller-ma
Copy link
Copy Markdown
Member

It seems that the client side chart library doesn't support interpolation and it needs to be done manually before sending the values to the chart.

@maniac103
Copy link
Copy Markdown
Contributor

maniac103 commented Jul 20, 2025

It seems that the client side chart library doesn't support interpolation

It does: there's LineDataSet.setMode(), which allows selecting LINEAR or STEPPED (the former being the default).
So when constructing the data set after loading from persistence API, we can use the value from the widget (which we have at hand there) to select the right mode.

@holgerfriedrich holgerfriedrich force-pushed the pr-chart-interpolation branch from c8c16f0 to 064c514 Compare July 20, 2025 13:10
Signed-off-by: Holger Friedrich <[email protected]>
@holgerfriedrich holgerfriedrich force-pushed the pr-chart-interpolation branch from 064c514 to 92565c1 Compare July 20, 2025 13:17
@holgerfriedrich
Copy link
Copy Markdown
Member Author

@mueller-ma Should we split this up and fix the server side charts first?

@maniac103 I don't see how I could implement the client-side charts. Would you be willing to guide me, or could you take over the implementation? We still have a few showstoppers for the OH5.0 release to resolve.

@maniac103
Copy link
Copy Markdown
Contributor

@holgerfriedrich Yes, I can complete this PR, assuming I can push to your branch.

@holgerfriedrich
Copy link
Copy Markdown
Member Author

Thanks a lot. I added you as a collaborator.

@maniac103
Copy link
Copy Markdown
Contributor

@holgerfriedrich I added the client side rendering handling. It's untested for now though, as interpolation doesn't seem to be part of the sitemap response:

        {
            "widgetId": "030404",
            "type": "Chart",
            "visibility": true,
            "label": "Füllstand Zisterne (Liter) [5643 l]",
            "labelSource": "ITEM_LABEL",
            "icon": "cistern",
            "staticIcon": false,
            "pattern": "%d l",
            "unit": "",
            "mappings": [

            ],
            "refresh": 1800000,
            "service": "influxdb",
            "period": "3D",
            "item": {
                "link": "http://192.168.100.10:8080/rest/items/CisternFillingLiter",
                "state": "5643.00",
                "stateDescription": {
                    "minimum": 0.0,
                    "maximum": 1.0E+8,
                    "pattern": "%d l",
                    "readOnly": true,
                    "options": [

                    ]
                },
                "lastState": "5638.00",
                "lastStateUpdate": 1753096820370,
                "lastStateChange": 1753096820370,
                "type": "Number",
                "name": "CisternFillingLiter",
                "label": "Füllstand Zisterne (Liter)",
                "category": "cistern",
                "tags": [
                    "Measurement",
                    "Water"
                ],
                "groupNames": [
                    "CisternFillSensor",
                    "GroupPersistenceChartable"
                ]
            },
            "widgets": [

            ]
        }

This is with no explicit interpolation set. I tried to set interpolation (via UI), but Main UI doesn't save the page once I've done that.
I'm running 5.0 RC1. Am I missing something here?

(FWIW, openhab/openhab-core#4610 not making any changes to WidgetDTO seems suspicious to me - after all, that's what the sitemap JSON response is generated from. Also FYI @mherwege )

@holgerfriedrich
Copy link
Copy Markdown
Member Author

@maniac103 I seems I forgot to follow up on this PR. I just briefly checked the commit log of the app, but I have not found that this was resolved. Correct?

@maniac103
Copy link
Copy Markdown
Contributor

@holgerfriedrich Correct. The code still seems fine, but what's missing is testing it against a server that actually sends the interpolaton value. Do you have a 5.1 test setup at hand?

@holgerfriedrich
Copy link
Copy Markdown
Member Author

Thanks for the feedback. I will give it a try the next days then 👍 - I did not have a dev environment for Android until now.

@holgerfriedrich
Copy link
Copy Markdown
Member Author

No I have completed my setup.
Sitemap contains 2 charts, first linear, then step.

In basicui it looks fine,

grafik

The API explorer shows correctly:

{
  "name": "default",
  "label": "Telefon",
  "link": "https://home3:8443/rest/sitemaps/default",
  "homepage": {
    "id": "default",
    "title": "Telefon",
    "link": "https://home3:8443/rest/sitemaps/default/default",
    "leaf": false,
    "timeout": false,
    "widgets": [
      {
        "widgetId": "00",
        "type": "Frame",
        "visibility": true,
        "label": "",
        "labelSource": "NONE",
        "icon": "frame",
        "staticIcon": false,
        "unit": "",
        "mappings": [],
        "widgets": [
          {
            "widgetId": "0000",
            "type": "Chart",
            "visibility": true,
            "label": "Außentemperatur (inet) [4.8 °C]",
            "labelSource": "ITEM_LABEL",
            "icon": "temperature",
            "staticIcon": false,
            "pattern": "%.1f °C",
            "unit": "°C",
            "mappings": [],
            "period": "12h",
            "interpolation": "linear",
            "item": {
              "link": "https://home3:8443/rest/items/Wetter_Inet_Temp",
              "state": "4.75 °C",
              "stateDescription": {
                "pattern": "%.1f °C",
                "readOnly": true,
                "options": []
              },
              "lastState": "4.99 °C",
              "lastStateUpdate": 1766353842039,
              "lastStateChange": 1766353842039,
              "unitSymbol": "°C",
              "type": "Number:Temperature",
              "name": "Wetter_Inet_Temp",
              "label": "Außentemperatur (inet)",
              "category": "temperature",
              "tags": [
                "Temperature",
                "Measurement"
              ],
              "groupNames": [
                "gWetterDia"
              ]
            },
            "widgets": []
          },
          {
            "widgetId": "0001",
            "type": "Chart",
            "visibility": true,
            "label": "Außentemperatur (inet) [4.8 °C]",
            "labelSource": "ITEM_LABEL",
            "icon": "temperature",
            "staticIcon": false,
            "pattern": "%.1f °C",
            "unit": "°C",
            "mappings": [],
            "period": "12h",
            "interpolation": "step",
            "item": {
              "link": "https://home3:8443/rest/items/Wetter_Inet_Temp",
              "state": "4.75 °C",
              "stateDescription": {
                "pattern": "%.1f °C",
                "readOnly": true,
                "options": []
              },
              "lastState": "4.99 °C",
              "lastStateUpdate": 1766353842039,
              "lastStateChange": 1766353842039,
              "unitSymbol": "°C",
              "type": "Number:Temperature",
              "name": "Wetter_Inet_Temp",
              "label": "Außentemperatur (inet)",
              "category": "temperature",
              "tags": [
                "Temperature",
                "Measurement"
              ],
              "groupNames": [
                "gWetterDia"
              ]
            },
            "widgets": []
          },
...

The APP does not show correctly yet:
Let me check that this is really the PR build and not the one from main I had tested before....

grafik

@holgerfriedrich
Copy link
Copy Markdown
Member Author

If click the charts in the app, everything is shown stepped, regardless of the setting in the sitemap:
grafik
(blue color indicates my local change, note that only this chart is shown blue)

@maniac103
Copy link
Copy Markdown
Contributor

maniac103 commented Dec 22, 2025

The current code in this PR expects LINEAR, not linear. Not sure whether the string sent by the server changed at some point?
Either way, I 'like' the inconsistency between label source and Interpolation values :-/

@maniac103
Copy link
Copy Markdown
Contributor

(blue color indicates my local change, note that only this chart is shown blue)

What do you mean by that? The locally rendered charts should use (roughly) the same colors as the server side rendered ones.

Signed-off-by: Holger Friedrich <[email protected]>
@holgerfriedrich
Copy link
Copy Markdown
Member Author

Yeah, got it!

Server side images:
grafik

client side, linear:
grafik

client side, step:
grafik

The only problem I see now is that for "undefined" the defaults differ (server side: linear, client side: step).

Will have a look later.

(btw: the blue color above was just to make sure that I have really built and deployed my code. I have removed it now.)

Signed-off-by: Holger Friedrich <[email protected]>
@holgerfriedrich
Copy link
Copy Markdown
Member Author

Ok, the default is now linear also for the client side rendering.

PR is ready for review 🎉

@maniac103 maniac103 merged commit 1f8152a into openhab:main Dec 22, 2025
8 checks passed
@holgerfriedrich holgerfriedrich deleted the pr-chart-interpolation branch December 22, 2025 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sitemap interpolation parameter for charts not implemented

3 participants