openhab / openhab-webui

Web UIs of openHAB
Eclipse Public License 2.0
221 stars 239 forks source link

Number input field doesn't respect step value #643

Closed pacive closed 3 years ago

pacive commented 3 years ago

The problem

My binding has a need to configure a decimal value with 6 decimals precision, but the input field only allows 2 decimals. After examining the code (not really fluent in js, and not familiar with vue so may have looked in the wrong place), the step parameter in the config-description should be what's decides the precision, otherwise it defaults to step="0.01". I set this to 0.000001, but nothing changes. When I inspect the response to /rest/config-descriptions/{thing-typeUID} however, the parameter is not called step, but stepsize. Might this be what's causing the issue?

Html for the generated input-field:

<input name="latitude" type="number" step="0.01" data-validate="true" class="input-with-value" required="">

Config-description:

    <config-description uri="thing-type:smhi:forecast">
        <parameter name="latitude" type="decimal" step="0.000001" required="true">
            <label>Latitude</label>
            <description>Latitude for the forecast</description>
        </parameter>
...
    </config-description>

Expected behavior

The input field validates according to the step parameter in the config-description.

Steps to reproduce

  1. Install the SMHI-binding Note: The binding included in the distribution doesn't include the step parameter in the config-description, so need to be built from the source-code at my github repo
  2. Create a forecast thing
  3. Enter values for longitude or latitude

Your environment

runtimeInfo:
  version: 3.0.0
  buildString: "Build #2067"
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: 46551096
  totalMemory: 191889408
bindings:
  - 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/87.0.4280.88 Safari/537.36
timestamp: 2020-12-15T08:51:11.940Z

Browser console

Browser network traffic

Response from /rest/config-descriptions/smhi:forecast (channels omitted):

{"configParameters":[{"description":"Latitude for the forecast","label":"Latitude","name":"latitude","required":true,"type":"DECIMAL","stepsize":0.000001,"readOnly":false,"multiple":false,"advanced":false,"verify":false,"limitToOptions":true,"options":[],"filterCriteria":[]},{"description":"Longitude for the forecast","label":"Longitude","name":"longitude","required":true,"type":"DECIMAL","stepsize":0.000001,"readOnly":false,"multiple":false,"advanced":false,"verify":false,"limitToOptions":true,"options":[],"filterCriteria":[]},{"description":"The hourly forecasts to display","label":"Hourly Forecasts","name":"hourlyForecasts","required":false,"type":"INTEGER","readOnly":false,"multiple":true,"advanced":false,"verify":false,"limitToOptions":true,"options":[{"label":"Current hour","value":"0"},{"label":"Next hour","value":"1"},{"label":"2 hours from now","value":"2"},{"label":"3 hours from now","value":"3"},{"label":"4 hours from now","value":"4"},{"label":"5 hours from now","value":"5"},{"label":"6 hours from now","value":"6"},{"label":"7 hours from now","value":"7"},{"label":"8 hours from now","value":"8"},{"label":"9 hours from now","value":"9"},{"label":"10 hours from now","value":"10"},{"label":"11 hours from now","value":"11"},{"label":"12 hours from now","value":"12"},{"label":"13 hours from now","value":"13"},{"label":"14 hours from now","value":"14"},{"label":"15 hours from now","value":"15"},{"label":"16 hours from now","value":"16"},{"label":"17 hours from now","value":"17"},{"label":"18 hours from now","value":"18"},{"label":"19 hours from now","value":"19"},{"label":"20 hours from now","value":"20"},{"label":"21 hours from now","value":"21"},{"label":"22 hours from now","value":"22"},{"label":"23 hours from now","value":"23"},{"label":"24 hours from now","value":"24"}],"filterCriteria":[]},{"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":[]}],"parameterGroups":[],"properties":{},"extensibleChannelTypeIds":[],"UID":"smhi:forecast","label":"SMHI Weather Forecast","description":"Gets weather forecasts from SMHI","listed":true,"supportedBridgeTypeUIDs":[],"bridge":false}

Additional information

pacive commented 3 years ago

After updating my production system to 3.0 I noticed this issue is still present. The thing-type configParameters have stepsize: 0.000001, but the input element still have it set to 0.01.