With the new Thing and the example HTML, which Channels work and which ones do not?
This are the results from the channels:
- http:url:BSB_Interface_Kessel:BSB_Kessel_Brennerstufe1 → OFF value is OK but ON value is not picked up
- http:url:BSB_Interface_Kessel:BSB_Kessel_Brennerstufe2 → OFF value is OK but ON value is not picked up
- http:url:BSB_Interface_Kessel:BSB_Kesselpumpe → OFF value is OK but ON value is not picked up
- http:url:BSB_Interface_Kessel:BSB_AbgastemperaturIst → UNDEF
- http:url:BSB_Interface_Kessel:BSB_AbgastemperaturMax → works
- http:url:BSB_Interface_Kessel:BSB_BrennerLaufzeitStufe_1 → works
- http:url:BSB_Interface_Kessel:BSB_BrennerLaufzeitStufe_2 → works
- http:url:BSB_Interface_Kessel:BSB_KesseltemperaturAktuell → UNDEF
The above HTML example is one where the switches should be turned ON.
Further up the HTML responses in the traces are mainly with the OFF value on the switches.
The regex testers show that should work but something is off. Maybe put the \d
into brackets. And presumably you’d want at least one digit. I’m assuming it’ll only ever be 0 or 255.
.*8300.*:[ \t]+([\d]+).*
Something like this might work too.
.*8300.*:[ \t]+(0|(255)).*
I suspect the *
isn’t working the way we expect in the original. Obviously update all the Switch Channels the same once you find an expression that works.
Working Channel Config:
- id: BSB_AbgastemperaturMax
channelTypeUID: http:number
label: Abgastemperatur Maximum
description: null
configuration:
mode: READONLY
stateTransformation: REGEX:.*8318.*Maximum:[ \t]+(.*)[ \t]+°.*
Not Working Channel Config:
- id: BSB_AbgastemperaturIst
channelTypeUID: http:number
label: Abgastemperatur Istwert
description: null
configuration:
mode: READONLY
stateTransformation: REGEX:.*Istwert:[\s]+(.*)[\d ].*
Differences:
- Missing the
.*8316
at the start - Using
[\s]+
instead of[ \t]+
for the space before the matching group - Matching
[\d ]
after the matching group? Not sure what that’s about.
What happens if you use the same pattern as one that works?
.*8316.*Istwert:[ \t]+(.*)[ \t]+deg&.*
Actually doesn’t change anyting.
If I change
.*Istwert:[\s]+(.*)[\d ].*
to
.*Maximum:[\s]+(.*)[\d ].*
in the cahnels, it is working - obviously picking up the wrong value but proves that the RegEx is kind of
working well.
At the end the question is - why the heck does the Regex transformation not picking up that “Istwert” Regex but the “Maximum” expression.
I already tried to debug the transformation itself to see what’s going in and coming out - but the only DEBUG output I get is that is runs expression on that string. I am missing the result of the operation and cannot judge if there is an issue with that transformation service.
As I got three switch channels I have all three versions now in the config
We’ll see if one of those pick up the right values.
In general I am wondering if there is some kinde of conversion issue between integer and string types exist?
one Step further
I thought I take the REGEX and push the result into a String Channel and look what the REGEX transform service outputs and the results show the issue:
Running this
REGEX:.*Maximum:[\s]+(.*)[\d ]+°.*
Result in the channel:
71.9
That looks pretty good and as expected.
But running this
REGEX:.*Istwert:[\s]+(.*)[\d ]+°.*
The Result in the string is:
45.8 °C </td><td> <input type=text id='value1' VALUE='45.80'></td><td></td></tr> <tr><td> 8318 Diagnose Erzeuger - Abgastemperatur Maximum: 71.9
No wonder that the http:number type is UNDEF with that loong string delivered
An error appears in the logs when that happens, or at least it’s supposed to.
I don’t understand this expression though. In English it says (if I’m interpreting it correctly)
.*Iswert:
Match everything until “Iswert:”[\s]+
Match one or more spaces(.*)[\d ]
Match everything until you see a digit or a space (this part makes no sense, you want the digits inside the matching group) and return everthing up to but not including that digit or space+
Match that digit or space one or more times°.*
Match literally°
and everything after that.
That expression makes no sense given the document. You want to match all the digits until the next space (i.e. [\s]+
).
So - I don’f fully understand why the REGEX service is working as it is working but finally I found REGEX that work.
Here is the final configuration where all channels are working:
UID: http:url:BSB-LAN_Kessel_b2de157d80
label: BSB-LAN Kessel
thingTypeUID: http:url
configuration:
authMode: BASIC
ignoreSSLErrors: false
baseURL: http://192.168.178.15/8300/8301/8304/8310/8316/8318/B
delay: 0
stateMethod: GET
refresh: 30
commandMethod: GET
contentType: text/html
timeout: 10000
bufferSize: 20480
location: Keller
channels:
- id: Kessel_Brennerstufe1
channelTypeUID: http:switch
label: Kessel_brennerstufe1
description: null
configuration:
mode: READONLY
onValue: "255"
offValue: "0"
stateTransformation: REGEX:.*Brennerstufe.T2:[\s]+(\d+).*
- id: Kessel_Brennerstufe2
channelTypeUID: http:switch
label: Kessel_brennerstufe2
description: null
configuration:
mode: READONLY
onValue: "255"
offValue: "0"
stateTransformation: REGEX:.*Brennerstufe.T8:[\s]+(\d+).*
- id: Kesselpumpe
channelTypeUID: http:switch
label: Kesselpumpe
description: null
configuration:
mode: READONLY
onValue: "255"
offValue: "0"
stateTransformation: REGEX:.*Kesselpumpe.Q1:[\s]+([\d\.]+).*
- id: Abgastemperaturist
channelTypeUID: http:number
label: Abgastemperatur Istwert
description: null
configuration:
mode: READONLY
stateTransformation: REGEX:.*Istwert:[\s]+([\d\.]+).*
- id: AbgastemperaturMax
channelTypeUID: http:number
label: Abgastemperatur Maximum
description: null
configuration:
mode: READONLY
stateTransformation: REGEX:.*8318.*Maximum:[\s]+([\d\.]+).*
- id: BrennerLaufzeitStufe_1
channelTypeUID: http:number
label: Brenner Laufzeit Stufe 1
description: null
configuration:
mode: READONLY
stateTransformation: REGEX:.*Brenner Laufzeit Stufe 1:.(\d+).*
- id: BrennerLaufzeitStufe_2
channelTypeUID: http:number
label: Brenner Laufzeit Stufe 2
description: null
configuration:
mode: READONLY
stateTransformation: REGEX:.*Brenner Laufzeit Stufe 2:.(\d+).*
- id: KesseltemperaturAktuell
channelTypeUID: http:number
label: Atkuelle Kesseltemperatur
description: null
configuration:
mode: READONLY
stateTransformation: REGEX:.*8310.*Kesseltemperatur:[\s]+([\d\.]+).*
- id: test
channelTypeUID: http:string
label: TEST
description: null
configuration:
mode: READONLY
stateTransformation: REGEX:.*Brennerstufe.T2:[\s]+(\d+).*
As you see - there is a TEST channel at the end and my learning out of that experience was that such a channel is required to actually capture the result of the REGEX service in a string and verify that the capture group just returns the value selected and not the rest of the line.
At the end I couldn’t figure out what the real issue was behind the different REGEX expressions but would like to thank everyone, especially Rhich Koshak, helping me in getting this solved.