Could someone better than I point me in the right direction.
I would like to publish some MQTT via an ECMA script but have got stuck. I have the broker & binding working together.
(thrilled to have my iPhone reading an NFC and Shortcuts/EasyMQTT sending a MQTT to my broker/OH item)
Have the below but it is not working.
var logger = Java.type("org.slf4j.LoggerFactory").getLogger("org.openhab.model.script.Rules.Experiments");
var ScriptExecution = Java.type("org.openhab.core.model.script.actions.ScriptExecution");
logger.info("MQTT published...")
getActions("mqtt","mqtt:systemBroker:openHab").publishMQTT("test-topic", "test-data", true);
The MQTT binding has an Action as shown in the original post. The only problem with that code is that in JavaScript (and other non-Rules DSL languages) one can’t just call a random OH function like getActions. One has to reference the Object that implements the function.