Forward item to UDP binding


I’ve started to play with OpenHAB and try to do a simple thing IMHO. I have a Netatmo weather station and I want to forward its reading to other system through an UDP socket. What is the natural way to do this in OpenHAB? Should I use rule, action, persistence? Any example would be helpful.

Kind regards,

I recommend starting by reading this page which will explain a little bit about how OH is put together and what each of the major parts are and what they do.

Using OH as a forwarder is a little unusual of a use case but should be possible.

You would use Items bound to the Neatamo binding to retrieve the data. You then have options:

  1. Add an additional outgoing binding to the TCP/UDP Binding to these Items. Any incoming updates from Neatamo will automatically be forwarded to the TCP/UDP Socket as configured.

  2. Create a separate Item bound to the TCP/UDP Socket Binding and write a rule that triggers on updates to the Netatmo Items and sends the value to the TCP/UDP Items using sendCommand.

I always thought this is the most usual function in openHAB as option 1 - one item but two bindings - is the usual way to put time and date from ntp to knx :wink:

Maybe it depends on the technologies being used. Since I have mainly zwave, Nest, and DIY devices I’ve never actually had the need to just forward things through OH unmodified or without some other OH processing in a rule.

I also have an aversion to mixing my bindings on a single Item. I clearly see the power of doing that but debugging seems like it would be a major pain and if it doesn’t work on the first try I would probably end up just writing a rule anyway in order to break it down and figure out what is wrong. In fact this is also the reason why I’ve abandoned the Exec binding and simply always just use a Rule now. But that is just me, and of the many opinions I push on this forum, it is one I tend not to argue about.

Thank you Rich for the tips.

Just to explain you what I’m doing. I’m in fact a hard core Openremote user and my all automation is done there. However, as OpenHAB has some protocol adaptors, which lack in Openremote, I thought of quick hack of running OpenHAB as data forwarder. Rewriting of 1000+ rules which I have in Openremote’s Drools to OpenHAB rules would be a major task.

Anyway, I’ve tried #1 without success. Perhaps there are some syntax errors which I don’t understand now. The TCP/UDP binging explanation is a bit dense to me. I’ve created the following item:

Number Netatmo_Indoor_Humidity "Indoor Humidity [%d %%]" (Netatmo, GF_Living) {netatmo="70:ea:51:03:ab:1a#Humidity", {udp=">['REGEX((.*))']"} }

Can you help me with the correct udp output binding command? Probably I miss something stupid obvious, which won’t be a problem when I learn OpenHAB a bit more.


Too many Brackets :slight_smile:

Number Netatmo_Indoor_Humidity "Indoor Humidity [%d %%]" (Netatmo, GF_Living {netatmo="70:ea:51:03:ab:1a#Humidity", udp=">['REGEX((.*))']"}

I don’t know if REGEX is the correct way for outbound communication, though.

@Udo_Hartmann, according to the wiki both inbound and outbound can have a transformation so that should be fine.

I’m going to guess the problem is the extra curly bracket at this point, at least until proven otherwise.

Yes, the extra curly brackets were the problem, copy/paste. I’ve corrected this and got the following in the log:

2016-04-15 13:57:03.022 [INFO ] [AbstractDatagramChannelBinding] - 'Connecting' the channel Channel [item=Netatmo_Indoor_Humidity, command=0, direction=OUT, remote=/, buffer=, isBlocking=false, isReconnecting=false, channel=, host=, port=6666]

However, when I listen on my remote host there is no traffic on the UDP socket from OpenHAB. I’ve tested the socket with nc so it should receive something. The Netatmo_Indoor_Humidity item is updating nicely on UI but nothing is send to the UDP socket. How can I debug this issue? Should I configure something more to get it going?

I’ve no experience with either of these bindings so I won’t be much helps.

In general the best way to debug a problem like this is to break it down into tiny steps to discover where the problem is happening. So I would separate the netamo and the UDP bindings into separate Items and write a rule to forward the changes from netamo to the UDP Item.