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

Percent sign in pattern of state description (meta data) is displayed incorrectly as %% in Analyze chart #928

Closed
thomaszlow opened this issue Feb 25, 2021 · 2 comments
Labels
bug Something isn't working main ui Main UI

Comments

@thomaszlow
Copy link

The problem

In the state description the value %d %% is entered as a pattern:

s1

In the analyze chart %% is displayed on x axis as well as the selectable axis in the control area.

s2

Expected behavior

Only % is displayed like for other values e.g. kWh or °C.

Steps to reproduce

  1. Select a dimmer item
  2. Add a state description as meta data
  3. Enter the value %d %% as pattern in the state description
  4. Go back to item
  5. Click on "Analyze"

Your environment

openHAB 3.0.1 Release Build
Docker on Synology DS918+

Browser console

Error occurs seems to occur in the backgound but not in the analyze overlay.

image

Browser network traffic

image

Additional information

None

@thomaszlow thomaszlow added bug Something isn't working main ui Main UI labels Feb 25, 2021
@Rossko57
Copy link

Rossko57 commented Mar 9, 2021

See also #870

@hubsif
Copy link
Contributor

hubsif commented Mar 19, 2021

Actually, that doesn't seem easy to solve. Afaik openHAB doesn't actually keep a unit parameter with an item, only a "dimension", like temperature. The unit is then chosen by the locale setting and can be overwritten in the state description, to e.g. automatically convert from °F to °C.

Right now, for charts the UI simply assumes the unit to be the second part of either the transformed state, state or if set the state description. While this mostly works, it breaks in multiple situations:

  1. if the state description converts the dimension for some reason (e.g. °C to °F), the chart still displays °C (IMHO this is actually a new, different bug)
  2. the correct unit is not detected for dimensionless items, and even displays wrong when the state description doesn't follow the " " pattern. Instead for currency values defined as $ %d it shows %d as value
  3. it doesn't take the required double percent sign into account, required for the server side printf(?) (unfortunately, the dimension "percentage" doesn't exist explicitly, which I also would have liked to use multiple times)

For now I think the UI could simply detect the double %%, which would solve many cases. But I think for 1. and 2. there's no easy solution...

hubsif added a commit to hubsif/openhab-webui that referenced this issue Mar 25, 2021
@ghys ghys closed this as completed in 7cbdc3c Mar 25, 2021
ghys pushed a commit that referenced this issue Apr 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working main ui Main UI
Projects
None yet
Development

No branches or pull requests

3 participants