The problem: There’s a leading space before the figure 1.9 - and the REGEX transformation in OH2 cannot handle this and crashes with a null point exception if I use the standard regex format for all characters (.*?)
I tried it with various variants like this, which should work according to various REGEX-helpers:
.*?<temperature>([0-9+.-]+)</temperature>.*?
Still, I get no valid value into my item. It’s either “NULL” or “-”
This is my item definition:
Number PoolTemp "Pool-Temperatur [%.1f °C]" <pool> {http="<[http://192.168.1.75:80?xml=1:60000:REGEX(.*?<temperature>([0-9.]+)</temperature>.*?)]"}
Sebastian, you’re my hero! It works! Thank you so much!
I tried hundreds of cominbations and tested them on regex101, but now I learned that I have to use double backslashes in openHAB whereas the regex testers I know count double backlashes as error - or interpret them wrong.
as you are such a regex Ninja wondering if you may be able to help with a similar issue I am having. I an receiving the following udp packet from my solar panel monitor
Hi thanks, sorry haven’t managed to try it out for a while then the batteries went flat in the sender but managed to replace them tonight. It did have an affect but sadly still didn’t deliver the value. I have it set up as follows
assuming the syntax is correct I get ‘null’ which is a change from the full string. Also crashes the ios app and I get an internal server error which is fixed when I remove the string from my items file.
event logs just show event change, nothing in openhab.log
2017-10-20 18:04:53.636 [ItemStateChangedEvent ] - TestSensor changed from <solar id='4437191016C3'><timestamp>1508519093</timestamp><current><generating units='w'>241.00</generating><exporting units='w'>0.00</exporting></current><day><generated units='wh'>8623.75</generated><exported units='wh'>2948.97</exported></day></solar> to null
Thanks again for your help on this. Not been able to play with this for a while but still no joy sadly, still displays null in the value and crashes the iPhone app quite spectacularly with a 400 error.
Might have a look at xpath and see if I can do anything with that.