[SOLVED] OH3 http regex stateTransformation help (after upgrade)

I am trying to get the current KW value from my ZeverSolar inverter. I had it working in OH2 but can’t seem to work out the syntax for OH3.

I’m using the .things and .items files. (I did try using the GUI).

This url gets the following text from the inverter (including the new-line character)
http://192.168.1.8/home.cgi

1
1
EAB961753604
6DLSWFHNUXBYSXHY
M11
16B21-663R+16B21-658R
14:44 10/05/2021
OK
1
SX00050101750030
830
17.80
OK
Error

The value I’m after is the 4th last line (830 in this instance).

Previously in OH2, I was able to use this line in .items
String SolarPower “Power [%s Watts]” { http="<[http://192.168.1.8/home.cgi:300000:REGEX((.?\n){11}.)]" }

I was never able to work out how to remove the new-line character, that’s why it is a string and not a number.

This is what I have tried in OH3 (and lots of variations)

.things
Thing http:url:SolarPower “Solarpower” [
baseURL=“http://192.168.1.8/home.cgi”,
refresh=15] {
Channels:
Type string : text “Text” [ stateTransformation=“REGEX:((.?\n){11}.)” ]
}

.items
String SolarPower “Power [%s Watts]” { channel=“http:url:SolarPower:text” }

Any help or pointers would be appreciated.

Thanks
Pete

Try to remove the () like this:

Type string : text “Text” [ stateTransformation=“REGEX:(.*?\n){11}.*” ]

I’ll have to try it in the morning. It’s now dark here and the inverter powers down when there is no sun.

Thanks

Yes, that worked. Thank you.

It is still a string but that’s OK as I have discovered I can use this in rules - “var Number SolarVal = SolarPower.state as Number”

Note: There is two backslash characters before the n in this REGEX:(.?\n){11}.