Skip to content
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

[rest] Persistence: Optionally add current Item state to response #4394

Merged
merged 2 commits into from
Oct 9, 2024

Conversation

florian-h05
Copy link
Contributor

@florian-h05 florian-h05 commented Sep 30, 2024

This adds a new query param itemState to the GET /rest/persistence/items/{itemname} endpoint.

This new parameter allows to add the current Item state to the data returned from persistence, which is a huge improvement for charts in the UI:

  • "normal" charts range until the end of the requested time range
  • "aggregate" charts such as a monthly chart are able to display the values of the current month even if the monthly value is only persisted at the end of the month

There are two special cases where the Item state is not added with the current time to the response:

  • If the boundary query param is also set to true and a state was already added to the requested end time, there is no need to include the current Item state as there already is a state at the end of the time range.
  • If the current time is after the requested end time and no end state was added, add the current state as the end state.

@florian-h05 florian-h05 requested a review from a team as a code owner September 30, 2024 22:01
@florian-h05 florian-h05 marked this pull request as draft September 30, 2024 22:05
@florian-h05 florian-h05 marked this pull request as ready for review September 30, 2024 22:34
@florian-h05 florian-h05 marked this pull request as draft October 1, 2024 09:46
…ponse

This new optional parameter gives the UI additional possibilities for charts.
E.g. it is now possible to display a bar chart with monthly energy consumption, where the consumption is only persisted at the end of the month, that includes the data from this month.

Signed-off-by: Florian Hotze <[email protected]>
@florian-h05 florian-h05 marked this pull request as ready for review October 2, 2024 23:52
@stefan-hoehn
Copy link
Contributor

I can totally understand why this param makes sense. These are the situations where you want to have all the information presented and where the data to be shown has not been persisted yet (for a reason), so you start developing you own specific implementation and work around. Therefore, your extension is very welcome! Very good idea.

Signed-off-by: Florian Hotze <[email protected]>
Copy link
Member

@kaikreuzer kaikreuzer left a comment

Choose a reason for hiding this comment

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

If it helps for nicer charts, let's add it. :-)

@kaikreuzer kaikreuzer merged commit 389f6a3 into openhab:main Oct 9, 2024
5 checks passed
@kaikreuzer kaikreuzer added this to the 4.3 milestone Oct 9, 2024
@kaikreuzer kaikreuzer added the enhancement An enhancement or new feature of the Core label Oct 9, 2024
@florian-h05 florian-h05 deleted the rest-persistence-itemstate branch October 9, 2024 17:34
florian-h05 added a commit to florian-h05/openhab-webui that referenced this pull request Oct 10, 2024
florian-h05 added a commit to florian-h05/openhab-webui that referenced this pull request Oct 10, 2024
florian-h05 added a commit to openhab/openhab-webui that referenced this pull request Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants