If you want to use the JSON response instead of the XML response, you can easily traverse it with a small JavaScript transform.
your.items
String WeatherAlerts "Alerts [%s]" { http="<[meteoalarm:3600000:JS(meteoalarm.js)]" }
/etc/openhab/configurations/transform/meteoalarm.js:
(function(json) {
var response = JSON.parse(json);
var arr = new Array(response.alerts.length);
for (var i = 0; i < response.alerts.length; i++) {
arr[i] = response.alerts[i].type;
}
return arr.join(", ");
})(input)
(Side note: If you put the quote between a line ```json and a line ```, it gets formatting.)
{
"response": {
"version":"0.1",
"termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
"features": {
"alerts": 1
}
}
,"query_zone": "999",
"alerts": [
{
"type": "FOG",
"wtype_meteoalarm": "4",
"wtype_meteoalarm_name": "Fog",
"level_meteoalarm": "2",
"level_meteoalarm_name": "Yellow",
"level_meteoalarm_description": "The weather is potentially dangerous. The weather phenomena that have been forecast are not unusual, but be attentive if you intend to practice activities exposed to meteorological risks. Keep informed about the expected meteorological conditions and do not take any avoidable risk.",
"description": "\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0009deutsch: Es tritt verbreitet Nebel mit Sichtweiten unter 150 Metern auf.",
"date": "2015-12-27 14:00:00 GMT",
"date_epoch": "NA",
"expires": "2015-12-28 09:00:00 GMT",
"expires_epoch": "NA",
"message": "\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0009deutsch: Es tritt verbreitet Nebel mit Sichtweiten unter 150 Metern auf.)",
"phenomena": "NA",
"significance": "NA",
"attribution": "Information provided by , <a href='http://meteoalarm.eu/'>EUMETNET - MeteoAlarm</a> Note: Time delays between this website and <a href='http://meteoalarm.eu/'>Meteoalarm.eu</a> are possible. For the most up-to-date information about alert levels as published by the participating National Meteorological Services, please visit <a href='http://meteoalarm.eu/'>Meteoalarm</a>. For terms of use of this information, and copyright information, see <a href='http://meteoalarm.eu/'>Meteoalarm</a> Terms of Use."
}
,
{
"type": "WIN",
"wtype_meteoalarm": "6",
"wtype_meteoalarm_name": "Extreme low temperature",
"level_meteoalarm": "2",
"level_meteoalarm_name": "Yellow",
"level_meteoalarm_description": "The weather is potentially dangerous. The weather phenomena that have been forecast are not unusual, but be attentive if you intend to practice activities exposed to meteorological risks. Keep informed about the expected meteorological conditions and do not take any avoidable risk.",
"description": "\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0009deutsch: Es tritt leichter Frost bis -2 °C auf.",
"date": "2015-12-27 17:00:00 GMT",
"date_epoch": "NA",
"expires": "2015-12-28 09:00:00 GMT",
"expires_epoch": "NA",
"message": "\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0009deutsch: Es tritt leichter Frost bis -2 °C auf.)",
"phenomena": "NA",
"significance": "NA",
"attribution": "Information provided by , <a href='http://meteoalarm.eu/'>EUMETNET - MeteoAlarm</a> Note: Time delays between this website and <a href='http://meteoalarm.eu/'>Meteoalarm.eu</a> are possible. For the most up-to-date information about alert levels as published by the participating National Meteorological Services, please visit <a href='http://meteoalarm.eu/'>Meteoalarm</a>. For terms of use of this information, and copyright information, see <a href='http://meteoalarm.eu/'>Meteoalarm</a> Terms of Use."
}
]
}