CoVid Information examples

Hello Community,

I know there is another thread, but I decided to do an new one here, only for examples to show informations of CoVid19 in Smart Home.

If you are interested: leave a like and I will post my examples later this evening.

I have some rules grep informations from

  • John Hopkins university for USA and Germany,
  • Robert Koch institute for Regions in Germany
  • Ministry for Health from North-Rhine-Westfalia for regions in NRW
  • Regional Government from Region Gütersloh with informations to all towns in that region.

If you are interested: leave like and I know the work to share is good invested :wink:

#stayathome

3 Likes

Is your work different from the post on the COVID-19 main thread?

Example for Ministry of North-Rhine-Westfalia

You need:

  • Regex Binding
  • Exec Binding
  • Linux Bash
  • Telegram if want information per Message

Things:

Thing exec:command:CoVid19GetData "EXEC CoVid19 GetData" [command="bash /etc/openhab2/scripts/CoVid19_GetData.sh", interval=0, timeout=20, autorun=false]
Thing exec:command:CoVid19BI "EXEC CoVid19 BI" [command="bash /etc/openhab2/scripts/CoVid19_BI_Faelle.sh", interval=0, timeout=20, autorun=false]

/etc/openhab2/misc/exec.whitelist

bash /etc/openhab2/scripts/CoVid19_GetData.sh
bash /etc/openhab2/scripts/CoVid19_BI_Faelle.sh

/etc/openhab2/scripts/CoVid19_GetData.sh

