openhab / openhab-webui

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

Number channel cannot be linked to Switch Item (with profile) #1478

Closed ssalonen closed 2 months ago

ssalonen commented 2 years ago

The problem

When linking a Number channel, it is impossible to select Switch item to link to

I use profile to transform the numbers to ON/OFF type.

As a workaround, it is possible to change item type temporarily to Number, do the channel link, and revert item type back to Switch.

Expected behavior

UI would not filter out items of different type when linking channels. Thanks to profiles, otherwise "incompatible" types should be linkable.

Steps to reproduce

Your environment

runtimeInfo:
  version: 3.3.0
  buildString: Release Build
locale: fi-FI
systemInfo:
  configFolder: /etc/openhab
  userdataFolder: /var/lib/openhab
  logFolder: /var/log/openhab
  javaVersion: 11.0.15
  javaVendor: Raspbian
  osName: Linux
  osVersion: 5.15.32-v7l+
  osArchitecture: arm
  availableProcessors: 4
  freeMemory: 81427080
  totalMemory: 372244480
  startLevel: 100
bindings:
  - fmiweather
  - modbus
  - network
  - shelly
  - systeminfo
  - zwave
clientInfo:
  device:
    ios: true
    android: false
    androidChrome: false
    desktop: false
    iphone: true
    ipod: false
    ipad: false
    edge: false
    ie: false
    firefox: false
    macos: false
    windows: false
    cordova: false
    phonegap: false
    electron: false
    nwjs: false
    os: ios
    osVersion: 15.6.1
    webView: true
    webview: true
    standalone: true
    pixelRatio: 3
    prefersColorScheme: dark
  isSecureContext: true
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: N/A
    hardwareConcurrency: 4
    language: en-GB
    languages:
      - en-GB
    onLine: true
    platform: iPhone
  screen:
    width: 390
    height: 844
    colorDepth: 32
  support:
    touch: true
    pointerEvents: true
    observer: true
    passiveListener: true
    gestures: true
    intersectionObserver: true
  themeOptions:
    dark: dark
    filled: true
    pageTransitionAnimation: default
    bars: light
    homeNavbar: default
    homeBackground: default
    expandableCardAnimation: default
  userAgent: Mozilla/5.0 (iPhone; CPU iPhone OS 15_6_1 like Mac OS X)
    AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148
timestamp: 2022-08-24T04:24:27.134Z

Browser console

Browser network traffic

Additional information

ssalonen commented 2 years ago

@rkoshak thoughts on this one? Does this make from core architecture point of view?

I find the ability to transform channel of type X to item of type Y using profiles is really powerful. It seems to work now (UI config workaround described in the first post) but I am not sure how officially supported it is.

rkoshak commented 2 years ago

I agree with this one. There are a number of new things that recent changes to Profiles have made possible that are not accounted for in MainUI. In particular the ability to change the type of the Item from a Number to a Switch (for example) which, prior to 3.2 (maybe even as recent as 3.3) was not possible.

I think MainUI is simply lagging behind those changes and needs to be updated.

Edit to note that I've been pushing for the ability to change the Item type like this periodically for a very long time (at least as far back as OH 2.0). I've always been annoyed that the Network Status binding followed by the Network binding shows the online/offline state of a network device using a Switch instead of a Contact. I'm super happy that we finally have this ability.

ssalonen commented 1 year ago

Easy would be to remove the item filter in https://github.com/openhab/openhab-webui/blob/d915c8aec96a1959b8b97b161ac9c7dd74224e47/bundles/org.openhab.ui/web/src/pages/settings/things/link/link-add.vue#L39

Is there more user friendly way to handle this?

ssalonen commented 1 year ago

Would PR be accepted to remove the item filter? I do understand the downsides with this as well.

As I was working on https://github.com/openhab/openhab-addons/issues/14058, I hit this issue once again. In modbus 4.0 I was planning to offer one channel, meant to offer the data as percent (%).

Now due to this UI limitation, it seems I should either

ssalonen commented 1 year ago

For now, I am resorting to advicing user to work-around the issue in docs:

Check out README at https://github.com/ssalonen/openhab2-addons/tree/modbus-14058/bundles/org.openhab.binding.modbus (ctrl+f search with "due to MainUI limitation"). Perhaps worst example is the one with Rollershutter Item: https://github.com/ssalonen/openhab2-addons/tree/modbus-14058/bundles/org.openhab.binding.modbus#rollershutter-example

florian-h05 commented 2 months ago

I have just created a draft PR to finally address this issue: #2690. Please have a look and check if my logic there is correct.