openhab / openhab-webui

Web UIs of openHAB
Eclipse Public License 2.0
215 stars 236 forks source link

Default values for widget property parameters are stored as string although type is BOOLEAN #1125

Open BobSilent opened 3 years ago

BobSilent commented 3 years ago

The problem

when setting a default value for a BOOLEAN type property it gets saved as string:

props:
  parameters:
  # my default value
    - name: colorMode
      default: false
      label: Color Mode
      description: Show Color mode as default or Temperature Mode
      required: false
      type: BOOLEAN

as long as the widget editor stays open the default value is a bool, but after closing and re-opening the Editor image

for the widget, the default value is converted to string, also the values gets sorted and any comments gets lost:

props:
  parameters:
    - default: "false"
      description: Show Color mode as default or Temperature Mode
      label: Color Mode
      name: colorMode
      required: false
      type: BOOLEAN

Expected behavior

default value remains type BOOLEAN. The code entered should not be changed or adapted during save as one does not see the result during editing (only after reopening the editor) and code changes are not expected during save

Steps to reproduce

  1. create new widget, and add first code snippet above
  2. Save and exit edit
  3. Open editor again, see result and compare with saved input

Your environment

runtimeInfo:
  version: 3.1.0
  buildString: Release Build
locale: en-DE
systemInfo:
  configFolder: /etc/openhab
  userdataFolder: /var/lib/openhab
  logFolder: /var/log/openhab
  javaVersion: 11.0.11
  javaVendor: Azul Systems, Inc.
  javaVendorVersion: Zulu11.48+21-CA
  osName: Linux
  osVersion: 5.10.17-v7l+
  osArchitecture: arm
  availableProcessors: 4
  freeMemory: 52891024
  totalMemory: 214089728
bindings:
  - astro
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
    prefersColorScheme: dark
  isSecureContext: false
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: N/A
    hardwareConcurrency: 8
    language: en-US
    languages:
      - en-US
      - en
      - de
    onLine: true
    platform: Win32
  screen:
    width: 1920
    height: 1080
    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/91.0.4472.114 Safari/537.36 Edg/91.0.864.54
timestamp: 2021-07-02T10:14:20.761Z

Browser console

Browser network traffic

Additional information

related to changes for #990

helipus commented 9 months ago

2 years later I just recognized the same bug in openHAB 4.0.4. Would be great if someone can fix it.