I’m trying to setup the MQTT 2.5 Eventbus as explained in (this awesome tutorial with Help of DSL Rules. Updates and Status of my Test Item are published just fine to the MQTT Broker. But the “Online” Status Rule:
rule "Eventbus Online" when System started or Thing mqtt:broker:mosquitto changed to ONLINE then logInfo("Reporting eventbus as online") getActions("mqtt", "mqtt:broker:mosquitto").publishMQTT("openhab-remote/status", "ONLINE", True) end
fails compiling. I tried to put the Thing “mqtt:broker:mosquitto” in Variables and Quotes but it still doesnt work. I keep getting Error: Configuration model 'eventbus_online.rules' has errors, therefore ignoring it: [3,46]: no viable alternative at input "mqtt"
Can anyone point me in the right direction? Thank you very much!
You do need to use quotes around a Thing UID, it’s in the docs
rule "Eventbus Online"
when
System started or
Thing "mqtt:broker:mosquitto" changed to ONLINE
then
logInfo("Reporting eventbus as online")
getActions("mqtt", "mqtt:broker:mosquitto")
publishMQTT("openhab-remote/status", "ONLINE", True)
end
I’ve just fixed it in the original tutorial too. Clearly I don’t use the Rules DSL version of the event bus. And for those using the Jython version it’s better to download them from my repo rather than copy/pasteing them. Good eye!
[ERROR] [untime.internal.engine.RuleEngineImpl] - Rule ‘Eventbus Online’: The name ‘True’ cannot be resolved to an item or type; line 8, column 42, length 4
I have now installed and configured VSCode + OHExtension but I see no obvious mistake using the code @rossko57 posted:
rule “Eventbus Online”
when
System started or
Thing “mqtt:broker:mosquitto” changed to ONLINE
then
logInfo(“eventbus startup”, “Reporting eventbus as online”)
getActions(“mqtt”, “mqtt:broker:mosquitto”)
publishMQTT(“remote/status”, “ONLINE”, True)
end