Combining tcp/udp gpio binding

Hi!

I am new to openhab and would like to ask the community if it is possible to combine the tcp/udp and gpio bindings:

tcp/udp would receive a command and according to the command a certain gpio pin would be set.
Is it possible to configure this via rules?

Hi,

I can’t offer you a ready solution for how to do it, but I don’t see why you couldn’t. I’d go as far as to say that that’s what OpenHAB is built to do.
You’ll need an item that links to the tcp/upd binding and that changes according to the received info. Another item for the gpio binding and as you wrote yourself a rule that changes the “gpio-item” when the “tcp-item” changes.

2 Likes

To close this topic, if someone else starts from scratch here my solution:

I defined the items:

String UDP_IN  "%s"  {udp="<[10.0.0.55:*:'REGEX((.*))']"}  //udp listens for messages from 10.0.0.55
Switch GPIO_W "GPIO_W" { gpio="pin:26" }                   //gpio pin 26 definition

Here the rule:

//if udp input is equal string "K_ON" then gpio pin 26 is set to high
rule "GPIO_SET"
when
  Item UDP_IN changed
then
  if (UDP_IN.state == "K_ON")
  {
    GPIO_W.sendCommand(ON)
  }
end