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

[Blockly] Automatically convert event.newItemState et. al. to String #1991

Closed
rkoshak opened this issue Jul 26, 2023 · 0 comments · Fixed by #1992
Closed

[Blockly] Automatically convert event.newItemState et. al. to String #1991

rkoshak opened this issue Jul 26, 2023 · 0 comments · Fixed by #1992
Labels
enhancement New feature or request main ui Main UI

Comments

@rkoshak
Copy link

rkoshak commented Jul 26, 2023

The problem

Everything in a JS Scripting rule in the UI is a JavaScript Class or Object except event which comes over as the raw Java. This means it's exceptionally awkward and counter intuitive to deal with as to treat them the same as, for example, an Item's state one much first know this is happening and then convert the Java State Object to a String.

Your suggestion

Short of fixing this in the JS Scripting add-on, which IIRC isn't possible for UI rules, the next best thing would be if Blockly could convert the State and Command Objects in event to Strings automatically by the contextual info block for "new state of item", "previous state of item" and "received command" (I think the rest are already Strings).

Your environment

runtimeInfo:
  version: 4.1.0
  buildString: "Build #3562"
locale: en-US
systemInfo:
  configFolder: /openhab/conf
  userdataFolder: /openhab/userdata
  logFolder: /openhab/userdata/logs
  javaVersion: 17.0.7
  javaVendor: Debian
  osName: Linux
  osVersion: 5.15.0-78-generic
  osArchitecture: amd64
  availableProcessors: 4
  freeMemory: 225943160
  totalMemory: 1149239296
  startLevel: 70
bindings: null
clientInfo:
  device:
    ios: false
    android: false
    androidChrome: false
    desktop: true
    iphone: false
    ipod: false
    ipad: false
    edge: false
    ie: false
    firefox: false
    macos: true
    windows: false
    cordova: false
    phonegap: false
    electron: false
    nwjs: false
    webView: false
    webview: false
    standalone: false
    os: macos
    pixelRatio: 2
    prefersColorScheme: light
  isSecureContext: false
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: N/A
    hardwareConcurrency: 12
    language: en-US
    languages:
      - en-US
      - en
    onLine: true
    platform: MacIntel
  screen:
    width: 2560
    height: 1440
    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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36
    (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
timestamp: 2023-07-26T19:45:13.155Z

Additional information

As more users of OH 4+ adopt Blockly I think this is going to be more and more of a problem.

@rkoshak rkoshak added enhancement New feature or request main ui Main UI labels Jul 26, 2023
florian-h05 pushed a commit that referenced this issue Jul 27, 2023
Fixes #1991.

Support conversion of event context types itemState, oldItemState,
itemCommand as String or Number by supplying a mutating block with a
choise of Number / String.

Also-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
florian-h05 pushed a commit that referenced this issue Jul 27, 2023
Fixes #1991.

Support conversion of event context types itemState, oldItemState,
itemCommand as String or Number by supplying a mutating block with a
choise of Number / String.

Also-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
(cherry picked from commit edc124e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request main ui Main UI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant