Help setting up Serial Bridge on OH3

Would someone be able to offer some advice? I had this working fine on OH2.5. But I seem to be having problems setting it up with OH3.

It used to be set-up with an .items file

String Currentcost_raw "CurrentCost XML [%s]" { serial="/dev/ttyUSB1@57600" }

This would then populate the string and I would have a rule that would use xpath to get the values from the XML and populate various items.

With OH3 I have moved the serial connection to the .things file as follows:

Bridge serial:serialBridge:currentCost [serialPort="/dev/ttyUSB0", baudRate=57600] { Thing serialDevice displayUnit [patternMatch="REGEX:.*"] { Channels: Type string : rawData [patternMatch="REGEX:.*"] } }

And updated the .items file as follows

String CurrentCostRaw "CurrentCost XML [%s]" { serial="serial:serialDevice:currentCost:displayUnit:rawData" }

The log shows that it connects and I get a serial:serialBridge:currentCost:data triggered PRESSED but the CurrenCost_raw item remains NULL.

Would you know if this is setup correct? I’m struggling with the patterns. I have set .* hoping that will return everything, but it does not. Once I get the hang of this, I am hoping to populate the items via the things file, using regex instead of xpath in the rule. But I’m jumping ahead of myself, as I can’t receive anything at the moment.

Would anyone be able to see what I’m doing wrong? I have been looking at this for many hours!

Thanks.

Well, that was silly! Can you spot the mistake :man_facepalming:. It’s working now! Once I get this all working properly I’ll share it, as it may be of use for others.

1 Like

Hi, please share your things file as well as with site and items.
I’m struggling to send commands and get NULL as well.
Yes, I have “channels” and not serial as in your mistake :wink:

I try to control a projector using the serial binding in openhab 2.5.6.

If I use the “old” way of using the serial commands, it works correctly:
ITEMS:

String viewsonic1projector “Proj [%s]” (gProj) { serial="/dev/ttyUSB1@9600,REGEX(.[A-Z]=(.?)#)" }

SITEMAP

Selection item=viewsonic1projector label=“Proj” mappings=[

                                            "\r*pow=on#\r"="ViewsonicON",

                                            "\r*pow=off#\r"="ViewsonicOFF",

                                            "\r*pow=?#\r"="ViewsonicPowerStatus",

                                            "\r*lampm=eco#\r"="ViewsonicECOmode",

                                            "\r*ltim=?#\r"="ViewsonicLampHours"]

But when I try to use a .THINGS file, all I get is NULL

To keep clear of errors, I tried using exact scheme of the serial binding documentation:

THINGS:

Bridge serial:serialBridge:sensors [serialPort="/dev/ttyUSB1", baudRate=9600] {

Thing serialDevice relay [patternMatch=".*"] {

    Channels:

        Type switch : serialRelay [patternMatch=".*", on="\r*pow=on#\r", off="\r*pow=off#\r"]

}

}

ITEMS:

Switch serialRelay “Relay Q1” (gProj) {channel=“serial:serialDevice:sensors:relay:serialRelay”}

Any input?

Just a note. But when pressing binding information in openhab, the page for binding 1 opens up.
Is there another binding in OH3 that is not available in OH2.5 that utilizes .things file?

Sure it’s here Serial Binding and Current Cost Energy Meter

However, I’m not sure how much it will help. I struggled with getting xpath to work in the things file via channels, so I did it all in rules.

This was for openhab 3, what version are you using? The binding settings changed a lot from 2.