I have a controller which is sending out tcp packets to my openhab server on IP:port combination, from these tcp packets i’m creating items in openhab using the following item config:
The tcp packet looks like item1=A or item1=B or…
This works fine but as all the items use the same tcp channel (192.168.1.121:2000) an update on item2 will trigger item1 as well. The regex doesn’t match so item gets updated to ‘null’ (problem!)
I’m wondering if there is any way to avoid this update to ‘null’ on items that don’t match the regex expression? Basically I only wan’t the item to recieve an update when the regex is not ‘null’. unfortunately changing the port for each item is not an option. I wan’t to avoid this faulty updates as the other items lose their state due to this behavior (I have dozens of these items…).
You will have to have only one Item bound to the socket and then have a Rule that parses out the message data and updates/commands item1, item2, et al as appropriate.
I was mislead by Dries post, though the idea of virtual items helped a lot. I’m reving this old topic, so others are not mislead by the same route.
“>[]” means openhab connects to remote port
“<[]” means other server connects to openhab port
Both of the above opens a tcp or udp, and thus both sends and receives data in a single binding. So in the example where MichVw wants to have the remote end connect to openhab server just one item to rule them all is needed:
Port ‘*’ does not work, and for this global binding we probably don’t want any transformation, but instead just do that in rules, hence the omitted leading command: and the empty transformation at the end.
Hey Rich,
I have a similar setup, where a udp server sends multiple strings (2 strings per room in a house), each string contains some information. I have created an item which receives massages from the udp server. So how to separate them in the rule and update the appropriate item accordingly.
Trigger a rule when the Item changes and write the lines of code to parse out the values from the String received. Then postUpdate or sendCommand those values to the appropriate Items.