openhab / openhab-webui

Web UIs of openHAB
Eclipse Public License 2.0
218 stars 238 forks source link

Analyzer view does not show anything if stateDescription metadata set for Dimmer Item #1523

Closed NikolayKash closed 1 year ago

NikolayKash commented 1 year ago

I have a Dimmer item where I set state description metadata like

value: " "
config:
  options: 16=1,32=2,48=3,64=4,80=5,100=6
  step: "16"
  min: "16"
  max: "100"

Values are stored in DynamoDB

When I try to analyze this item, Analyzer view does not show anything

like: image

When I remove stateDescription metadata, it shows raw values as expected

image

Expected behavior

Analyzer should show values as defined in stateDescription or raw values

Steps to reproduce

  1. Create dimmer item and add storing values to some persistence provider like DynamoDB
  2. Add stateDescription metadata as mentioned above
  3. Press Analyze button

Your environment

runtimeInfo:
  version: 3.4.0.M2
  buildString: Milestone Build
locale: en-RU
systemInfo:
  javaVersion: 11.0.13
  javaVendor: Azul Systems, Inc.
  javaVendorVersion: Zulu11.52+13-CA

clientInfo:
  device:
    ios: false
    android: false
    androidChrome: false
    desktop: true
    iphone: false
    ipod: false
    ipad: false
    edge: false
    ie: false
    firefox: false
    macos: false
    windows: true
    cordova: false
    phonegap: false
    electron: false
    nwjs: false
    webView: false
    webview: false
    standalone: false
    os: windows
    pixelRatio: 1.25
    prefersColorScheme: dark
  isSecureContext: false
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: N/A
    hardwareConcurrency: 4
    language: en-US
    languages:
      - en-US
      - en
      - ru
    onLine: true
    platform: Win32
  screen:
    width: 1536
    height: 864
    colorDepth: 24
  support:
    touch: false
    pointerEvents: true
    observer: true
    passiveListener: true
    gestures: false
    intersectionObserver: true
  themeOptions:
    dark: dark
    filled: true
    pageTransitionAnimation: default
    bars: light
    homeNavbar: default
    homeBackground: default
    expandableCardAnimation: default
  userAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,
    like Gecko) Chrome/105.0.0.0 Safari/537.36
timestamp: 2022-10-10T19:32:53.111Z

Browser console

As I see it retrives item info as well data from persistence correctly.

{"link":"xxxx:xxxxxx:xxxx/rest/items/xxxxxx_FanSpeed","state":"16","stateDescription":{"minimum":16,"maximum":100,"step":16,"readOnly":false,"options":[{"value":"16","label":"1"},{"value":"32","label":"2"},{"value":"48","label":"3"},{"value":"64","label":"4"},{"value":"80","label":"5"},{"value":"100","label":"6"}]},"commandDescription":{"commandOptions":[{"command":"16","label":"1"},{"command":"32","label":"2"},{"command":"48","label":"3"},{"command":"64","label":"4"},{"command":"80","label":"5"},{"command":"100","label":"6"}]},"editable":true,"type":"Dimmer","name":"xxxxxx_FanSpeed","label":"xxxxxx_FanSpeed","category":"DimmableLight","tags":["Point"],"groupNames":["xxxxxxx"]}
{"name":"xxxxxxx_FanSpeed","datapoints":"34","data":[{"time":1665389576886,"state":"0"},{"time":1665413806289,"state":"16"},{"time":1665413836135,"state":"48"},{"time":1665413836192,"state":"16"},{"time":1665413836259,"state":"48"},{"time":1665414377802,"state":"16"},{"time":1665414377858,"state":"48"},{"time":1665414377937,"state":"16"},{"time":1665423580526,"state":"48"},{"time":1665423580595,"state":"16"},{"time":1665423580659,"state":"48"},{"time":1665424121897,"state":"16"},{"time":1665424121995,"state":"48"},{"time":1665424122072,"state":"16"},{"time":1665424181910,"state":"48"},{"time":1665424181977,"state":"16"},{"time":1665424182058,"state":"48"},{"time":1665424723618,"state":"16"},{"time":1665424723709,"state":"48"},{"time":1665424723785,"state":"16"},{"time":1665427791730,"state":"48"},{"time":1665427791793,"state":"16"},{"time":1665427791863,"state":"48"},{"time":1665427827556,"state":"16"},{"time":1665427841463,"state":"48"},{"time":1665428332777,"state":"16"},{"time":1665428332822,"state":"48"},{"time":1665428332954,"state":"16"},{"time":1665428392719,"state":"48"},{"time":1665428392787,"state":"16"},{"time":1665428392852,"state":"48"},{"time":1665428935799,"state":"16"},{"time":1665428935872,"state":"48"},{"time":1665428935937,"state":"16"}]}

Browser network traffic

Additional information

NikolayKash commented 1 year ago

@ghys, could you please take a look on this?

ghys commented 1 year ago

This is the relevant code, when an item has state options the series is considered "discrete": https://github.com/openhab/openhab-webui/blob/b47ed942e6327b2e1ec30e6032a1478d2ebf1b69/bundles/org.openhab.ui/web/src/pages/analyzer/analyzer.vue#L352 The idea was that it would be represented as colored areas on the chart, one color by value, but this ended only implemented for "ON" and "OPEN" states being rendered as an area, not generic states.

NikolayKash commented 1 year ago

@ghys, thanks! is there any plan to change it for dimmer type?

ghys commented 1 year ago

I wouldn't mind having the options ignored for now, but only while the "discrete" graphs are not implemented (would resemble something like https://echarts.apache.org/examples/en/editor.html?c=custom-profile&reset=1&edit=1 somehow merged with the usual line charts). Ultimately defining options should mean that you expect such a chart with colored rectangles, each color representing a different option.