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] Contextual info 'event available' throws error instead of 'false' #3102

Open
maxmaximax opened this issue Mar 10, 2025 · 0 comments
Labels
bug Something isn't working main ui Main UI

Comments

@maxmaximax
Copy link

maxmaximax commented Mar 10, 2025

The problem

An error is thrown when a rule calls another rule and 'event available' is used as contexual info.

Rule 1:
Image

console.info('Rule fired ... (something...)');
console.info((event !== undefined));
console.info(event.type);
rules.runRule('test_blockly_something_else', {});
console.info('Rule finished ... (something...)');

… runs Rule 2:
Image

console.info('Rule fired ... (something else...)');
console.info((event !== undefined));
console.info('Rule finished ... (something else...)');

Log:

2025-03-01 21:14:00.815 [INFO ] [ion.script.ui.test_blockly_something] - Rule fired ... (something...)
2025-03-01 21:14:00.815 [INFO ] [ion.script.ui.test_blockly_something] - true
2025-03-01 21:14:00.815 [INFO ] [ion.script.ui.test_blockly_something] - ExecutionEvent
2025-03-01 21:14:00.816 [INFO ] [cript.ui.test_blockly_something_else] - Rule fired ... (something else...)
2025-03-01 21:14:00.817 [ERROR] [.handler.AbstractScriptModuleHandler] - Script execution of rule with UID 'test_blockly_something_else' failed: org.graalvm.polyglot.PolyglotException: ReferenceError: "event" is not defined
2025-03-01 21:14:00.817 [INFO ] [ion.script.ui.test_blockly_something] - Rule finished ... (something...)

Refer to:
https://community.openhab.org/t/oh-4-0-1-javascript-ecmascript-2021-always-defines-event-object-in-an-rule/148529/3?u=maxmaximax

Expected behavior

'event available' in rule 2 should return 'false' instead of the error

Steps to reproduce

Use the Blockly I posted above.

Your environment

runtimeInfo:
  version: 4.3.2
  buildString: Release Build
locale: de-AT
systemInfo:
  configFolder: /etc/openhab
  userdataFolder: /var/lib/openhab
  logFolder: /var/log/openhab
  javaVersion: 17.0.13
  javaVendor: Azul Systems, Inc.
  javaVendorVersion: Zulu17.54+21-CA
  osName: Linux
  osVersion: 6.8.0-52-generic
  osArchitecture: amd64
  availableProcessors: 4
  freeMemory: 284622000
  totalMemory: 762314752
  uptime: 255927
  startLevel: 100
addons:
  - automation-groovyscripting
  - automation-jsscripting
  - binding-avmfritz
  - binding-daikin
  - binding-denonmarantz
  - binding-enigma2
  - binding-exec
  - binding-homeconnect
  - binding-hue
  - binding-ipcamera
  - binding-kostalinverter
  - binding-loxone
  - binding-mail
  - binding-modbus
  - binding-mqtt
  - binding-netatmo
  - binding-network
  - binding-opensprinkler
  - binding-openweathermap
  - binding-speedtest
  - binding-systeminfo
  - misc-openhabcloud
  - persistence-influxdb
  - persistence-mapdb
  - persistence-rrd4j
  - transformation-exec
  - transformation-jsonpath
  - transformation-map
  - transformation-regex
  - transformation-scale
  - transformation-xpath
  - transformation-xslt
  - ui-basic
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.350000023841858
    prefersColorScheme: dark
  isSecureContext: false
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: N/A
    hardwareConcurrency: 8
    language: de-DE
    languages:
      - de-DE
      - de
      - en-US
      - en
    onLine: true
    platform: Win32
  screen:
    width: 1707
    height: 1067
    colorDepth: 24
  support:
    touch: false
    pointerEvents: true
    observer: true
    passiveListener: true
    gestures: false
    intersectionObserver: true
  themeOptions:
    dark: light
    filled: true
    pageTransitionAnimation: default
    bars: light
    homeNavbar: default
    homeBackground: default
    expandableCardAnimation: default
    blocklyRenderer: thrasos
  userAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,
    like Gecko) Chrome/133.0.0.0 Safari/537.36
timestamp: 2025-03-10T21:08:57.637Z
@maxmaximax maxmaximax added bug Something isn't working main ui Main UI labels Mar 10, 2025
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

No branches or pull requests

1 participant