Ok, unfortunately I’m still having the same issue on the receiver/main openhab/subscriber. I’m still seeing my helloworld script running every 10 seconds so I think I may be good with the Helper Libraries install (these are the steps I did JSR223 Helper Libraries/ Jython Support Install Guide - openHAB 2.5 (WIP) )
Download scripts: From here, click GitHub pull request link->Commits tab->“<>” symbol to “Browse the repository at this point in history”->Clone or Download zip link
Copy /Community/MQTT Eventbus/automation/lib/python/configuration.py.example → /etc/openhab2/automation/lib/python/configuration.py (Rename existing to *.ORIG ?? Need it?)
Merge contents of /Community/MQTT Eventbus/automation/lib/python/configuration.py.example WITH /etc/openhab2/automation/lib/python/configuration.py & edit PUBLISHER or SUBSCRIBER sections as applicable
2020-01-21 18:50:57.306 [INFO ] [ome.model.script.SubscribeMQTT.rules] - Subscribe update to the event bus
2020-01-21 18:50:57.310 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Subscribe for commands and updates from the event bus’: ‘split’ is not a member of ‘org.eclipse.smarthome.core.thing.events.ChannelTriggeredEvent’; line 8, column 20, length 24
2020-01-21 18:50:57.464 [vent.ChannelTriggeredEvent] - mqtt:broker:40b306d8:openhab1 triggered openhab2_EB/out/Multisensor_Humidity/state#32
2020-01-21 18:50:57.472 [INFO ] [ome.model.script.SubscribeMQTT.rules] - Subscribe update to the event bus
2020-01-21 18:50:57.477 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Subscribe for commands and updates from the event bus’: ‘split’ is not a member of ‘org.eclipse.smarthome.core.thing.events.ChannelTriggeredEvent’; line 8, column 20, length 24
2020-01-21 18:51:00.329 [DEBUG] [e.automation.internal.RuleEngineImpl] - The trigger ‘Time_cron_0_10_2b96c3003cb111ea867bdca6322133ca_2bf0068f3cb111eabc22dca6322133ca’ of rule ‘2d5e4294-5f63-4cd4-8346-a81fda7709f8’ is triggered.
2020-01-21 18:51:00.334 [.event.RuleStatusInfoEvent] - 2d5e4294-5f63-4cd4-8346-a81fda7709f8 updated: RUNNING
2020-01-21 18:51:00.356 [INFO ] [Jython Hello World (cron decorators)] - Hello World!
2020-01-21 18:51:00.358 [DEBUG] [e.automation.internal.RuleEngineImpl] - The rule ‘2d5e4294-5f63-4cd4-8346-a81fda7709f8’ is executed.
2020-01-21 18:51:00.360 [.event.RuleStatusInfoEvent] - 2d5e4294-5f63-4cd4-8346-a81fda7709f8 updated: IDLE
I will stop saying anything along these lines. It seemed clear that acceptance of this pr above was all that was missing to get to install it through the usual add-ons mechanism, since oh 2 5 add-on development is continuing.
It also seemed clear that if python was going to become the default and Rules DSL completely eliminated that Python would just come with OH 3.
I’m getting lies of mixed messages regarding where this is all going so I’ll just shut up.
If your see that then your Python is installed and working. Reply in the event bus thread and we will debug further there.
You know I’ll be your guinea pig…and good or bad…give feedback And when were done it’ll support NOOBS that never even heard of an event bus or Jython! lol We can either do it here or PM. Thank you Rich!
I’ve rewritten the OP to include the Python example rather than just the link to the PR on the Helper Libraries. See if you can follow the new tutorial as written above to copy over the Rules and get them to run.
Works like a charm. Thanks Rich for your patience!
(For new readers, my Rules DSL error ‘split’ is not a member of ‘org.eclipse.smarthome.core.thing.events.ChannelTriggeredEvent’ is now resolved via Richs OP.)
The “Subscribing” DSL code has a string detokenization bug if users configure their subscription channels in accordance with the screen shot (ie “#” as the “Separator Character”). The fix is:
var topic = receivedEvent.toString.split("#").get(0)
var state = receivedEvent.toString.split("#").get(1)
val itemName = topic.split("/").get(2)
val type = topic.split("/").get(3)
Post the full error. Post the Rule as you have it implemented. If it happens again, file an issue on the MQTT binding. This isn’t directly related to the Event Bus rules, it’s something going on in the MQTT binding.
Sometimes this kind of thing turns out to be a variation on the file load time sequence issue.
If the “get actions” is a global, it gets executed during the chaos of startup, relying on binding and Things to be ready.
If its local in the rule, it should work better when that is the issue.
These are the rules that i’m running to communicate to the cloud mqtt and to the local mqtt:
rule "Publish updates to the local and cloud event bus"
when
Member of PubItems received update
then
val mqttActionsLocal = getActions("mqtt","mqtt:broker:local")
mqttActionsLocal.publishMQTT("/bus/out/"+triggeringItem.name+"/state",triggeringItem.state.toString,true)
val mqttActionsCloud = getActions("mqtt","mqtt:broker:cloud")
mqttActionsCloud.publishMQTT("/bus/43193719-F06E-4045-82E8-CF145AA7DB04/out/"+triggeringItem.name+"/state",triggeringItem.state.toString,true)
end
rule "Subscribe for commands and updates from the local event bus"
when
Channel 'mqtt:broker:local:bus' triggered
then
val itemName = receivedEvent.toString.split("/").get(3)
val type = receivedEvent.toString.split("/").get(4)
val state = receivedEvent.toString.split("#").get(1)
if(type == "command") sendCommand(itemName, state)
else postUpdate(itemName, state)
end
rule "Subscribe for commands and updates from the cloud event bus"
when
Channel 'mqtt:broker:cloud:bus' triggered
then
val itemName = receivedEvent.toString.split("/").get(4)
val type = receivedEvent.toString.split("/").get(5)
val state = receivedEvent.toString.split("#").get(1)
if (type == "command") sendCommand(itemName, state)
else postUpdate(itemName, state)
end
The full error that i get is this:
Rule ‘Publish updates to the local and cloud event bus’: Instance is not an MQTTActions class.
Like you already noticed, i did a few changes to the example above becausse i’m sending updates and recieving commands to/from 2 mqtt brokers (one localy and one in the cloud)
The wierd thing is that when i did a restart of the whole system it didn’t help
when i disabled the broker thing and enabled it back it was working fine again, and no error’s so far…
This happend 3 times so far.
Oh, today i have the same error when starting the rule:
2020-04-23 22:31:41.188 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Request ZigBee Network Map in Graphviz format': Instance is not an MQTTActions class.
val mqttActions=getActions("mqtt", "mqtt:broker:mosquitto")
rule "Request ZigBee Network Map in Graphviz format"
when
Time cron "0 1 * * * ?" or
Item zigbee_NetworkUpdate received command ON
then
// ask zigbee2mqtt to generate graphviz network map (in DOT format)
mqttActions.publishMQTT("zigbee2mqtt/bridge/networkmap", "graphviz")
logInfo("zigbee_map", "DotFileState: " + zigbee_NetworkMap.state)
end
This rule working more then one year without any errors…until today (
OK, so it’s far better to post a new thread rather than reopening an old thread that has nothing to do with your problem.
But, if you are using the OP as an example for how to use the publishMQTT Action, you will notice a difference between your Rule and the example Rules above. The call to getActions and saving that to mqttActions is done inside the Rule. Try doing the same.