I need help with the REGEX syntax when it is used in a sitemap. But first some background:
I’m using OpenHabian OH2.4 that is controlling a Volumio internet radio via MQTT. A useful status messages from Volumio gives extensive information on what is playing, which is sent to OH2 in a string item named VolumioStatInfo.
It’s a large string that has several fields. I’d like to extract the title and artist fields from the string in the sitemap rather than with rules. The REGEX transformation add-on binding has been installed.
Here is an example of the contents of the string item:
{"status":"play","position":3,"title":"Wham! - Careless Whisper","artist":"MIX 96","album":null,"albumart":"/albumart?cacheid=265&web=MIX%2096//extralarge","uri":"http://17963.live.streamtheworld.com:80/KYMXFM_SC?DIST=TuneIn&tdtok=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImtpZCI6ImZTeXA4In0.eyJpc3MiOiJ0aXNydiIsInN1YiI6IjIxMDY0IiwiaWF0IjoxNTQyMzQ0NzA2LCJ0ZC1yZWciOmZhbHNlfQ.rQ-4bJC9zzv1oBaIsxnq_HeoDd5A5ZbFqgd-0TT5tnU&TGT=TuneIn","trackType":"webradio","seek":4520588,"duration":0,"samplerate":"","bitdepth":"","channels":2,"random":true,"repeat":true,"repeatSingle":false,"consume":true,"volume":18,"mute":false,"disableVolumeControl":false,"stream":true,"updatedb":false,"volatile":false,"service":"webradio"}
I’d like to use REGEX to extract the title field.In the item string example above it is
"title":"Wham! - Careless Whisper"
The problem:
I tested my REGEX pattern using an online developer tool. It passes the syntax test and provide the correct result, per the screen shot below:
In my sitemap I have this Text item:
Text item=VolumioStatInfo label="Title [REGEX(\"title\": \"(.*?)\"(.*)):%s]"
But it produces an error in the log and the sitemap shows NULL for the value.
Here’s the log error:
2018-11-16 15:43:46.368 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - transformation of type REGEX did not return a valid result
I’ve run out of ideas and need some help with correcting the regex sitemap code.
- Thomas