I’m looking for a solution to automatically convert a simple json string to a map file everytime the string item changes.
The Squeezebox Binding provides a comma separated json list which includes the favoritesList from the the server. I’m using a .map file for display purposes in MainUI.
But everytime I change the list on the server I have to manually update the .map file.
My idea is to write a rule which keeps them in sync
check the favoritesList item for changes
on change take the item string and convert "commata" to "linebrakes"
overwrite the existing .map file with the new created list
the first point is a nobrainer…
but I’m not sure how to convert json list to linebrakes and couldn’t find any attemps on the forum search.
and it’s also not so clear to me how to manipulate files through rules. I’m not sure but I think rulesDSL is not capable of that - maybe JSscripting. Or maybe I have to use a bash script to manipulate the json and save the .map file??
Would be very nice to get some help on that, thanks
in short:
convert this
0=ListItem1,1=ListItem2,2=ListItem3
to this
0=ListItem1
1=ListItem2
2=ListItem3
and save it to a .map file in /etc/openhab/transform/