#! /bin/bash
cd /tmp
rm corona*
DELE=$(/bin/wget -q https://www.mags.nrw/coronavirus-fallzahlen-nrw)

/etc/openhab2/scripts/CoVid19_BI_Faelle.sh

DATA=$(cat /tmp/coronavirus-fallzahlen-nrw | grep Bielefeld -A 1 | grep td | grep -v tr | sed 's/<td>//' | sed 's/<\/td>//')
echo $DATA

For other Regions look in downloaded file and change “Bielefeld” to other Region.

/etc/openhab/items/CoVid.items

String 		CoVid19_BI_IN 			"Fälle Kreis BI IN" 				(gCoVid) 			{channel="exec:command:CoVid19BI:output"} 
Number 		CoVid19_BI 			"Fälle Kreis BI [%s]" 				(gCoVid, gCoVidCh3, gHistoryCh)
Switch		CoVid19_BI_Run			"BI Run BI"					(gCoVid)			{channel="exec:command:CoVid19BI:run", autoupdate="false" } 
DateTime 	CoVid19_BI_LastRun		"BI Stand [%1$td.%1$tm. %1$tH:%1$tM Uhr]"	(gCoVid)			{channel="exec:command:CoVid19BI:lastexecution" } 

Don’t forget the items for the groups, or change groups in example.

/etc/openhab2/rules/Covid.rules

rule "CoVid Trigger NRW-Daten"
when
   Time cron "0 25,55 * ? * * *"
then
    logInfo("CoVid get NRW-Data", "Hole neue Daten")
    CoVid19_GetData_Run.sendCommand(ON)
end

rule "CoVid Trigger NRW-Werte"
when
   Time cron "0 /30 * ? * * *"
then
    CoVid19_BI_Run.sendCommand(ON)
end

rule "EXEC CoVid Konversion BI"
when
    Item CoVid19_BI_IN received update
then
    CoVid19_BI.sendCommand(Integer::parseInt(CoVid19_BI_IN.state.toString))
    CoVid19_BI.postUpdate(Integer::parseInt(CoVid19_BI_IN.state.toString))
end

rule "CoVid Info Kreis(e)"
when
    Item gCoVidCh3 changed
then
    val int delaySec=60
    val telegramAction = getActions("telegram","telegram:telegramBot:HomeBot")
    var long ChatId = 123456789L

    if(KREISEtelegramTimer === null) {
        KREISEtelegramTimer = createTimer(now.plusSeconds(delaySec)) [|
            telegramAction.sendTelegramPhoto(ChatId, "http://<IP-Server>:8080/chart?groups=gCoVidCh3&period=W&service=jdbc", "Neue Daten CoVid19 - Kreise")
        ]
    }
    else {
        KREISEtelegramTimer.reschedule(now.plusSeconds(delaySec))
    }
end

Don’t forget to enter your own ChatID and IP-Adress for Server

1 Like

Home Assistant has an addon using the John Hopkins information, I believe. Here is an interesting"geek" thread in another forum started by a China resident in a less affected region. Lots of US posters there too.

That Thread looks like more off topic. Idea is a Thread with concrete examples only.

1 Like

Well then, thank you very much for sharing you already got my like :wink:

I don’t need this information in my SmartHome since I work with the Berlin Katastrophenschutz (aka. Civil Protection).

I got every day COVID-19 news, talk and yada yada don’t want that at home too :smiley:

2 Likes

The thread I posted has lots of data examples from different people. I know it is long but I have been following it for a while.

I got an example for Berlin with Robert-Koch-Institute-Informations too :wink:

Things

Thing exec:command:CoVid19GetRKIData "EXEC CoVid19 RKI-Data" [command="bash /etc/openhab2/scripts/CoVid19_GetRKIData.sh", interval=0, timeout=60, autorun=false]

Thing exec:command:CoVid19BMitte "EXEC CoVid19 RKI B-Mitte" [command="bash /etc/openhab2/scripts/CoVid19_RKI_B-Mitte_Faelle.sh", interval=0, timeout=60, autorun=false]
Thing exec:command:CoVid19BFriKr "EXEC CoVid19 RKI B-Friedrichahain-Kreuzberg" [command="bash /etc/openhab2/scripts/CoVid19_RKI_B-Friedrichshain-Kreuzberg_Faelle.sh", interval=0, timeout=60, autorun=false]
Thing exec:command:CoVid19BChaWi "EXEC CoVid19 RKI B-Charlottenburg-Wilmersdorf" [command="bash /etc/openhab2/scripts/CoVid19_RKI_B-Charlottenburg-Wilmersdorf_Faelle.sh", interval=0, timeout=60, autorun=false]
Thing exec:command:CoVid19BTemSc "EXEC CoVid19 RKI B-Tempelhof-Schoeneberg" [command="bash /etc/openhab2/scripts/CoVid19_RKI_B-Tempelhof-Schoeneberg_Faelle.sh", interval=0, timeout=60, autorun=false]

Scripts
CoVid19_RKI_B-Charlottenburg-Wilmersdorf_Faelle.sh

#! /bin/bash
cd /tmp
DATA=$(cat /tmp/RKI-Daten-Kreise.data | jq -r '.features' | grep 'SK Berlin Charlottenburg-Wilmersdorf' -A 1 -B 36 | grep \"cases\": | cut -d: -f2 | cut -d, -f1)
echo $DATA

CoVid19_RKI_B-Friedrichshain-Kreuzberg_Faelle.sh

#! /bin/bash
cd /tmp
DATA=$(cat /tmp/RKI-Daten-Kreise.data | jq -r '.features' | grep 'SK Berlin Friedrichshain-Kreuzberg' -A 1 -B 36 | grep \"cases\": | cut -d: -f2 | cut -d, -f1)
echo $DATA

CoVid19_RKI_B-Mitte_Faelle.sh

#! /bin/bash
cd /tmp
DATA=$(cat /tmp/RKI-Daten-Kreise.data | jq -r '.features' | grep 'SK Berlin Mitte' -A 1 -B 36 | grep \"cases\": | cut -d: -f2 | cut -d, -f1)
echo $DATA

CoVid19_RKI_B-Tempelhof-Schoeneberg_Faelle.sh

#! /bin/bash
cd /tmp
DATA=$(cat /tmp/RKI-Daten-Kreise.data | jq -r '.features' | grep 'SK Berlin Tempelhof-Schöneberg' -A 1 -B 36 | grep \"cases\": | cut -d: -f2 | cut -d, -f1)
echo $DATA

You can look in Downloaded File and Replace the grep for every region in Germany

Items

String 		CoVid19_GetRKIData_IN 		"RKI Kreise getData" 				(gCoVid) 			{channel="exec:command:CoVid19GetRKIData:output"} 
Switch		CoVid19_GetRKIData_Run		"RKI Run getData"				(gCoVid)			{channel="exec:command:CoVid19GetRKIData:run", autoupdate="false" } 
DateTime 	CoVid19_GetRKIData_LastRun	"RKI getData Stand [%1$td.%1$tm. %1$tH:%1$tM Uhr]" (gCoVid)			{channel="exec:command:CoVid19GetRKIData:lastexecution" } 

String 		CoVid19_RKIGT_IN 		"RKI Kreis GT IN" 				(gCoVid) 			{channel="exec:command:CoVid19RKI_GT:output"} 
Number 		CoVid19_RKIGT 			"RKI Kreis GT [%s]" 				(gCoVid, gCoVidChKGT, gHistoryCh)
Switch		CoVid19_RKIGT_Run		"RKI GT Run GT"					(gCoVid)			{channel="exec:command:CoVid19RKI_GT:run", autoupdate="false" } 
DateTime 	CoVid19_RKIGT_LastRun		"RKI GT Stand [%1$td.%1$tm. %1$tH:%1$tM Uhr]"	(gCoVid)			{channel="exec:command:CoVid19RKI_GT:lastexecution" } 

String 		CoVid19_RKIBMitte_IN 		"RKI B-Mitte IN" 				(gCoVid) 			{channel="exec:command:CoVid19BMitte:output"} 
Number 		CoVid19_RKIBMitte 		"RKI B-Mitte [%s]" 				(gCoVid, gCoVidChB, gHistoryCh)
Switch		CoVid19_RKIBMitte_Run		"RKI B-Mitte Run"				(gCoVid)			{channel="exec:command:CoVid19BMitte:run", autoupdate="false" } 
DateTime 	CoVid19_RKIBMitte_LastRun	"RKI B-Mitte Stand [%1$td.%1$tm. %1$tH:%1$tM Uhr]" (gCoVid)			{channel="exec:command:CoVid19BMitte:lastexecution" } 
    
String 		CoVid19_RKIBFriKr_IN 		"RKI B-Friedrichsh.-Kreuzb. IN" 		(gCoVid) 			{channel="exec:command:CoVid19BFriKr:output"} 
Number 		CoVid19_RKIBFriKr 		"RKI B-Friedrichsh.-Kreuzb. [%s]" 		(gCoVid, gCoVidChB, gHistoryCh)
Switch		CoVid19_RKIBFriKr_Run		"RKI B-Friedrichsh.-Kreuzb. Run"		(gCoVid)			{channel="exec:command:CoVid19BFriKr:run", autoupdate="false" } 
DateTime 	CoVid19_RKIBFriKr_LastRun	"RKI B-Friedrichsh.-Kreuzb. Stand [%1$td.%1$tm. %1$tH:%1$tM Uhr]" (gCoVid)	{channel="exec:command:CoVid19BFriKr:lastexecution" } 

String 		CoVid19_RKIBChaWi_IN 		"RKI B-Charl.bg-Wilmersd. IN" 			(gCoVid) 			{channel="exec:command:CoVid19BChaWi:output"} 
Number 		CoVid19_RKIBChaWi 		"RKI B-Charl.bg-Wilmersd. [%s]" 		(gCoVid, gCoVidChB, gHistoryCh)
Switch		CoVid19_RKIBChaWi_Run		"RKI B-Charl.bg-Wilmersd. Run"			(gCoVid)			{channel="exec:command:CoVid19BChaWi:run", autoupdate="false" } 
DateTime 	CoVid19_RKIBChaWi_LastRun	"RKI B-Charl.bg-Wilmersd. Stand [%1$td.%1$tm. %1$tH:%1$tM Uhr]"	(gCoVid)	{channel="exec:command:CoVid19BChaWi:lastexecution" } 

String 		CoVid19_RKIBTemSc_IN 		"RKI B-Temp.hof-Schöneb. IN" 			(gCoVid) 			{channel="exec:command:CoVid19BTemSc:output"} 
Number 		CoVid19_RKIBTemSc 		"RKI B-Temp.hof-Schöneb. [%s]" 			(gCoVid, gCoVidChB, gHistoryCh)
Switch		CoVid19_RKIBTemSc_Run		"RKI B-Temp.hof-Schöneb. Run"			(gCoVid)			{channel="exec:command:CoVid19BTemSc:run", autoupdate="false" } 
DateTime 	CoVid19_RKIBTemSc_LastRun	"RKI B-Temp.hof-Schöneb. Stand [%1$td.%1$tm. %1$tH:%1$tM Uhr]" (gCoVid)		{channel="exec:command:CoVid19BTemSc:lastexecution" } 

rules

rule "CoVid Trigger DATA RKI -Daten"
when
   Time cron "0 25,55 * ? * * *"
then
    logInfo("CoVid get RKI -Data", "Hole neue Daten")
    CoVid19_GetRKIData_Run.sendCommand(ON)
end

rule "CoVid Trigger RKI-Werte B"
when
   Time cron "0 /30 * ? * * *"
then
    CoVid19_RKIBMitte_Run.sendCommand(ON)
    CoVid19_RKIBFriKr_Run.sendCommand(ON)
    CoVid19_RKIBChaWi_Run.sendCommand(ON)
    CoVid19_RKIBTemSc_Run.sendCommand(ON)
end

rule "EXEC CoVid Konversion RKI BMitte"
when
    Item CoVid19_RKIBMitte_IN received update
then
    logInfo("EXEC Covid RKI BMitte", "Starte Konversion", CoVid19_RKIBMitte_IN.state)
    CoVid19_RKIBMitte.sendCommand(Integer::parseInt(CoVid19_RKIBMitte_IN.state.toString))
    CoVid19_RKIBMitte.postUpdate(Integer::parseInt(CoVid19_RKIBMitte_IN.state.toString))
end

rule "EXEC CoVid Konversion RKI BFriKr"
when
    Item CoVid19_RKIBFriKr_IN received update
then
    logInfo("EXEC Covid RKI BFriKr", "Starte Konversion", CoVid19_RKIBFriKr_IN.state)
    CoVid19_RKIBFriKr.sendCommand(Integer::parseInt(CoVid19_RKIBFriKr_IN.state.toString))
    CoVid19_RKIBFriKr.postUpdate(Integer::parseInt(CoVid19_RKIBFriKr_IN.state.toString))
end

rule "EXEC CoVid Konversion RKI BChaWi"
when
    Item CoVid19_RKIBChaWi_IN received update
then
    logInfo("EXEC Covid RKI BChaWi", "Starte Konversion", CoVid19_RKIBChaWi_IN.state)
    CoVid19_RKIBChaWi.sendCommand(Integer::parseInt(CoVid19_RKIBChaWi_IN.state.toString))
    CoVid19_RKIBChaWi.postUpdate(Integer::parseInt(CoVid19_RKIBChaWi_IN.state.toString))
end

rule "EXEC CoVid Konversion RKI BTemSc"
when
    Item CoVid19_RKIBTemSc_IN received update
then
    logInfo("EXEC Covid RKI BTemSc", "Starte Konversion", CoVid19_RKIBTemSc_IN.state)
    CoVid19_RKIBTemSc.sendCommand(Integer::parseInt(CoVid19_RKIBTemSc_IN.state.toString))
    CoVid19_RKIBTemSc.postUpdate(Integer::parseInt(CoVid19_RKIBTemSc_IN.state.toString))
end

rule "CoVid Info Berlin"
when
    Item gCoVidChB changed
then
    val int delaySec=60
    val telegramAction = getActions("telegram","telegram:telegramBot:HomeBot")
    var long ChatId = 123456789L

if(BtelegramTimer === null) {
    BtelegramTimer = createTimer(now.plusSeconds(delaySec)) [|
        telegramAction.sendTelegramPhoto(ChatId, "http://<IP-Adress>:8080/chart?groups=gCoVidChB&period=W&service=jdbc", "Neue Daten CoVid19 - Berlin")
    ]
}
else {
    BtelegramTimer.reschedule(now.plusSeconds(delaySec))
}
end

Don’t forget to add the scripts in /misc/exec.whitelist

Thank you for your dedicated work. I am sure many people here sympathize with information overload. Some of us are close to that limit with the added complexity of trying to separate truth from fiction or politics.

3 Likes

For me the more important information would be hospital statistics in Germany/Berlin.

But there is no way you get these information from any officials, since it would freak out the citizens so hard.
Also there is no way to gather this information via. any tool or server since Germany is pretty much third world when it’s about digitalization.

That’s why I’m in contact with at least 5 hospitals intensive care unit managers who can tell me by thump these stats

Stats:

  • beds free
  • workers
  • COVID-19 in treatment
  • Supply Status

Forgotten script to get rki-Data

#! /bin/bash
cd /tmp

rm RKI-Daten-Kreise.data
DELE=$(/bin/wget -q -O RKI-Daten-Kreise.data 'https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?f=json&where=1%3D1&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=*&orderByFields=cases%20desc&outSR=102100&resultOffset=0&resultRecordCount=1000&cacheHint=true')
DATA="got it"
echo $DATA

I saw this post to late, so I created my own way to get the Incidence (per week per 100.000) values from RKI for different counties (Landkreise).

Items

Number  Corona_K_Incidence   "Köln [%d]"      {http="<[https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?objectIds=80&returnGeometry=false&outFields=OBJECTID,county,cases7_per_100k,BL,last_update,GEN&outSR=4326&f=json:600000:JSONPATH($.features.[0].attributes.cases7_per_100k)]"}
Number  Corona_HM_Incidence  "Hameln [%d]"    {http="<[https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?objectIds=29&returnGeometry=false&outFields=OBJECTID,county,cases7_per_100k,BL,last_update,GEN&outSR=4326&f=json:600000:JSONPATH($.features.[0].attributes.cases7_per_100k)]"}

To get values for other counties you just need to change the objectId in the URL.
You find the ObjectIds here: https://npgeo-corona-npgeo-de.hub.arcgis.com/datasets/917fc37a709542548cc3be077a786c17_0/data?geometry=-30.805%2C46.211%2C52.823%2C55.839

This is probably not an effective way to get the values for multiple counties, but you do not need complicated rules. :wink:

I wanted to do the same for states (Bundesländer), but there are umlauts in the URL which openHAB does not like.
Any idea how I can solve this?

Items (not working)

Number  Corona_NRW_Incidence  "Inzidenz NRW [%d]"   {http="<[https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/Coronaf%C3%A4lle_in_den_Bundesl%C3%A4ndern/FeatureServer/0/query?ObjectIds=5&returnGeometry=false&outFields=LAN_ew_GEN,OBJECTID,Aktualisierung,cases7_bl_per_100k&outSR=4326&f=json:600000:JSONPATH($.features.[0].attributes.cases7_bl_per_100k)]"}

openhab.log

2020-10-12 18:50:47.430 [ERROR] [b.core.service.AbstractActiveService] - Error while executing background thread HTTP Refresh Service
java.util.IllegalFormatConversionException: c != java.util.Date
        at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4302) ~[?:?]
        at java.util.Formatter$FormatSpecifier.printCharacter(Formatter.java:2869) ~[?:?]
        at java.util.Formatter$FormatSpecifier.print(Formatter.java:2757) ~[?:?]
        at java.util.Formatter.format(Formatter.java:2520) ~[?:?]
        at java.util.Formatter.format(Formatter.java:2455) ~[?:?]
        at java.lang.String.format(String.java:2940) ~[?:?]
        at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:144) ~[?:?]
        at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:144) ~[196:org.openhab.core.compat1x:2.4.0]
        at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:166) [196:org.openhab.core.compat1x:2.4.0]
2 Likes

You have two ways to do:
First way use Geography=true and specify the latitude etc., then as I saw the result only covers the area you specified.
Or you take another way: I just grep every our the Data-File for germany and then use a script for searching the value with jq | grep and so on. Not elegant, but it works.

I got every district for north-rhine-westfalia (think about 50?) and some other districts in this way. If look back the EXEC script could also be have done with an input value (search string), instead of 300 scripts (cases, death, R7-value, healed), but I thought to late about.

The bash Script (I start with a trigger rule) for RKI-Data:
{{{

#! /bin/bash
cd /tmp
rm CoVid_RKI_Daten-Kreise.data
DELE=$(/bin/wget -q -O CoVid_RKI_Daten-Kreise.data ‘https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?f=json&where=1%3D1&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=*&orderByFields=cases%20desc&outSR=102100&resultOffset=0&resultRecordCount=1000&cacheHint=true’)
DATA=“got it”
echo $DATA

Or for NRW Data with a lot of more Informations:

#! /bin/bash
cd /tmp
rm CoVid_NRW_Gesamt-u-Kreise.data
DELE=$(/bin/wget -q -O /tmp/CoVid_NRW_Gesamt-u-Kreise.data 'https://www.arcgishostedserver.nrw.de/arcgis/rest/services/Hosted/COVID19_Indikatoren_Kreise/FeatureServer/0/query?f=json&where=1%3D1&returnGeometry=false&outFields=*&outSR=25832&resultType=tile')

An example for a grep for a value (Could be more variable with INPUT-Item and INPUT triggers Script with Output:
RKI:>

#! /bin/bash
cd /tmp
DATA=$(cat /tmp/CoVid_RKI_Daten-Kreise.data | jq -r ‘.features’ | grep ‘SK Berlin Mitte’ -A 5 -B 36 | grep cases7_p | cut -d: -f2 | cut -d, -f1)
echo $DATA

NRW:>

#! /bin/bash
DATA=$(cat /tmp/CoVid_NRW_Gesamt-u-Kreise.data | jq | grep Bielefeld -B 2 -A 29 | grep infizierte | cut -d: -f2 | sed ‘s/,//’)
echo $DATA

Ein anderer Weg, aber funktioniert

As the number start to increase a lot during the last days I also wanted to put the COVID data on my “weather” dashboard. I am also interested in the hospital situation and it seems that there is also data for Germany available on the ARCGIS/NPGEO resources. (see here).
Does anybody understands the API there? How can I get the data fields “betten_frei” “betten_belegt” “betten_gesamt” “Anteil_betten_frei” “faelle_covid_aktuell” “faelle_covid_aktuell_beatmet” “Anteil_covid_beatmet” “Anteil_COVID_betten” for a certain region?

The RKI data don’t has it in I believe. The nrw data has a field list and the beds are for every district in f10 to f18

Just look the file with cat data-file | jq

Edit: The divi register I didn’t used until now. Look with Firefox development view name if data file, get it and then look inside with above command. Then you should find

I know some time has gone, sorry for late reply:
Meanwhile I have integrated DIVI-Register with hospital situation and vaccine statistics from RKI too.

If someone still interested, just short pm, then I ll take the work and share it here.

Because quested by PM here the scripts for vaccine for germany with official daily RKI-Excel-Publications:

I only have for Germany. And with new vaccines you will need to change the scripts (raise field number in greps -f. because I only found in excel:

Things:

Thing exec:command:CoVid19GetDataRKIimpf 	"EXEC Get CoVid19 RKI-Impf." 	[command="bash /etc/openhab/scripts/CoVid19_1_GetData_RKI-Impfungen.sh", interval=0, timeout=20, autorun=false, transform="REGEX((.*?))"]

Thing exec:command:CoVid19RKIDImpfdosen "EXEC CoVid19 RKI D Impfdosen" [command="bash /etc/openhab/scripts/CoVid19_8_RKI_D_Impfdosen.sh", interval=0, timeout=60, autorun=false, transform="REGEX((.*?))"]
Thing exec:command:CoVid19RKINRWImpfdosen "EXEC CoVid19 RKI NRW Impfdosen" [command="bash /etc/openhab/scripts/CoVid19_8_RKI_NRW_Impfdosen.sh", interval=0, timeout=60, autorun=false, transform="REGEX((.*?))"]
Thing exec:command:CoVid19RKIBImpfdosen "EXEC CoVid19 RKI B Impfdosen" [command="bash /etc/openhab/scripts/CoVid19_8_RKI_B_Impfdosen.sh", interval=0, timeout=60, autorun=false, transform="REGEX((.*?))"]

Thing exec:command:CoVid19RKIDImpfdose1 "EXEC CoVid19 RKI D 1. Impfung" [command="bash /etc/openhab/scripts/CoVid19_8_RKI_D_Impfdose1.sh", interval=0, timeout=60, autorun=false, transform="REGEX((.*?))"]
Thing exec:command:CoVid19RKINRWImpfdose1 "EXEC CoVid19 RKI NRW 1. Impfung" [command="bash /etc/openhab/scripts/CoVid19_8_RKI_NRW_Impfdose1.sh", interval=0, timeout=60, autorun=false, transform="REGEX((.*?))"]
Thing exec:command:CoVid19RKIBImpfdose1 "EXEC CoVid19 RKI B 1. Impfung" [command="bash /etc/openhab/scripts/CoVid19_8_RKI_B_Impfdose1.sh", interval=0, timeout=60, autorun=false, transform="REGEX((.*?))"]

Thing exec:command:CoVid19RKIDImpfdose2 "EXEC CoVid19 RKI D 2. Impfung" [command="bash /etc/openhab/scripts/CoVid19_8_RKI_D_Impfdose2.sh", interval=0, timeout=60, autorun=false, transform="REGEX((.*?))"]
Thing exec:command:CoVid19RKINRWImpfdose2 "EXEC CoVid19 RKI NRW 2. Impfung" [command="bash /etc/openhab/scripts/CoVid19_8_RKI_NRW_Impfdose2.sh", interval=0, timeout=60, autorun=false, transform="REGEX((.*?))"]
Thing exec:command:CoVid19RKIBImpfdose2 "EXEC CoVid19 RKI B 2. Impfung" [command="bash /etc/openhab/scripts/CoVid19_8_RKI_B_Impfdose2.sh", interval=0, timeout=60, autorun=false, transform="REGEX((.*?))"]

Items:

Switch		CoVid19_GetData_RKIimpf_Run	"Get Data RKIimpf"					(gAll, gCoVid)	{channel="exec:command:CoVid19GetDataRKIimpf:run", autoupdate="false" } 
DateTime 	CoVid19_GetData_RKIimpf_LastRun	"Get Data RKIimpf Last [%1$td.%1$tm. %1$tH:%1$tM Uhr]"	(gAll, gCoVid)	{channel="exec:command:CoVid19GetDataRKIimpf:lastexecution" } 

//String 		CoVid19_RKI_D_Impfdosen_IN 	"D Impfdosen verimpft IN (Q:RKI) [%d]" 				(gAll, gCoVid)				{channel="exec:command:CoVid19RKIDImpfdosen:output"} 
Number 		CoVid19_RKI_D_Impfdosen 	"D Impfdosen verimpft (Q:RKI) [%d]" 				(gAll, gCoVid, gCoVidDIC, gHistoryCh)		{channel="exec:command:CoVid19RKIDImpfdosen:output"} 
Number 		CoVid19_RKI_D_Impfdosen_New 	"D Impfdosen neu verimpft (Q:RKI) [%d]" 			(gAll, gCoVid, gCoVidChDI1, gHistoryCh)
Switch 		CoVid19_RKI_D_Impfdosen_Run 	"D Impfdosen verimpft RUN (Q:RKI)" 				(gAll, gCoVid, gCoVidDIRun)				{channel="exec:command:CoVid19RKIDImpfdosen:run"} 
Number 		CoVid19_RKI_D_Impfquote 	"Impfquote D (berechnet mit 2 Impf./P.) [%.3f %%]" 		(gAll, gCoVid, gHistoryCh)

Number 		CoVid19_RKI_D_Impf_ETA50 	"D Impfq. 50% in x Tagen [%d]" 					(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_D_Impf_ETA60 	"D Impfq. 60% in x Tagen [%d]"					(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_D_Impf_ETA70 	"D Impfq. 70% in x Tagen [%d]"					(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_D_Impf_ETA80 	"D Impfq. 80% in x Tagen [%d]"					(gAll, gCoVid, gHistoryCh)

Number 		CoVid19_RKI_D_Impfung1 		"D 1. Impfung verimpft (Q:RKI) [%d]" 				(gAll, gCoVid, gCoVidDIC, gHistoryCh)		{channel="exec:command:CoVid19RKIDImpfdose1:output"} 
Number 		CoVid19_RKI_D_Impfung1_New 	"D 1. Impfung neu verimpft (Q:RKI) [%d]" 			(gAll, gCoVid, gCoVidChDI1, gHistoryCh)
Switch 		CoVid19_RKI_D_Impfung1_Run 	"D 1. Impfung verimpft RUN (Q:RKI)" 				(gAll, gCoVid, gCoVidDIRun)				{channel="exec:command:CoVid19RKIDImpfdose1:run"} 
Number 		CoVid19_RKI_D_Impfquote1 	"Impfquote D (1. Impfung) [%.3f %%]" 				(gAll, gCoVid, gCoVidChDI2, gHistoryCh)
Number 		CoVid19_RKI_D_Impf1_ETA50 	"D 1.Impfung 50% in x Tagen [%d]" 				(gAll, gCoVid, gCoVidChDIETA, gHistoryCh)
Number 		CoVid19_RKI_D_Impf1_ETA60 	"D 1.Impfung 60% in x Tagen [%d]"				(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_D_Impf1_ETA70 	"D 1.Impfung 70% in x Tagen [%d]"				(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_D_Impf1_ETA80 	"D 1.Impfung 80% in x Tagen [%d]"				(gAll, gCoVid, gHistoryCh)

Number 		CoVid19_RKI_D_Impfung2 		"D 2. Impfung verimpft (Q:RKI) [%d]" 				(gAll, gCoVid, gCoVidDIC, gHistoryCh)		{channel="exec:command:CoVid19RKIDImpfdose2:output"} 
Number 		CoVid19_RKI_D_Impfung2_New 	"D 2. Impfung neu verimpft (Q:RKI) [%d]" 			(gAll, gCoVid, gCoVidChDI1, gHistoryCh)
Switch 		CoVid19_RKI_D_Impfung2_Run 	"D 2. Impfung verimpft RUN (Q:RKI)" 				(gAll, gCoVid, gCoVidDIRun)				{channel="exec:command:CoVid19RKIDImpfdose2:run"} 
Number 		CoVid19_RKI_D_Impfquote2 	"Impfquote D (2. Impfung) [%.3f %%]" 				(gAll, gCoVid, gCoVidChDI2, gHistoryCh)
Number 		CoVid19_RKI_D_Impf2_ETA50 	"D 2.Impfung 50% in x Tagen [%d]" 				(gAll, gCoVid, gCoVidChDIETA, gHistoryCh)
Number 		CoVid19_RKI_D_Impf2_ETA60 	"D 2.Impfung 60% in x Tagen [%d]"				(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_D_Impf2_ETA70 	"D 2.Impfung 70% in x Tagen [%d]"				(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_D_Impf2_ETA80 	"D 2.Impfung 80% in x Tagen [%d]"				(gAll, gCoVid, gHistoryCh)



//String 		CoVid19_RKI_NRW_Impfdosen_IN 	"NRW Impfdosen verimpft IN (Q:RKI) [%d]" 			(gAll, gCoVid)				{channel="exec:command:CoVid19RKINRWImpfdosen:output"} 
Number 		CoVid19_RKI_NRW_Impfdosen 	"NRW Impfdosen verimpft (Q:RKI) [%d]" 				(gAll, gCoVid, gCoVidDIC, gHistoryCh)		{channel="exec:command:CoVid19RKINRWImpfdosen:output"} 
Number 		CoVid19_RKI_NRW_Impfdosen_New 	"NRW Impfdosen neu verimpft (Q:RKI) [%d]" 			(gAll, gCoVid, gCoVidChNRW4, gHistoryCh)
Switch 		CoVid19_RKI_NRW_Impfdosen_Run 	"NRW Impfdosen verimpft RUN (Q:RKI)" 				(gAll, gCoVid, gCoVidDIRun)				{channel="exec:command:CoVid19RKINRWImpfdosen:run"} 
Number 		CoVid19_RKI_NRW_Impfquote 	"Impfquote NRW (berechnet mit 2 Impf./P.) [%.3f %%]" 		(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_NRW_Impf_ETA50 	"NRW Impfq. 50% in x Tagen [%d]" 				(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_NRW_Impf_ETA60 	"NRW Impfq. 60% in x Tagen [%d]"				(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_NRW_Impf_ETA70 	"NRW Impfq. 70% in x Tagen [%d]"				(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_NRW_Impf_ETA80 	"NRW Impfq. 80% in x Tagen [%d]"				(gAll, gCoVid, gHistoryCh)

Number 		CoVid19_RKI_NRW_Impfung1 	"NRW 1. Impfung verimpft (Q:RKI) [%d]" 				(gAll, gCoVid, gCoVidDIC, gHistoryCh)		{channel="exec:command:CoVid19RKINRWImpfdose1:output"} 
Number 		CoVid19_RKI_NRW_Impfung1_New 	"NRW 1. Impfung neu verimpft (Q:RKI) [%d]" 			(gAll, gCoVid, gCoVidChNRW4, gHistoryCh)
Switch 		CoVid19_RKI_NRW_Impfung1_Run 	"NRW 1. Impfung verimpft RUN (Q:RKI)" 				(gAll, gCoVid, gCoVidDIRun)				{channel="exec:command:CoVid19RKINRWImpfdose1:run"} 
Number 		CoVid19_RKI_NRW_Impfquote1 	"Impfquote NRW (1. Impfung) [%.3f %%]" 				(gAll, gCoVid, gCoVidChDI2, gHistoryCh)
Number 		CoVid19_RKI_NRW_Impf1_ETA50 	"NRW 1.Impfung 50% in x Tagen [%d]" 				(gAll, gCoVid, gCoVidChDIETA, gHistoryCh)
Number 		CoVid19_RKI_NRW_Impf1_ETA60 	"NRW 1.Impfung 60% in x Tagen [%d]"				(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_NRW_Impf1_ETA70 	"NRW 1.Impfung 70% in x Tagen [%d]"				(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_NRW_Impf1_ETA80 	"NRW 1.Impfung 80% in x Tagen [%d]"				(gAll, gCoVid, gHistoryCh)

Number 		CoVid19_RKI_NRW_Impfung2 	"NRW 2. Impfung verimpft (Q:RKI) [%d]" 				(gAll, gCoVid, gCoVidDIC, gHistoryCh)		{channel="exec:command:CoVid19RKINRWImpfdose2:output"} 
Number 		CoVid19_RKI_NRW_Impfung2_New 	"NRW 2. Impfung neu verimpft (Q:RKI) [%d]" 			(gAll, gCoVid, gCoVidChNRW4, gHistoryCh)
Switch 		CoVid19_RKI_NRW_Impfung2_Run 	"NRW 2. Impfung verimpft RUN (Q:RKI)" 				(gAll, gCoVid, gCoVidDIRun)				{channel="exec:command:CoVid19RKINRWImpfdose2:run"} 
Number 		CoVid19_RKI_NRW_Impfquote2 	"Impfquote NRW (2. Impfung) [%.3f %%]" 				(gAll, gCoVid, gCoVidChDI2, gHistoryCh)
Number 		CoVid19_RKI_NRW_Impf2_ETA50 	"NRW 2.Impfung 50% in x Tagen [%d]" 				(gAll, gCoVid, gCoVidChDIETA, gHistoryCh)
Number 		CoVid19_RKI_NRW_Impf2_ETA60 	"NRW 2.Impfung 60% in x Tagen [%d]"				(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_NRW_Impf2_ETA70 	"NRW 2.Impfung 70% in x Tagen [%d]"				(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_NRW_Impf2_ETA80 	"NRW 2.Impfung 80% in x Tagen [%d]"				(gAll, gCoVid, gHistoryCh)



//String 		CoVid19_RKI_B_Impfdosen_IN 	"B Impfdosen verimpft IN (Q:RKI) [%d]" 				(gAll, gCoVid)				{channel="exec:command:CoVid19RKIBImpfdosen:output"} 
Number 		CoVid19_RKI_B_Impfdosen 	"B Impfdosen verimpft (Q:RKI) [%d]" 				(gAll, gCoVid, gCoVidDIC, gHistoryCh)		{channel="exec:command:CoVid19RKIBImpfdosen:output"} 
Number 		CoVid19_RKI_B_Impfdosen_New 	"B Impfdosen neu verimpft (Q:RKI) [%d]" 			(gAll, gCoVid, gCoVidChB5, gHistoryCh)
Switch 		CoVid19_RKI_B_Impfdosen_Run 	"B Impfdosen verimpft RUN (Q:RKI)" 				(gAll, gCoVid, gCoVidDIRun)				{channel="exec:command:CoVid19RKIBImpfdosen:run"} 
Number 		CoVid19_RKI_B_Impfquote 	"Impfquote B (berechnet mit 2 Impf./P.) [%.3f %%]" 		(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_B_Impf_ETA50 	"B Impfq. 50% in x Tagen [%d]" 					(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_B_Impf_ETA60 	"B Impfq. 60% in x Tagen [%d]"					(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_B_Impf_ETA70 	"B Impfq. 70% in x Tagen [%d]"					(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_B_Impf_ETA80 	"B Impfq. 80% in x Tagen [%d]"					(gAll, gCoVid, gHistoryCh)

Number 		CoVid19_RKI_B_Impfung1 	"B 1. Impfung verimpft (Q:RKI) [%d]" 					(gAll, gCoVid, gCoVidDIC, gHistoryCh)		{channel="exec:command:CoVid19RKIBImpfdose1:output"} 
Number 		CoVid19_RKI_B_Impfung1_New 	"B 1. Impfung neu verimpft (Q:RKI) [%d]" 			(gAll, gCoVid, gCoVidChB5, gHistoryCh)
Switch 		CoVid19_RKI_B_Impfung1_Run 	"B 1. Impfung verimpft RUN (Q:RKI)" 				(gAll, gCoVid, gCoVidDIRun)				{channel="exec:command:CoVid19RKIBImpfdose1:run"} 
Number 		CoVid19_RKI_B_Impfquote1 	"Impfquote B (1. Impfung) [%.3f %%]" 				(gAll, gCoVid, gCoVidChDI2, gHistoryCh)
Number 		CoVid19_RKI_B_Impf1_ETA50 	"B 1.Impfung 50% in x Tagen [%d]" 				(gAll, gCoVid, gCoVidChDIETA, gHistoryCh)
Number 		CoVid19_RKI_B_Impf1_ETA60 	"B 1.Impfung 60% in x Tagen [%d]"				(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_B_Impf1_ETA70 	"B 1.Impfung 70% in x Tagen [%d]"				(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_B_Impf1_ETA80 	"B 1.Impfung 80% in x Tagen [%d]"				(gAll, gCoVid, gHistoryCh)

Number 		CoVid19_RKI_B_Impfung2 	"B 2. Impfung verimpft (Q:RKI) [%d]" 					(gAll, gCoVid, gCoVidDIC, gHistoryCh)		{channel="exec:command:CoVid19RKIBImpfdose2:output"} 
Number 		CoVid19_RKI_B_Impfung2_New 	"B 2. Impfung neu verimpft (Q:RKI) [%d]" 			(gAll, gCoVid, gCoVidChB5, gHistoryCh)
Switch 		CoVid19_RKI_B_Impfung2_Run 	"B 2. Impfung verimpft RUN (Q:RKI)" 				(gAll, gCoVid, gCoVidDIRun)				{channel="exec:command:CoVid19RKIBImpfdose2:run"} 
Number 		CoVid19_RKI_B_Impfquote2 	"Impfquote B (2. Impfung) [%.3f %%]" 				(gAll, gCoVid, gCoVidChDI2, gHistoryCh)
Number 		CoVid19_RKI_B_Impf2_ETA50 	"B 2.Impfung 50% in x Tagen [%d]" 				(gAll, gCoVid, gCoVidChDIETA, gHistoryCh)
Number 		CoVid19_RKI_B_Impf2_ETA60 	"B 2.Impfung 60% in x Tagen [%d]"				(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_B_Impf2_ETA70 	"B 2.Impfung 70% in x Tagen [%d]"				(gAll, gCoVid, gHistoryCh)
Number 		CoVid19_RKI_B_Impf2_ETA80 	"B 2.Impfung 80% in x Tagen [%d]"				(gAll, gCoVid, gHistoryCh)

Rules (inclusive calculation of ETA in days for mass immunity):

rule "CoVid Trigger Get-Data-Files RKI, RKI-Impf, Divi und NRW"
when
    Time cron "0 18,48 5-2 ? * * *"
then
    logInfo("CoVid Trigger Get-Data-Files RKI, RKI-Impf, Divi und NRW", "CoVid19 - Every 30m - Get new Data Files: RKI, Divi und NRW")
    CoVid19_GetData_RKIimpf_Run.sendCommand(ON)
end

var Timer USAcalcTimer = null
var Timer DIcalcTimer = null
var Timer NRWIcalcTimer = null
var Timer BIcalcTimer = null


rule "CoVid Berechnungen Impfungen D"
when
//    Time cron "0 /2 * ? * * *" or
    Item gCoVidDIC changed
then
    val int delaySec=30
    logInfo("Covid Work Impfungen D", "CoVid19 - Calculate D Impfungen Timer")
    if(DIcalcTimer === null) {
        DIcalcTimer = createTimer(now.plusSeconds(delaySec), [|
            CoVid19_RKI_D_Impfung1_New.postUpdate(CoVid19_RKI_D_Impfung1.deltaSince(now.minusMinutes(720)))
            CoVid19_RKI_D_Impfung2_New.postUpdate(CoVid19_RKI_D_Impfung2.deltaSince(now.minusMinutes(720)))
            CoVid19_RKI_D_Impfdosen_New.postUpdate(CoVid19_RKI_D_Impfdosen.deltaSince(now.minusMinutes(720)))
            CoVid19_RKI_D_Impfquote1.postUpdate(CoVid19_RKI_D_Impfung1.state as Number / 830200.00)
            CoVid19_RKI_D_Impfquote2.postUpdate(CoVid19_RKI_D_Impfung2.state as Number / 830200.00)
// Berechnung ETA Herdenimmunität
            CoVid19_RKI_D_Impf1_ETA50.postUpdate((41510000.0 - CoVid19_RKI_D_Impfung1.state as Number) / (CoVid19_RKI_D_Impfung1.deltaSince(now.minusHours(324)) as Number / 14.0 ))
            CoVid19_RKI_D_Impf1_ETA60.postUpdate((49812000.0 - CoVid19_RKI_D_Impfung1.state as Number) / (CoVid19_RKI_D_Impfung1.deltaSince(now.minusHours(324)) as Number / 14.0 ))
            CoVid19_RKI_D_Impf1_ETA70.postUpdate((58114000.0 - CoVid19_RKI_D_Impfung1.state as Number) / (CoVid19_RKI_D_Impfung1.deltaSince(now.minusHours(324)) as Number / 14.0 ))
            CoVid19_RKI_D_Impf1_ETA80.postUpdate((66416000.0 - CoVid19_RKI_D_Impfung1.state as Number) / (CoVid19_RKI_D_Impfung1.deltaSince(now.minusHours(324)) as Number / 14.0 ))

            CoVid19_RKI_D_Impf2_ETA50.postUpdate((41510000.0 - CoVid19_RKI_D_Impfung2.state as Number) / (CoVid19_RKI_D_Impfung2.deltaSince(now.minusHours(324)) as Number / 14.0 ))
            CoVid19_RKI_D_Impf2_ETA60.postUpdate((49812000.0 - CoVid19_RKI_D_Impfung2.state as Number) / (CoVid19_RKI_D_Impfung2.deltaSince(now.minusHours(324)) as Number / 14.0 ))
            CoVid19_RKI_D_Impf2_ETA70.postUpdate((58114000.0 - CoVid19_RKI_D_Impfung2.state as Number) / (CoVid19_RKI_D_Impfung2.deltaSince(now.minusHours(324)) as Number / 14.0 ))
            CoVid19_RKI_D_Impf2_ETA80.postUpdate((66416000.0 - CoVid19_RKI_D_Impfung2.state as Number) / (CoVid19_RKI_D_Impfung2.deltaSince(now.minusHours(324)) as Number / 14.0 ))
            logInfo("Covid Work Impfungen D", "CoVid19 - Calculate D Impfungen done")
            DIcalcTimer.cancel
            DIcalcTimer=null
        ] )
    }
    else {
        DIcalcTimer.reschedule(now.plusSeconds(delaySec))
    }
end


rule "CoVid Berechnungen Impfungen NRW"
when
//    Time cron "0 /2 * ? * * *" or
    Item gCoVidDIC changed
then
    val int delaySec=30
    logInfo("Covid Work Impfungen NRW", "CoVid19 - Calculate NRW Impfungen Timer")
    if(NRWIcalcTimer === null) {
        NRWIcalcTimer = createTimer(now.plusSeconds(delaySec), [|
            CoVid19_RKI_NRW_Impfung1_New.postUpdate(CoVid19_RKI_NRW_Impfung1.deltaSince(now.minusMinutes(720)))
            CoVid19_RKI_NRW_Impfung2_New.postUpdate(CoVid19_RKI_NRW_Impfung2.deltaSince(now.minusMinutes(720)))
            CoVid19_RKI_NRW_Impfdosen_New.postUpdate(CoVid19_RKI_NRW_Impfdosen.deltaSince(now.minusMinutes(720)))
            CoVid19_RKI_NRW_Impfquote1.postUpdate(CoVid19_RKI_NRW_Impfung1.state as Number / 179470.00)
            CoVid19_RKI_NRW_Impfquote2.postUpdate(CoVid19_RKI_NRW_Impfung2.state as Number / 179470.00)
// Berechnung ETA Herdenimmunität
            CoVid19_RKI_NRW_Impf1_ETA50.postUpdate((8973500.0 - CoVid19_RKI_NRW_Impfung1.state as Number ) / (CoVid19_RKI_NRW_Impfung1.deltaSince(now.minusHours(324)) as Number / 14.0 ))
            CoVid19_RKI_NRW_Impf1_ETA60.postUpdate((10768200.0 - CoVid19_RKI_NRW_Impfung1.state as Number ) / (CoVid19_RKI_NRW_Impfung1.deltaSince(now.minusHours(324)) as Number / 14.0 ))
            CoVid19_RKI_NRW_Impf1_ETA70.postUpdate((12562900.0 - CoVid19_RKI_NRW_Impfung1.state as Number ) / (CoVid19_RKI_NRW_Impfung1.deltaSince(now.minusHours(324)) as Number / 14.0 ))
            CoVid19_RKI_NRW_Impf1_ETA80.postUpdate((14357600.0 - CoVid19_RKI_NRW_Impfung1.state as Number ) / (CoVid19_RKI_NRW_Impfung1.deltaSince(now.minusHours(324)) as Number / 14.0 ))
            CoVid19_RKI_NRW_Impf2_ETA50.postUpdate((8973500.0 - CoVid19_RKI_NRW_Impfung2.state as Number ) / (CoVid19_RKI_NRW_Impfung2.deltaSince(now.minusHours(324)) as Number / 14.0 ))
            CoVid19_RKI_NRW_Impf2_ETA60.postUpdate((10768200.0 - CoVid19_RKI_NRW_Impfung2.state as Number ) / (CoVid19_RKI_NRW_Impfung2.deltaSince(now.minusHours(324)) as Number / 14.0 ))
            CoVid19_RKI_NRW_Impf2_ETA70.postUpdate((12562900.0 - CoVid19_RKI_NRW_Impfung2.state as Number ) / (CoVid19_RKI_NRW_Impfung2.deltaSince(now.minusHours(324)) as Number / 14.0 ))
            CoVid19_RKI_NRW_Impf2_ETA80.postUpdate((14357600.0 - CoVid19_RKI_NRW_Impfung2.state as Number ) / (CoVid19_RKI_NRW_Impfung2.deltaSince(now.minusHours(324)) as Number / 14.0 ))
            logInfo("Covid Work Impfungen D", "CoVid19 - Calculate NRW Impfungen done")
            NRWIcalcTimer.cancel
            NRWIcalcTimer=null
        ] )
    }
    else {
        NRWIcalcTimer.reschedule(now.plusSeconds(delaySec))
    }
end

rule "CoVid Berechnungen Impfungen B"
when
//    Time cron "0 /2 * ? * * *" or
    Item gCoVidDIC changed
then
    val int delaySec=30
    logInfo("Covid Work Impfungen NRW", "CoVid19 - Calculate NRW Impfungen Timer")
    if(BIcalcTimer === null) {
        BIcalcTimer = createTimer(now.plusSeconds(delaySec), [|
            CoVid19_RKI_B_Impfung1_New.postUpdate(CoVid19_RKI_B_Impfung1.deltaSince(now.minusMinutes(720)))
            CoVid19_RKI_B_Impfung2_New.postUpdate(CoVid19_RKI_B_Impfung2.deltaSince(now.minusMinutes(720)))
            CoVid19_RKI_B_Impfdosen_New.postUpdate(CoVid19_RKI_B_Impfdosen.deltaSince(now.minusMinutes(720)))
            CoVid19_RKI_B_Impfquote1.postUpdate(CoVid19_RKI_B_Impfung1.state as Number / 36690.00)
            CoVid19_RKI_B_Impfquote2.postUpdate(CoVid19_RKI_B_Impfung2.state as Number / 36690.00)
// Berechnung ETA Herdenimmunität
            CoVid19_RKI_B_Impf1_ETA50.postUpdate((1834500.0 - CoVid19_RKI_B_Impfung1.state as Number ) / (CoVid19_RKI_B_Impfung1.deltaSince(now.minusHours(324)) as Number / 14.0 ))
            CoVid19_RKI_B_Impf1_ETA60.postUpdate((2201400.0 - CoVid19_RKI_B_Impfung1.state as Number ) / (CoVid19_RKI_B_Impfung1.deltaSince(now.minusHours(324)) as Number / 14.0 ))
            CoVid19_RKI_B_Impf1_ETA70.postUpdate((2568300.0 - CoVid19_RKI_B_Impfung1.state as Number ) / (CoVid19_RKI_B_Impfung1.deltaSince(now.minusHours(324)) as Number / 14.0 ))
            CoVid19_RKI_B_Impf1_ETA80.postUpdate((2935200.0 - CoVid19_RKI_B_Impfung1.state as Number ) / (CoVid19_RKI_B_Impfung1.deltaSince(now.minusHours(324)) as Number / 14.0 ))

            CoVid19_RKI_B_Impf2_ETA50.postUpdate((1834500.0 - CoVid19_RKI_B_Impfung2.state as Number ) / (CoVid19_RKI_B_Impfung2.deltaSince(now.minusHours(324)) as Number / 14.0 ))
            CoVid19_RKI_B_Impf2_ETA60.postUpdate((2201400.0 - CoVid19_RKI_B_Impfung2.state as Number ) / (CoVid19_RKI_B_Impfung2.deltaSince(now.minusHours(324)) as Number / 14.0 ))
            CoVid19_RKI_B_Impf2_ETA70.postUpdate((2568300.0 - CoVid19_RKI_B_Impfung2.state as Number ) / (CoVid19_RKI_B_Impfung2.deltaSince(now.minusHours(324)) as Number / 14.0 ))
            CoVid19_RKI_B_Impf2_ETA80.postUpdate((2935200.0 - CoVid19_RKI_B_Impfung2.state as Number ) / (CoVid19_RKI_B_Impfung2.deltaSince(now.minusHours(324)) as Number / 14.0 ))
            logInfo("Covid Work Impfungen D", "CoVid19 - Calculate B Impfungen done")
            BIcalcTimer.cancel
            BIcalcTimer=null
        ] )
    }
    else {
        BIcalcTimer.reschedule(now.plusSeconds(delaySec))
    }
end

Scripts (only Get Data and Example Berlin and because of little different Germany in total)

CoVid19_1_GetData_RKI-Impfungen.sh (Package with xlsx2csv needed)

#! /bin/bash
cd /tmp
RUNTIME=`date +%Y-%m-%d`
if [ ! -f /tmp/$RUNTIME.xlsx ]
then
    mv CoVid_Data_RKI_D_Impfdaten.xlsx /tmp/$RUNTIME.xlsx
else
    rm CoVid_Data_RKI_D_Impfdaten.xlsx
fi
rm CoVid_Data_RKI_D_Impfdaten.csv
DELE=$(/bin/wget -q -O CoVid_Data_RKI_D_Impfdaten.xlsx 'https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Daten/Impfquotenmonitoring.xlsx?__blob=publicationFile')
CONV=$(xlsx2csv CoVid_Data_RKI_D_Impfdaten.xlsx -a > CoVid_Data_RKI_D_Impfdaten.csv)
DATA="got it"
echo $DATA

Script CoVid19_8_RKI_B_Impfdose1.sh

#! /bin/bash
DATA=$(cat /tmp/CoVid_Data_RKI_D_Impfdaten.csv | grep "Berlin" -m 1 | cut -d, -f4)
echo $DATA

Script CoVid19_8_RKI_B_Impfdose2.sh

#! /bin/bash
DATA=$(cat /tmp/CoVid_Data_RKI_D_Impfdaten.csv | grep "Berlin" -m 1 | cut -d, -f10)
echo $DATA

Script CoVid19_8_RKI_B_Impfdosen.sh

#! /bin/bash
DATA=$(cat /tmp/CoVid_Data_RKI_D_Impfdaten.csv | grep "Berlin" -m 1 | cut -d, -f3)
echo $DATA

Script CoVid19_8_RKI_D_Impfdose1.sh

#! /bin/bash
DATA=$(cat /tmp/CoVid_Data_RKI_D_Impfdaten.csv | grep ",Gesamt," -m2 | grep -v Moderna | cut -d, -f4)
echo $DATA

Script CoVid19_8_RKI_D_Impfdose2.sh

#! /bin/bash
DATA=$(cat /tmp/CoVid_Data_RKI_D_Impfdaten.csv | grep ",Gesamt," -m2 | grep -v Moderna | cut -d, -f10)
echo $DATA

Script CoVid19_8_RKI_D_Impfdosen.sh

#! /bin/bash
DATA=$(cat /tmp/CoVid_Data_RKI_D_Impfdaten.csv | grep ",Gesamt," -m 2 | grep -v BioNTech | cut -d, -f3)
echo $DATA

I hope I didn’t forget something.

Remember:

  • New vaccines: In scripts impfdosis2 the field in grep has to be raised, otherwise value of percent will be overtaken
  • Sometimes the RKI changes somes Texts in Excel, so grep ,Gesamt, won’t work, then you need to change the script D over all
  • If want to calculate ETA for other regions, you need to change in rules the amount of e.g. 50% citizens need to got the vaccine to the 50% citizens of those other region.
2 Likes

Hey,

I am using a quite simple solution for germany that I want to share with you. You need the http binding, then you can get the values from https://api.corona-zahlen.org . Visit the webpage, on Endpoints you can easily click through the API and see the generated JSON if you want to adapt to your Districts / State / … . You can also get the vaccinations very detailed, and a lot more. Nice service!

Items

Number  Corona_LK_Regensburg_Incidence "LK Rgbg 7d [%.1f]"      <line>(store){http="<[https://api.corona-zahlen.org/districts/09375:3600000:JSONPATH($.data.09375.weekIncidence)]"}
Number  Corona_S_Regensburg_Incidence  "Stadt Rgbg 7d [%.1f]"   <line>(store){http="<[https://api.corona-zahlen.org/districts/09362:3600000:JSONPATH($.data.09362.weekIncidence)]"}
Number  Corona_Deutschland_Incidence   "Deutschland 7d [%.1f]"  <line>(store){http="<[https://api.corona-zahlen.org/germany:3600000:JSONPATH($.weekIncidence)]"}
Number  Corona_Deutschland_R           "Deutschland R [%.2f]"   <chart>(store){http="<[https://api.corona-zahlen.org/germany:3600000:JSONPATH($.r.value)]"}

Sitemap

Frame label="Corona"{
    Default item=Corona_LK_Regensburg_Incidence
    Default item=Corona_S_Regensburg_Incidence
    Default item=Corona_Deutschland_Incidence
    Default item=Corona_Deutschland_R
}

rule to send me the values each morning as notification

rule "Corona Daily News"
    when
        Time cron "0 0 6 * * ?"
    then
        sendNotification(<E-Mail>, 
            "Land Rgbg: " + String.format("%.1f", (Corona_LK_Regensburg_Incidence.state as Number).floatValue) + ", " +
            "Stadt Rgbg: " + String.format("%.1f", (Corona_S_Regensburg_Incidence.state as Number).floatValue) + ", " +
            "DE: " + String.format("%.1f", (Corona_Deutschland_Incidence.state as Number).floatValue) + ", " +
            "DE r: " + String.format("%.2f", (Corona_Deutschland_R.state as Number).floatValue))
    end
4 Likes

Thank you! Finally an API to get vaccination data, too! That’s great!

Hey,

I am new to openhab 3. Please have a look at my code:

UID: http:url:rki
label: RKI Daten
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: https://api.corona-zahlen.org/
  refresh: 30
  commandMethod: GET
  contentType: application/json
  timeout: 3000
  bufferSize: 2048
channels:
  - id: Regensburg
    channelTypeUID: http:string
    label: Regensburg
    description: ""
    configuration:
      mode: READONLY
      stateExtension: districts/09375
      stateTransformation: JSONPATH($.data.09375.weekIncidence)

The stateTransformation is wrong. I only get NULL. When I delete this line, I get the complete json.

I hope you can help me!