rule "Ping djecja"
when
Time cron “0 0/1 * * * ?“
then
postUpdate(Status_gDjecja, OFF)
publish(“server”,”/home/djecja/command/ping”,“PING”)
Thread::sleep(1000)
postUpdate(String_Status_gDjecja, Status_gDjecja.state.toString)
end
Where the “server” in the publish action is defined in openhab.cfg as:
mqtt:server.url=tcp://localhost:1883
Mqtt binding is working, I can send and receive messages to switches using the binding, but I cant publish an MQTT message from the rules.
The log file when the rule fires:
2016-02-22 14:20:00.028 [ERROR] [.o.m.r.i.engine.ExecuteRuleJob] - Error during the execution of rule Ping djecja
java.lang.RuntimeException: The name ‘publish(,,)’ cannot be resolved to an item or type.
at org.openhab.model.script.interpreter.ScriptInterpreter.internalFeatureCallDispatch(ScriptInterpreter.java:67) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateAbstractFeatureCall(XbaseInterpreter.java:658) ~[na:na]
at sun.reflect.GeneratedMethodAccessor45.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_95]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_95]
at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291) ~[na:na]
.
.
.
I already searched for the answer, but could not find anything. There is no single reference that I can find in regard to the publish action for MQTT binding that was introduced in version 1.8. Of course, there are other ways to do what I want, like updating a state of an item, but I want to use the publish action since this is there just for this purpose, and I cant get it to work.
I tried with and without quotation marks, without the marks, the error in log is a bit different:
2016-02-22 13:39:00.084 [ERROR] [.o.m.r.i.engine.ExecuteRuleJob] - Error during the execution of rule Ping djecja
java.lang.RuntimeException: The name ‘server’ cannot be resolved to an item or type.
at org.openhab.model.script.interpreter.ScriptInterpreter.internalFeatureCallDispatch(ScriptInterpreter.java:67) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateAbstractFeatureCall(XbaseInterpreter.java:658) ~[na:na]
at sun.reflect.GeneratedMethodAccessor45.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_95]
…