AndrewZ
(Andrew)
1
I’m testing a new controller which can report a temperature over http.
The manual query gives me the following result (no xml):
26.8 C
This is the item definition I use:
Number Webtemp “Room Temperature [%.1f °C]” (Temperatures)
{ http=“<[http://192.168.5.236/gett1.cgi:30000]” }
Please advise on the right transformationrule which will extract the actual temperature value.
Thanks!
watou
(John Cocula)
2
Number Webtemp "Room Temperature [%.1f °C]" (Temperatures)
{ http="<[http://192.168.5.236/gett1.cgi:30000:JS(numonly.js)]" }
You can use this JavaScript transform/numonly.js:
(function(num) {
return num.replace(/[^\d.-]/g,'');
})(input)
AndrewZ
(Andrew)
3
It works, thank you!
I wonder whether it is preferable to REGEX?
watou
(John Cocula)
4
I don’t know if REGEX can substitute or only just extract, but whatever is easy and works!
AndrewZ
(Andrew)
5
From my perspective this should work as a transformationrule but it doesn’t:
REGEX(.*?([0-9]+\.[0-9]).*)
but it works without backslash!