MQTT Start Rule error in OH3

RPI4 2Gb, Openhabian,
Could be minor or something I did, but I upgraded my remote OH-2.5.11 to OH3 M5. I use the event Bus and have the following rule:

triggers:
  - id: "0"
    configuration:
      startlevel: 20
    type: core.SystemStartlevelTrigger
  - id: "1"
    configuration:
      thingUID: mqtt:broker:MQTT-Camera
      status: ONLINE
    type: core.ThingStatusChangeTrigger
conditions: []
actions:
  - inputs: {}
    id: script
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: >
        // context: online-1

        logInfo( "events", "Reporting eventbus as online")

        getActions("mqtt", "mqtt:broker:MQTT-Camera").publishMQTT("Camera/status", "ONLINE", true)
    type: script.ScriptAction

and get the following error on start-up. Note however the Status does get changed to ONLINE, so it seems to be transitory. I did not get the error using 2.5.x. Thought I would throw it out there.

2020-12-07 09:28:09.432 [INFO ] [org.openhab.core.model.script.events] - Reporting eventbus as online
2020-12-07 09:28:09.455 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'online-1' failed: 'publishMQTT' is not a member of 'org.openhab.core.thing.binding.ThingActions'; line 7, column 5, length 90 in online
2020-12-07 09:29:02.244 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '192.168.0.212' with clientid Camera
2020-12-07 09:29:02.474 [INFO ] [org.openhab.core.model.script.events] - Reporting eventbus as online
2020-12-07 09:29:02.479 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'online-1' failed: 'publishMQTT' is not a member of 'org.openhab.core.thing.binding.ThingActions'; line 7, column 5, length 90 in online

try something like

val mqttActions = getActions("mqtt", "mqtt:broker:xxxxxxx")
mqttActions.publishMQTT("/lampa-pod-tv/switch/cmd", "get")

edit:

I think, that You put wrong mqtt broker.
mqtt:broker:MQTT-Camera is Your broker name??

There have been some reports that system started rules in Rules DSL are not working. But that may only apply to .rules files.

Also, as Kamil indicates, the Thing ID needs to be for the Broker Thing.

Here is a version that was working last time I checked in my OH system.

It’s JavaScript.

triggers:
  - id: "1"
    label: Mosquitto Broker Thing changes to ONLINE
    configuration:
      thingUID: mqtt:broker:mosquitto
      status: ONLINE
    type: core.ThingStatusChangeTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    label: Publish ONLINE to the LWT topic
    configuration:
      type: application/javascript
      script: >-
        var logger =
        Java.type("org.slf4j.LoggerFactory").getLogger("org.openhab.model.script.Rules.MQTT_Online");

        logger.info("Publishing ONLINE to LWT topic");

        actions.get("mqtt", "mqtt:broker:mosquitto").publishMQTT("openhab3/status", "ONLINE", true);
    type: script.ScriptAction

The big difference is I trigger the rule when the Broker Thing changes state to ONLINE instead of just running it at System started. I will go back at some point and update the MQTT Event Bus tutorial at some point.

Having said all that, if you are using the event bus to connect two OH instances, you should look at the Remote openHAB binding instead. It’s way easier to set up and use.

Thanks for the insights. This is the same form as in the tutorial and has worked for several months on 2.5.(all the names are correct). I also was probably not clear that ONLINE is getting published in OH3 also (verified by MQTT Explorer), it just flings the errors while starting up and is probably related to the DSL rule issue you mentioned, so I can probably drop the system started trigger.

I put so much effort into the 2.5 event bus and it is generally working fine, I hate to start over on the remote OH binding :wink:, although I have read it is easier.