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

Multiple selection not displaying correctly for INTEGER type #852

Closed
pacive opened this issue Jan 27, 2021 · 0 comments · Fixed by #874
Closed

Multiple selection not displaying correctly for INTEGER type #852

pacive opened this issue Jan 27, 2021 · 0 comments · Fixed by #874
Labels
bug Something isn't working main ui Main UI

Comments

@pacive
Copy link
Member

pacive commented Jan 27, 2021

The problem

When defining a parameter as <parameter name="parameterName" type="integer" multiple="true"> in the xml-file the resulting multiple selection input doesn't display which values are checked when editing a Thing. I believe the reason is that the config-description returns the values as strings, but the thing definition returns them as numbers, which breaks the comparison. This can be seen in the config YAML: if you check some of the options, they appear in the YAML config as string representations of the numbers, but when the thing is loaded from the rest api they appear as numbers. Obviously, only strings work for html inputs, and they can be parsed to create the Thing correctly, but when the Thing is loaded for editing, the values are returned as numbers, and need to be converted to strings to make the comparison work and set the checked-value of the option correctly.

Expected behavior

The configured values appear as checked boxes when editing a Thing with a multiple-selection list.

Steps to reproduce

  1. Install the SMHI-binding
  2. Create a new Forecast thing, and check some of the values for Hourly forecasts and/or Daily forecasts
    The YAML would look something like this:
UID: smhi:forecast:d43ea277fd
label: SMHI Weather Forecast
thingTypeUID: smhi:forecast
configuration:
  hourlyForecasts:
    - "0"
    - "1"
    - "2"
  latitude: 56
  longitude: 12

The thing gets created correctly
3. Open the thing to edit the configuration. No values are checked, and the YAML look like this:

UID: smhi:forecast:d43ea277fd
label: SMHI Weather Forecast
thingTypeUID: smhi:forecast
configuration:
  hourlyForecasts:
    - 0
    - 1
    - 2
  latitude: 56
  longitude: 12

Your environment

runtimeInfo:
  version: 3.0.0
  buildString: Release Build
locale: en_SE
systemInfo:
  configFolder: C:\Users\ander\AppData\Local\Openhab3\conf
  userdataFolder: C:\Users\ander\AppData\Local\Openhab3\userdata
  logFolder: C:\Users\ander\AppData\Local\Openhab3\userdata\logs
  javaVersion: 11.0.8
  javaVendor: Oracle Corporation
  javaVendorVersion: "18.9"
  osName: Windows 10
  osVersion: "10.0"
  osArchitecture: amd64
  availableProcessors: 8
  freeMemory: 78645672
  totalMemory: 159383552
bindings:
  - nibeuplinkrest
  - smhi
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: light
  isSecureContext: true
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: 8
    hardwareConcurrency: 8
    language: en-US
    languages:
      - en-US
      - sv
      - en-GB
      - sv-SE
    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: light
    filled: true
    pageTransitionAnimation: default
    bars: filled
    homeNavbar: default
    homeBackground: default
    expandableCardAnimation: default
  userAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,
    like Gecko) Chrome/88.0.4324.104 Safari/537.36
timestamp: 2021-01-27T19:20:50.469Z

Browser console

Browser network traffic

Example config-description:

{
  "description": "The daily forecasts to display",
  "label": "Daily Forecasts",
  "name": "dailyForecasts",
  "required": false,
  "type": "INTEGER",
  "readOnly": false,
  "multiple": true,
  "advanced": false,
  "verify": false,
  "limitToOptions": true,
  "options": [
    {
      "label": "Today",
      "value": "0"
    },
    {
      "label": "Tomorrow",
      "value": "1"
    },
    {
      "label": "2 days from now",
      "value": "2"
    },
    {
      "label": "3 days from now",
      "value": "3"
    },
    {
      "label": "4 days from now",
      "value": "4"
    },
    {
      "label": "5 days from now",
      "value": "5"
    },
    {
      "label": "6 days from now",
      "value": "6"
    },
    {
      "label": "7 days from now",
      "value": "7"
    },
    {
      "label": "8 days from now",
      "value": "8"
    },
    {
      "label": "9 days from now",
      "value": "9"
    }
  ],
  "filterCriteria": []
}

Example thing definition config:

{
  "hourlyForecasts": [
    0,
    1,
    2
  ],
  "latitude": 56,
  "longitude": 12
}

Additional information

Please also have a second look at #643 which also relates to the configuration of this binding, and wasn't resolved bu the suggested fix.

@pacive pacive added bug Something isn't working main ui Main UI labels Jan 27, 2021
@ghys ghys closed this as completed in #874 Feb 5, 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

Successfully merging a pull request may close this issue.

1 participant