[SOLVED] UDP command in a rule does not work

Hello!

I am hesitating now since 2 week one one issue:
I am able to send a udp message from my raspberry with OH2 via item:

Switch switch6 “Garage:” [“Lighting”] {udp=">[ON:193.172.2.40:8888:‘MAP(GARAGE.map)’], >[OFF:193.172.2.40:8888:‘MAP(GARAGE.map)’]"}

when i now write a rule and try to send:

rule “Item Roll_EG_Test1”
when
_ Item Roll_EG_Test1 received command_
then
{
_ logInfo(“openhab”,“Test switch 1 pressed.”)_
_ var String mymessage_
_ mymessage = “OFF”_
_ logInfo(“openhab”, “test message sent:” + mymessage)_
_ // executeCommandLine(“bash /etc/openhab2/scripts/UDPsend.sh 2d2d2d”) _
_ udp=">[ON:193.172.2.40:8888:‘MAP(TEST.map)’]" _
}
end

i will get an error message:

2018-01-01 22:13:09.330 [ome.event.ItemCommandEvent] - Item ‘Roll_EG_Test1’ received command UP

2018-01-01 22:13:09.405 [vent.ItemStateChangedEvent] - Roll_EG_Test1 changed from 100 to 0

==> /var/log/openhab2/openhab.log <==

2018-01-01 22:13:09.437 [INFO ] [lipse.smarthome.model.script.openhab] - Test switch 1 pressed.

2018-01-01 22:13:09.476 [INFO ] [lipse.smarthome.model.script.openhab] - test message sent:OFF

18-01-01 22:13:09.492 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Item Roll_EG_Test1’: An error occurred during the script execution: Couldn’t invoke ‘assignValueTo’ for feature JvmVoid: (eProxyURI: default.rules#|::0.2.0.2.0.0.0.4::0::/1)

when i comment the UDP command out i do not get this error message, please anybody who might have a clue please help me on this issue.

Best Regards,
Gregor

I don’t see a declaration of a variable named udp. So therefore, you can’t assign to it.

Hi!

Thanks for that quick reply. Ak okay, UDP should be a message (UDP or TCP), in my rule it is just a variable. (and the rule does not know that this should be the message to send out)
Understand.
Do you have any hint how I could write that in the rule “knows” that this should be a outgoing command of a UDP message from the OH2 (running on a RPI).

Do i need e.g. to use the SendCommand( UDP, “>[ON:193.172.2.40:8888:‘MAP(TEST.map)’]” ) or how can a tell the rule to send a UDP message frame?

Thanks for your support!

So after your comment with the variable:
i have create a item:

String sUdpCommandOut “sUdpCommandOut [%s]” {udp=">[192.168.2.40:8888:‘REGEX((.*))’]"}

and add into the rule

sUdpCommandOut.sendCommand(receivedCommand.toString.toUpperCase)
logInfo(“openhab”, “UDP str is:” + sUdpCommandOut)

and this seems to work.

Thanks for your support and excuse my noob question