telegramAction.sendTelegram fails with ECMAScript 262 Edition 11

Hi,
I am trying to send Telegram messages with ECMAScript 262 Edition 11, but the same rule that works for me in ECMAScript 262 Edition 5.1 fails in Edition 2021. Specifically, I am trying this rule of two lines.

var telegramAction = actions.get("telegram","telegram:telegramBot:<uid>");
telegramAction.sendTelegram( chatId,"hello!!!");

Openhag logs ‘TypeError: (intermediate value).get is not a function’

2023-04-15 20:37:30.270 [WARN ] [.internal.OpenhabGraalJSScriptEngine] - Failed to retrieve script script dependency listener from engine bindings. Script dependency tracking will be disabled.
2023-04-15 20:37:32.599 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script:
org.graalvm.polyglot.PolyglotException: TypeError: (intermediate value).get is not a function

2023-04-15 20:37:32.615 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID '1ee43de896' failed: org.graalvm.polyglot.PolyglotException: TypeError: (intermediate value).get is not a function

Does anyone know if anything needs to be changed in Edition 11?

  • Platform information:
    • Hardware: amd64
    • OS: Linux + Openhab 3.3.0 Container in Docker
    • openHAB version: 3.3
  • Issue of the topic: telegram binding with ECMAScript 262 Edition 11

Lots. The GraalVM add-on comes with a helper library that goes to great lengths to present a pure JS interface to OH. Looking at the docs (JavaScript Scripting - Automation | openHAB) shows the syntax to be

actions.Things.getActions(bindingId, thingUid)

Note, please use code fences when posting code and logs to the forum.

```
code goes here
```
2 Likes

Lots, :-), you are right. I have edited my post and included the code fences.

And yes, the syntax that you posted solves my issue.

Thank you!!