Converting from "Rule DSL" to "ECMAScript"

Hi
This part of my “Rule DSL”-script works:

  1. val mqttActions = getActions(“mqtt”,“mqtt:broker:MQTT”)
  2. mqttActions.publishMQTT(“zigbee2mqtt/078/set”,"{“color”:{“r”:0,“g”:200,“b”:0}}", true)

Can anyone help me converting that into “ECMAScrip”.

Thanx in advance

/Torben

You need an import first. While not exactly what you are looking for, it should get you on the right track.

var Actions = Java.type("org.openhab.core.model.script.actions.Things");
var recordAction = Actions.getActions("ipcamera", "ipcamera:hikvision:FrontDoorCam").recordGIF("ipcamera",6);

You don’t need to type Actions. There is a variable injected into the context called actions you can just use directly.

actions.getAction(...

Even better. Thanks for the tip.

This did the job:

var Actions = Java.type("org.openhab.core.model.script.actions.Things");
var mqttActions = Actions.getActions("mqtt","mqtt:broker:MQTT");
mqttActions.publishMQTT("zigbee2mqtt/078/set","{\"color\":{\"r\":0,\"g\":200,\"b\":0}}");

thanks for the quick feedback to everyone involved