var String newStart = transform("JSONPATH", "$.start", newString)
var DateTime time = new DateTime(Long::parseLong(newStart))
DWD_Unwetter_start.postUpdate(new DateTimeType(time.toString))
rule "Unwetterwarnung DWD"
when
Time cron "0 * * ? * *"
then
var String jsonString = sendHttpGetRequest("https://www.dwd.de/DWD/warnungen/warnapp/json/warnings.json")
jsonString = transform("JS", "getDWDjson.js", jsonString)
DWD_Unwetter_start.postUpdate(transform("JSONPATH","$start",jsonString))
DWD_Unwetter_end.postUpdate(transform("JSONPATH","$end",jsonString))
DWD_Unwetter_level.postUpdate(transform("JSONPATH","$level",jsonString))
DWD_Unwetter_description.postUpdate(transform("JSONPATH","$description",jsonString))
DWD_Unwetter_headline.postUpdate(transform("JSONPATH","$headline",jsonString))
DWD_Unwetter_instruction.postUpdate(transform("JSONPATH","$instruction",jsonString))
DWD_Unwetter_event.postUpdate(transform("JSONPATH","$event",jsonString))
DWD_Unwetter_last_update.postUpdate(new DateTimeType())
end
my transformation:
(function(jsonString) {
var newString = jsonString.replace('warnWetter.loadWarnings(','');
newString = newString.replace(');','');
var newJSON = JSON.parse(newString);
var jsonResult = "";
if (newJSON.warnings.hasOwnProperty('501000008')) {
jsonResult =JSON.stringify(newJSON.warnings['501000008'][0]);
} else jsonResult = 'NULL'
return jsonResult;
})(input)
and my sitemap:
Text item=DWD_Unwetter_start
Text item=DWD_Unwetter_end
Text item=DWD_Unwetter_level
Text item=DWD_Unwetter_description
Text item=DWD_Unwetter_headline
Text item=DWD_Unwetter_instruction
Text item=DWD_Unwetter_event
As @vzorglub already stated, i don’t think that this is possible.
You could of course do some string magic and split up the Description to several parts that would fit into basic ui and use several String items for that.
But that is plenty of additional work of course.
Hi, I’m glad you found a solution. I went a totally different way the last few days, and maybe it’s interesting for somebody.
I dont’s use the json file of the DWD, but the xml files which are on a municipality level (Gemeinde statt Landkreis). I display up to 3 different warnings, my dashboard you can see here:
I think the best way would be via xslt, but I didn’t get that to work, that’s why I use a shell script (I’m more familiar with )
I use the following items:
They get updated by the following shell sript (triggered every 5 Minutes via rule or crontab) - warncellid to be adjusted, the number between the two “%27” - starting with an 8
# check current value of Warnung_1_Event
value_old=$(curl -s "http://openhabianpi:8080/rest/items/DWD_Warnung_1_Event/state")
# download xml for warncellid or ids
rm /etc/openhab2/html/dwd/warnings.xml
wget -q -O /etc/openhab2/html/dwd/warnings.xml "https://maps.dwd.de/geoserver/dwd/ows?service=WFS&version=2.0.0&request=GetFeature&typeName=dwd:Warnungen_Gemeinden&CQL_FILTER=WARNCELLID%20IN%20(%27800000000%27)"
if [ ! -s /etc/openhab2/html/dwd/warnings.xml ]; then
echo "xml-Datei ist leer. Vermutlich kein Internet. Ich geh wieder schlafen..."
exit
fi
#
# Events
value=$(</etc/openhab2/html/dwd/warnings.xml awk -F"<dwd:EVENT>" '{print $2}' | awk -F"</dwd:EVENT>" '{print $1}')
if [ -n "$value" ]; then
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "$value" "http://openhabianpi:8080/rest/items/DWD_Warnung_1_Event/state"
else
if [ "$value_old" = "0" ]; then
# echo "Keine Warnung gefunden, Wert in OH ist schon 0, ich geh wieder schlafen..."
exit
fi
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "0" "http://openhabianpi:8080/rest/items/DWD_Warnung_1_Event/state"
fi
value=$(</etc/openhab2/html/dwd/warnings.xml awk -F"<dwd:EVENT>" '{print $3}' | awk -F"</dwd:EVENT>" '{print $1}')
if [ -n "$value" ]; then
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "$value" "http://openhabianpi:8080/rest/items/DWD_Warnung_2_Event/state"
else
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "0" "http://openhabianpi:8080/rest/items/DWD_Warnung_2_Event/state"
fi
value=$(</etc/openhab2/html/dwd/warnings.xml awk -F"<dwd:EVENT>" '{print $4}' | awk -F"</dwd:EVENT>" '{print $1}')
if [ -n "$value" ]; then
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "$value" "http://openhabianpi:8080/rest/items/DWD_Warnung_3_Event/state"
else
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "0" "http://openhabianpi:8080/rest/items/DWD_Warnung_3_Event/state"
fi
#
# Severity
value=$(</etc/openhab2/html/dwd/warnings.xml awk -F"<dwd:SEVERITY>" '{print $2}' | awk -F"</dwd:SEVERITY>" '{print $1}')
if [ -n "$value" ]; then
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "$value" "http://openhabianpi:8080/rest/items/DWD_Warnung_1_Severity/state"
else
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "0" "http://openhabianpi:8080/rest/items/DWD_Warnung_1_Severity/state"
fi
value=$(</etc/openhab2/html/dwd/warnings.xml awk -F"<dwd:SEVERITY>" '{print $3}' | awk -F"</dwd:SEVERITY>" '{print $1}')
if [ -n "$value" ]; then
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "$value" "http://openhabianpi:8080/rest/items/DWD_Warnung_2_Severity/state"
else
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "0" "http://openhabianpi:8080/rest/items/DWD_Warnung_2_Severity/state"
fi
value=$(</etc/openhab2/html/dwd/warnings.xml awk -F"<dwd:SEVERITY>" '{print $4}' | awk -F"</dwd:SEVERITY>" '{print $1}')
if [ -n "$value" ]; then
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "$value" "http://openhabianpi:8080/rest/items/DWD_Warnung_3_Severity/state"
else
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "0" "http://openhabianpi:8080/rest/items/DWD_Warnung_3_Severity/state"
fi
#
# Start
value=$(</etc/openhab2/html/dwd/warnings.xml awk -F"<dwd:ONSET>" '{print $2}' | awk -F"</dwd:ONSET>" '{print $1}')
if [ -n "$value" ]; then
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "$value" "http://openhabianpi:8080/rest/items/DWD_Warnung_1_Start/state"
else
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "2000-01-01T00:00:00Z" "http://openhabianpi:8080/rest/items/DWD_Warnung_1_Start/state"
fi
value=$(</etc/openhab2/html/dwd/warnings.xml awk -F"<dwd:ONSET>" '{print $3}' | awk -F"</dwd:ONSET>" '{print $1}')
if [ -n "$value" ]; then
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "$value" "http://openhabianpi:8080/rest/items/DWD_Warnung_2_Start/state"
else
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "2000-01-01T00:00:00Z" "http://openhabianpi:8080/rest/items/DWD_Warnung_2_Start/state"
fi
value=$(</etc/openhab2/html/dwd/warnings.xml awk -F"<dwd:ONSET>" '{print $4}' | awk -F"</dwd:ONSET>" '{print $1}')
if [ -n "$value" ]; then
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "$value" "http://openhabianpi:8080/rest/items/DWD_Warnung_3_Start/state"
else
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "2000-01-01T00:00:00Z" "http://openhabianpi:8080/rest/items/DWD_Warnung_3_Start/state"
fi
#
# End
value=$(</etc/openhab2/html/dwd/warnings.xml awk -F"<dwd:EXPIRES>" '{print $2}' | awk -F"</dwd:EXPIRES>" '{print $1}')
if [ -n "$value" ]; then
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "$value" "http://openhabianpi:8080/rest/items/DWD_Warnung_1_End/state"
else
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "2000-01-01T00:00:00Z" "http://openhabianpi:8080/rest/items/DWD_Warnung_1_End/state"
fi
value=$(</etc/openhab2/html/dwd/warnings.xml awk -F"<dwd:EXPIRES>" '{print $3}' | awk -F"</dwd:EXPIRES>" '{print $1}')
if [ -n "$value" ]; then
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "$value" "http://openhabianpi:8080/rest/items/DWD_Warnung_2_End/state"
else
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "2000-01-01T00:00:00Z" "http://openhabianpi:8080/rest/items/DWD_Warnung_2_End/state"
fi
value=$(</etc/openhab2/html/dwd/warnings.xml awk -F"<dwd:EXPIRES>" '{print $4}' | awk -F"</dwd:EXPIRES>" '{print $1}')
if [ -n "$value" ]; then
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "$value" "http://openhabianpi:8080/rest/items/DWD_Warnung_3_End/state"
else
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "2000-01-01T00:00:00Z" "http://openhabianpi:8080/rest/items/DWD_Warnung_3_End/state"
fi
#
# Group
value=$(</etc/openhab2/html/dwd/warnings.xml awk -F"<dwd:EC_GROUP>" '{print $2}' | awk -F"</dwd:EC_GROUP>" '{print $1}')
if [ -n "$value" ]; then
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "$value" "http://openhabianpi:8080/rest/items/DWD_Warnung_1_Group/state"
else
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "0" "http://openhabianpi:8080/rest/items/DWD_Warnung_1_Group/state"
fi
value=$(</etc/openhab2/html/dwd/warnings.xml awk -F"<dwd:EC_GROUP>" '{print $3}' | awk -F"</dwd:EC_GROUP>" '{print $1}')
if [ -n "$value" ]; then
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "$value" "http://openhabianpi:8080/rest/items/DWD_Warnung_2_Group/state"
else
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "0" "http://openhabianpi:8080/rest/items/DWD_Warnung_2_Group/state"
fi
value=$(</etc/openhab2/html/dwd/warnings.xml awk -F"<dwd:EC_GROUP>" '{print $4}' | awk -F"</dwd:EC_GROUP>" '{print $1}')
if [ -n "$value" ]; then
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "$value" "http://openhabianpi:8080/rest/items/DWD_Warnung_3_Group/state"
else
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "0" "http://openhabianpi:8080/rest/items/DWD_Warnung_3_Group/state"
fi
#
# Parameter
value=$(</etc/openhab2/html/dwd/warnings.xml awk -F"<dwd:PARAMATERVALUE>" '{print $2}' | awk -F"</dwd:PARAMATERVALUE>" '{print $1}' | sed 's/</</g' | sed 's/>/>/g')
if [ -n "$value" ]; then
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "$value" "http://openhabianpi:8080/rest/items/DWD_Warnung_1_Parameter/state"
else
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "0" "http://openhabianpi:8080/rest/items/DWD_Warnung_1_Parameter/state"
fi
value=$(</etc/openhab2/html/dwd/warnings.xml awk -F"<dwd:PARAMATERVALUE>" '{print $3}' | awk -F"</dwd:PARAMATERVALUE>" '{print $1}' | sed 's/</</g' | sed 's/>/>/g')
if [ -n "$value" ]; then
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "$value" "http://openhabianpi:8080/rest/items/DWD_Warnung_2_Parameter/state"
else
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "0" "http://openhabianpi:8080/rest/items/DWD_Warnung_2_Parameter/state"
fi
value=$(</etc/openhab2/html/dwd/warnings.xml awk -F"<dwd:PARAMATERVALUE>" '{print $4}' | awk -F"</dwd:PARAMATERVALUE>" '{print $1}' | sed 's/</</g' | sed 's/>/>/g')
if [ -n "$value" ]; then
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "$value" "http://openhabianpi:8080/rest/items/DWD_Warnung_3_Parameter/state"
else
curl -s -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "0" "http://openhabianpi:8080/rest/items/DWD_Warnung_3_Parameter/state"
fi
I use the following rules to improve the readability of the start and end date (make it “lesbar” )
rule "Wetterwarnungen lesbarer machen - 1 Start"
when
Item DWD_Warnung_1_Start changed
then
val DateTime Start = new DateTime((DWD_Warnung_1_Start.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
val DateTime Start_Tag = new DateTime((DWD_Warnung_1_Start.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli).withTimeAtStartOfDay
val Long Diff = Math::round((Start_Tag.millis - now.withTimeAtStartOfDay.millis) / (86400000.0))
val String Uhrzeit = Start.toString.substring(11,16)
val String Tag = Start.toString.substring(8,10)
val String Monat = Start.toString.substring(5,7)
if ( Diff == 0 ) {
DWD_Warnung_1_Start_lesbar.postUpdate("heute " +Uhrzeit)
} else if ( Diff == 1 ) {
DWD_Warnung_1_Start_lesbar.postUpdate("morgen " +Uhrzeit)
} else if ( Diff == -1 ) {
DWD_Warnung_1_Start_lesbar.postUpdate("gestern " +Uhrzeit)
} else {
DWD_Warnung_1_Start_lesbar.postUpdate(Tag +"." +Monat +". " +Uhrzeit)
}
Thread::sleep(3000)
if (DWD_Warnung_1_Severity.state!="0") {
if (DWD_Warnung_1_Event.state=="UV-INDEX") {
sendTelegram("haus_an_mich_bot", "UV-Warnung von %s bis %s", DWD_Warnung_1_Start_lesbar.state.toString, DWD_Warnung_1_End_lesbar.state.toString)
} else {
sendTelegram("haus_an_mich_bot", "%s von %s bis %s (%s) [%s]", DWD_Warnung_1_Event.state.toString, DWD_Warnung_1_Start_lesbar.state.toString, DWD_Warnung_1_End_lesbar.state.toString, DWD_Warnung_1_Parameter.state.toString, DWD_Warnung_1_Severity.state.toString)
}
}
end
rule "Wetterwarnungen lesbarer machen - 2 Start"
when
Item DWD_Warnung_2_Start changed
then
val DateTime Start = new DateTime((DWD_Warnung_2_Start.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
val DateTime Start_Tag = new DateTime((DWD_Warnung_2_Start.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli).withTimeAtStartOfDay
val Long Diff = Math::round((Start_Tag.millis - now.withTimeAtStartOfDay.millis) / (86400000.0))
val String Uhrzeit = Start.toString.substring(11,16)
val String Tag = Start.toString.substring(8,10)
val String Monat = Start.toString.substring(5,7)
if ( Diff == 0 ) {
DWD_Warnung_2_Start_lesbar.postUpdate("heute " +Uhrzeit)
} else if ( Diff == 1 ) {
DWD_Warnung_2_Start_lesbar.postUpdate("morgen " +Uhrzeit)
} else if ( Diff == -1 ) {
DWD_Warnung_2_Start_lesbar.postUpdate("gestern " +Uhrzeit)
} else {
DWD_Warnung_2_Start_lesbar.postUpdate(Tag +"." +Monat +". " +Uhrzeit)
}
Thread::sleep(3000)
if (DWD_Warnung_2_Severity.state!="0") {
if (DWD_Warnung_2_Event.state=="UV-INDEX") {
sendTelegram("haus_an_mich_bot", "UV-Warnung von %s bis %s", DWD_Warnung_2_Start_lesbar.state.toString, DWD_Warnung_2_End_lesbar.state.toString)
} else {
sendTelegram("haus_an_mich_bot", "%s von %s bis %s (%s) [%s]", DWD_Warnung_2_Event.state.toString, DWD_Warnung_2_Start_lesbar.state.toString, DWD_Warnung_2_End_lesbar.state.toString, DWD_Warnung_2_Parameter.state.toString, DWD_Warnung_2_Severity.state.toString)
}
}
end
rule "Wetterwarnungen lesbarer machen - 3 Start"
when
Item DWD_Warnung_3_Start changed
then
val DateTime Start = new DateTime((DWD_Warnung_3_Start.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
val DateTime Start_Tag = new DateTime((DWD_Warnung_3_Start.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli).withTimeAtStartOfDay
val Long Diff = Math::round((Start_Tag.millis - now.withTimeAtStartOfDay.millis) / (86400000.0))
val String Uhrzeit = Start.toString.substring(11,16)
val String Tag = Start.toString.substring(8,10)
val String Monat = Start.toString.substring(5,7)
if ( Diff == 0 ) {
DWD_Warnung_3_Start_lesbar.postUpdate("heute " +Uhrzeit)
} else if ( Diff == 1 ) {
DWD_Warnung_3_Start_lesbar.postUpdate("morgen " +Uhrzeit)
} else if ( Diff == -1 ) {
DWD_Warnung_3_Start_lesbar.postUpdate("gestern " +Uhrzeit)
} else {
DWD_Warnung_3_Start_lesbar.postUpdate(Tag +"." +Monat +". " +Uhrzeit)
}
Thread::sleep(3000)
if (DWD_Warnung_3_Severity.state!="0") {
if (DWD_Warnung_3_Event.state=="UV-INDEX") {
sendTelegram("haus_an_mich_bot", "UV-Warnung von %s bis %s", DWD_Warnung_3_Start_lesbar.state.toString, DWD_Warnung_3_End_lesbar.state.toString)
} else {
sendTelegram("haus_an_mich_bot", "%s von %s bis %s (%s) [%s]", DWD_Warnung_3_Event.state.toString, DWD_Warnung_3_Start_lesbar.state.toString, DWD_Warnung_3_End_lesbar.state.toString, DWD_Warnung_3_Parameter.state.toString, DWD_Warnung_3_Severity.state.toString)
}
}
end
rule "Wetterwarnungen lesbarer machen - 1 End"
when
Item DWD_Warnung_1_End changed
then
val DateTime Start = new DateTime((DWD_Warnung_1_End.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
val DateTime Start_Tag = new DateTime((DWD_Warnung_1_End.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli).withTimeAtStartOfDay
val Long Diff = Math::round((Start_Tag.millis - now.withTimeAtStartOfDay.millis) / (86400000.0))
val String Uhrzeit = Start.toString.substring(11,16)
val String Tag = Start.toString.substring(8,10)
val String Monat = Start.toString.substring(5,7)
if ( Diff == 0 ) {
DWD_Warnung_1_End_lesbar.postUpdate("heute " +Uhrzeit)
} else if ( Diff == 1 ) {
DWD_Warnung_1_End_lesbar.postUpdate("morgen " +Uhrzeit)
} else if ( Diff == -1 ) {
DWD_Warnung_1_End_lesbar.postUpdate("gestern " +Uhrzeit)
} else {
DWD_Warnung_1_End_lesbar.postUpdate(Tag +"." +Monat +". " +Uhrzeit)
}
end
rule "Wetterwarnungen lesbarer machen - 2 End"
when
Item DWD_Warnung_2_End changed
then
val DateTime Start = new DateTime((DWD_Warnung_2_End.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
val DateTime Start_Tag = new DateTime((DWD_Warnung_2_End.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli).withTimeAtStartOfDay
val Long Diff = Math::round((Start_Tag.millis - now.withTimeAtStartOfDay.millis) / (86400000.0))
val String Uhrzeit = Start.toString.substring(11,16)
val String Tag = Start.toString.substring(8,10)
val String Monat = Start.toString.substring(5,7)
if ( Diff == 0 ) {
DWD_Warnung_2_End_lesbar.postUpdate("heute " +Uhrzeit)
} else if ( Diff == 1 ) {
DWD_Warnung_2_End_lesbar.postUpdate("morgen " +Uhrzeit)
} else if ( Diff == -1 ) {
DWD_Warnung_2_End_lesbar.postUpdate("gestern " +Uhrzeit)
} else {
DWD_Warnung_2_End_lesbar.postUpdate(Tag +"." +Monat +". " +Uhrzeit)
}
end
rule "Wetterwarnungen lesbarer machen - 3 End"
when
Item DWD_Warnung_3_End changed
then
val DateTime Start = new DateTime((DWD_Warnung_3_End.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
val DateTime Start_Tag = new DateTime((DWD_Warnung_3_End.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli).withTimeAtStartOfDay
val Long Diff = Math::round((Start_Tag.millis - now.withTimeAtStartOfDay.millis) / (86400000.0))
val String Uhrzeit = Start.toString.substring(11,16)
val String Tag = Start.toString.substring(8,10)
val String Monat = Start.toString.substring(5,7)
if ( Diff == 0 ) {
DWD_Warnung_3_End_lesbar.postUpdate("heute " +Uhrzeit)
} else if ( Diff == 1 ) {
DWD_Warnung_3_End_lesbar.postUpdate("morgen " +Uhrzeit)
} else if ( Diff == -1 ) {
DWD_Warnung_3_End_lesbar.postUpdate("gestern " +Uhrzeit)
} else {
DWD_Warnung_3_End_lesbar.postUpdate(Tag +"." +Monat +". " +Uhrzeit)
}
end
rule "Wetterwarnungen - Max Severity"
when
Item DWD_Warnung_1_Severity changed or
Item DWD_Warnung_2_Severity changed or
Item DWD_Warnung_3_Severity changed or
Item DelayedStartup changed from OFF to ON
then
var String MaxSeverity = "0"
if((DWD_Warnung_1_Severity.state=="Minor") || (DWD_Warnung_2_Severity.state=="Minor") || (DWD_Warnung_3_Severity.state=="Minor")) {
MaxSeverity = "Minor"
}
if((DWD_Warnung_1_Severity.state=="Moderate") || (DWD_Warnung_2_Severity.state=="Moderate") || (DWD_Warnung_3_Severity.state=="Moderate")) {
MaxSeverity = "Moderate"
}
if((DWD_Warnung_1_Severity.state=="Severe") || (DWD_Warnung_2_Severity.state=="Severe") || (DWD_Warnung_3_Severity.state=="Severe")) {
MaxSeverity = "Severe"
}
if((DWD_Warnung_1_Severity.state=="Extreme") || (DWD_Warnung_2_Severity.state=="Extreme") || (DWD_Warnung_3_Severity.state=="Extreme")) {
MaxSeverity = "Extreme"
}
DWD_Warnung_Max_Severity.postUpdate(MaxSeverity)
end
And finally, that stuff is displayes in a custom widget (with a blinking icon if there’s a warning): wetterwarnungen.widget.json (9.6 KB)
(for a preview please see my first link of this post)
So, have fun and if you have an improvement, I’d be happy if you share it
Sorry, I missed that part… Well, if there is no warning at the moment, there’s no warning in the file.
At the moment, there’s a warning for example in Torgau, warncell-id 814730310 (until 15:00). That’s what I did during debugging - look where’s a warning at the moment in insert that id.
That’s what my xml looks like if there’s no warning at the moment:
Then the script set all the values to 0 (and the dates I tink to 1.1.2000 or something, but that wouldn’t be necessary at all as the widget only checks the item “…event”)
(and copied them to /icons/classic, seemed to take a while, till they are shown up in the UI. Also: watch out for the Option “Vector oder Bitmap” File in PaperUI!)
I’m struggeling with the blue “DWD Icon”. In your upper post, that one with the screenshots of your sitemaps, your are using it in the first frame of your sitemap: (Blue Icon, “Wetter”, Dropdown Box “Warnungen”).
What is behind this frame? What item are you using?
thank you for this PDF. Don’t know my mistake - perhaps only IDs starting with “8” (Gemeinden) are allowed to be fetched. With your given ID, my command was working.
To make your Script runable:
create directory: “mkdir /etc/openhab2/html/dwd/”
and file: “touch /etc/openhab2/html/dwd/warnings.xml”
make it read and writeable to everyone (e.g. for user openhab and cron) “chmod 666 /etc/openhab2/html/dwd/warnings.xml”
Then, saved your script to /usr/local/bin/dwdweather.sh, and added “#!/bin/bash” at the first line. After chmod +x /usr/local/bin/dwdweather.sh i can run the script as the user “user”.
With and for this user, i created a cron entry: “crontab -e”, and there: “*/5 * * * * /usr/local/bin/dwdweather.sh”
“crontab -l” list the entry.
I run the script manually “/usr/local/bin/dwdwetter.sh” and watch the timestamp of warnings.xml. It is updated. But cron is not running the script … the timestamp remains. What could be wrong?
Are you able to download “Regenradar” GIF and display on your site?
PS: Once i could reference a username by drag an drop. Now i can’t find this option anymore. What is the trick?
PSS: I could/should open a new thread for my question. That is off-topic here.