Hardware: RaspBerry Pi 3b
OS: latest stable OpenHABian
openHAB version: 2.5.9
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"
System started or
Thing "mqtt:broker:mosquitto" changed to ONLINE
logInfo("Reporting eventbus as online")
publishMQTT("openhab-remote/status", "ONLINE", True)
That’s what I thought. Still I’m getting a:
[ERROR] [untime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule ‘Eventbus Online’: index=1, size=1
I have tried passing the UID via Variable, but keep getting the same Error…
That’s never going to work.
Now I notice the logInfo is broken - you can’t tell that from the error message except by experience. Two parameters required -
logInfo("eventbusStartup", "Reporting eventbus as online")
Using VSCode + openHAB extension as a rule editor will pick up a lot of syntax errors
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!
Thank you so much for your Help!
Seems like my Syntax is still broken, I get:
[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”
System started or
Thing “mqtt:broker:mosquitto” changed to ONLINE
logInfo(“eventbus startup”, “Reporting eventbus as online”)
publishMQTT(“remote/status”, “ONLINE”, True)
Lower case “t” for True:
true. I’ve also gone in and fixed this in the original tutorial just now.