R19i80k
(Rik)
January 30, 2019, 10:52am
1
Hey,
I do not know how to connect the incoming UDP to five items.
(openHAB2.4 - binding TCP/UDP: binding-tcp1 - 1.13.0)
Can someone help me?
I get data from 5x 1-wire temperature with:
String MyUDP "Udp receive [%s]" {udp="<[192.168.0.12:*:'REGEX((.*))']"}
2019-01-30 11:50:57.096 [vent.ItemStateChangedEvent] - MyUDP changed from rail2 1w 28ffd9266143a3 61.38 to rail2 1w 28eed84a2816116 11.00
2019-01-30 11:51:02.128 [vent.ItemStateChangedEvent] - MyUDP changed from rail2 1w 28eed84a2816116 11.00 to rail2 1w 28ff50f0651439 64.75
2019-01-30 11:51:07.131 [vent.ItemStateChangedEvent] - MyUDP changed from rail2 1w 28ff50f0651439 64.75 to rail2 1w 28fff0e76514384 36.38
2019-01-30 11:51:12.136 [vent.ItemStateChangedEvent] - MyUDP changed from rail2 1w 28fff0e76514384 36.38 to rail2 1w 28ffd2e66514370 65.25
2019-01-30 11:51:17.148 [vent.ItemStateChangedEvent] - MyUDP changed from rail2 1w 28ffd2e66514370 65.25 to rail2 1w 28ffd9266143a3 61.25
vzorglub
(Vincent Regaud)
January 30, 2019, 11:07am
2
Your REGEX is wrong
String MyUDP "Udp receive [%s]" {udp="<[192.168.0.12:*:'REGEX((.*))']"}
The string received from upd is: rail2 1w 28eed84a2816116 11.00
This REGEX: (.*)
returns the whole string so you need to build a REGEX that returns the last value in the string
See:
Regex101 allows you to create, debug, test and have your expressions explained for PHP, PCRE, Python, Golang and JavaScript. The website also features a community where you can share useful expressions.
REGEX(.* .* .* (.*))
should do the job
R19i80k
(Rik)
January 30, 2019, 11:33am
3
Yes that works, thanks.
String MyUDP "Udp receive [%s]" {udp="<[192.168.0.12:*:'REGEX(.* .* .* (.*))']"}
But how do I link to items so that I know where the temperature is coming from.
vzorglub
(Vincent Regaud)
January 30, 2019, 11:52am
4
You need 5 items:
String MyUDPItem1 "Udp receive [%s]" {udp="<[192.168.0.12:*:'REGEX(rail2 1w 28eed84a2816116 (.*))']"}
Etc…
R19i80k
(Rik)
January 30, 2019, 12:31pm
5
Yes it works … after restart.
I changed “string” to “number” because output was only visible during poll.
Number MyUDPItem1 "Tank 1 [%.1f °C]" <temperature> {udp="<[192.168.0.12:*:'REGEX(rail2 1w 28eed84a2816116 (.*))']"}
Number MyUDPItem2 "Tank 2 [%.1f °C]" <temperature> {udp="<[192.168.0.12:*:'REGEX(rail2 1w 28ff50f0651439 (.*))']"}
Number MyUDPItem3 "Tank 3 [%.1f °C]" <temperature> {udp="<[192.168.0.12:*:'REGEX(rail2 1w 28fff0e76514384 (.*))']"}
Number MyUDPItem4 "Tank 4 [%.1f °C]" <temperature> {udp="<[192.168.0.12:*:'REGEX(rail2 1w 28ffd2e66514370 (.*))']"}
Number MyUDPItem5 "Tank 5 [%.1f °C]" <temperature> {udp="<[192.168.0.12:*:'REGEX(rail2 1w 28ffd9266143a3 (.*))']"}
But now get error messages, output in Basic UI is now good.
==> /var/log/openhab2/openhab.log <==
2019-01-30 13:20:58.119 [WARN ] [ing.tcp.protocol.internal.UDPBinding] - Cannot parse input rail2 1w 28eed84a2816116 11.88 to match command 2 on item MyUDPItem3
2019-01-30 13:20:58.129 [WARN ] [ing.tcp.protocol.internal.UDPBinding] - Cannot parse input rail2 1w 28eed84a2816116 11.88 to match command 1 on item MyUDPItem2
==> /var/log/openhab2/events.log <==
2019-01-30 13:20:58.135 [vent.ItemStateChangedEvent] - MyUDPItem1 changed from NULL to 11.88
==> /var/log/openhab2/openhab.log <==
2019-01-30 13:20:58.142 [WARN ] [ing.tcp.protocol.internal.UDPBinding] - Cannot parse input rail2 1w 28eed84a2816116 11.88 to match command 4 on item MyUDPItem5
2019-01-30 13:20:58.151 [WARN ] [ing.tcp.protocol.internal.UDPBinding] - Cannot parse input rail2 1w 28eed84a2816116 11.88 to match command 3 on item MyUDPItem4
2019-01-30 13:21:02.916 [WARN ] [ing.tcp.protocol.internal.UDPBinding] - Cannot parse input rail2 1w 28ff50f0651439 67.25 to match command 0 on item MyUDPItem1
2019-01-30 13:21:02.921 [WARN ] [ing.tcp.protocol.internal.UDPBinding] - Cannot parse input rail2 1w 28ff50f0651439 67.25 to match command 2 on item MyUDPItem3
2019-01-30 13:21:02.928 [WARN ] [ing.tcp.protocol.internal.UDPBinding] - Cannot parse input rail2 1w 28ff50f0651439 67.25 to match command 4 on item MyUDPItem5
2019-01-30 13:21:02.933 [WARN ] [ing.tcp.protocol.internal.UDPBinding] - Cannot parse input rail2 1w 28ff50f0651439 67.25 to match command 3 on item MyUDPItem4
==> /var/log/openhab2/events.log <==
2019-01-30 13:21:02.943 [vent.ItemStateChangedEvent] - MyUDPItem2 changed from NULL to 67.25
==> /var/log/openhab2/openhab.log <==
2019-01-30 13:21:07.945 [WARN ] [ing.tcp.protocol.internal.UDPBinding] - Cannot parse input rail2 1w 28fff0e76514384 63.63 to match command 0 on item MyUDPItem1
2019-01-30 13:21:07.950 [WARN ] [ing.tcp.protocol.internal.UDPBinding] - Cannot parse input rail2 1w 28fff0e76514384 63.63 to match command 1 on item MyUDPItem2
2019-01-30 13:21:07.954 [WARN ] [ing.tcp.protocol.internal.UDPBinding] - Cannot parse input rail2 1w 28fff0e76514384 63.63 to match command 4 on item MyUDPItem5
2019-01-30 13:21:07.959 [WARN ] [ing.tcp.protocol.internal.UDPBinding] - Cannot parse input rail2 1w 28fff0e76514384 63.63 to match command 3 on item MyUDPItem4
==> /var/log/openhab2/events.log <==
2019-01-30 13:21:07.977 [vent.ItemStateChangedEvent] - CurrentDate changed from 2019-01-30T13:20:07.932+0100 to 2019-01-30T13:21:07.935+0100
2019-01-30 13:21:07.982 [vent.ItemStateChangedEvent] - MyUDPItem3 changed from 63.50 to 63.63
==> /var/log/openhab2/openhab.log <==
2019-01-30 13:21:12.972 [WARN ] [ing.tcp.protocol.internal.UDPBinding] - Cannot parse input rail2 1w 28ffd2e66514370 67.75 to match command 0 on item MyUDPItem1
2019-01-30 13:21:12.977 [WARN ] [ing.tcp.protocol.internal.UDPBinding] - Cannot parse input rail2 1w 28ffd2e66514370 67.75 to match command 2 on item MyUDPItem3
2019-01-30 13:21:12.985 [WARN ] [ing.tcp.protocol.internal.UDPBinding] - Cannot parse input rail2 1w 28ffd2e66514370 67.75 to match command 1 on item MyUDPItem2
2019-01-30 13:21:12.991 [WARN ] [ing.tcp.protocol.internal.UDPBinding] - Cannot parse input rail2 1w 28ffd2e66514370 67.75 to match command 4 on item MyUDPItem5
==> /var/log/openhab2/events.log <==
2019-01-30 13:21:13.017 [vent.ItemStateChangedEvent] - MyUDPItem4 changed from 67.50 to 67.75
==> /var/log/openhab2/openhab.log <==
2019-01-30 13:21:18.006 [WARN ] [ing.tcp.protocol.internal.UDPBinding] - Cannot parse input rail2 1w 28ffd9266143a3 60.75 to match command 0 on item MyUDPItem1
2019-01-30 13:21:18.009 [WARN ] [ing.tcp.protocol.internal.UDPBinding] - Cannot parse input rail2 1w 28ffd9266143a3 60.75 to match command 2 on item MyUDPItem3
2019-01-30 13:21:18.012 [WARN ] [ing.tcp.protocol.internal.UDPBinding] - Cannot parse input rail2 1w 28ffd9266143a3 60.75 to match command 1 on item MyUDPItem2
2019-01-30 13:21:18.016 [WARN ] [ing.tcp.protocol.internal.UDPBinding] - Cannot parse input rail2 1w 28ffd9266143a3 60.75 to match command 3 on item MyUDPItem4
==> /var/log/openhab2/events.log <==
2019-01-30 13:21:18.019 [vent.ItemStateChangedEvent] - MyUDPItem5 changed from 60.63 to 60.75
vzorglub
(Vincent Regaud)
January 30, 2019, 12:33pm
6
The udp binding only provides strings if I remember. That’s why you have parsing errors
R19i80k
(Rik)
January 30, 2019, 12:38pm
7
ok, there is a way to keep the output (on Basic GU) until new polling comes?
vzorglub
(Vincent Regaud)
January 30, 2019, 12:43pm
8
Yes, you will need a Number item
Number Item1 "My Item [%.2f]"
and a rule:
rule "Change String to Number"
when
Item MyUDPItem1 changed
then
if (triggeringItem.state != "") {
Item1.postUpdate(Float::parseFloat(triggeringItem.state.toString) as Number)
}
end
And then show the Number item in the GUI instead on the text item
It makes sense to convert to a Number item anyway because then you can do some math with it.
R19i80k
(Rik)
January 30, 2019, 1:29pm
9
Yes, it works. Top! Thanks.
Do you want to change in your reaction “triggeringItem.State ” to “triggeringItem.state ” in the rules.
I received an error message:
2019-01-30 14:22:02.269 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Change String to Number': 'State' is not a member of 'org.eclipse.smarthome.core.items.Item'; line 32, column 9, length 20
2019-01-30 14:22:02.270 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Change String to Number': 'State' is not a member of 'org.eclipse.smarthome.core.items.Item'; line 41, column 9, length 20```
R19i80k
(Rik)
January 30, 2019, 9:40pm
10
I now see that I have errors.
It works well.
2019-01-30 22:37:21.587 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Change String to Number': For input string: "rail2 1w 28eed84a2816116 10.50"
2019-01-30 22:37:21.602 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Change String to Number': For input string: "rail2 1w 28eed84a2816116 10.50"
2019-01-30 22:37:21.619 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Change String to Number': For input string: "rail2 1w 28eed84a2816116 10.50"
2019-01-30 22:37:21.620 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Change String to Number': For input string: "rail2 1w 28eed84a2816116 10.50"
2019-01-30 22:37:21.620 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Change String to Number': For input string: "rail2 1w 28eed84a2816116 10.50"
2019-01-30 22:37:26.613 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Change String to Number': For input string: "rail2 1w 28ff50f0651439 63.50"
2019-01-30 22:37:26.622 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Change String to Number': For input string: "rail2 1w 28ff50f0651439 63.50"
2019-01-30 22:37:26.640 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Change String to Number': For input string: "rail2 1w 28ff50f0651439 63.50"
2019-01-30 22:37:26.635 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Change String to Number': For input string: "rail2 1w 28ff50f0651439 63.50"
2019-01-30 22:37:26.646 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Change String to Number': For input string: "rail2 1w 28ff50f0651439 63.50"
R19i80k
(Rik)
January 31, 2019, 5:48pm
11
Error come up with more than 5 items / rules.
Is there a cause for this?
rossko57
(Rossko57)
February 1, 2019, 12:05am
12
Don’t forget each rule needs a unique name.
R19i80k
(Rik)
February 1, 2019, 7:47am
13
Thank you, that’s better.
I had done before, but also received error messages.
Thinking it was that.
And restarting after adding is apparently necessary.