COVID-19
Hey all,
I built out a datasource to monitor the COVID-19 cases and deaths per state. An API key from Finnhub.io is required to run this DataSource. The API key must be saved as a custom property on the device you want this DataSource applied to. The Custom Propery name needs to be "finhubb.api.key" with the value being the Finnhub.io API key. Finnhub.io offers a free API key teir that allows 60 queries a minute.

Locator Code: M9WGM3

mkerfoot
10 comments
mkerfoot
OPMy hero! Thanks again for all the hard work!
LM User
FYI, i've started a github repo with my personal datasources, including the groovy version of this one: https://github.com/sweenig/lmcommunity. Feel free to grab anything from there.
LM User
Yeah, the groovy version had that problem too. I didn't notice the trailing space, but I did notice a record with a name of " " and one that had a leading space. If you look at the groovy code, you'll see a .trim() method that eliminates that.
mkerfoot
OPThat is a good point. I found a little bug too. the API is returning "Colorado " with a space at the end which was returning NaN in the script. I did a ghetto little workaround.
Its not pretty but it works. lol
if($wildvalue -eq "Colorado"){
$Case = ($Data | Where-Object State -eq "Colorado ").case
$Death = ($Data | Where-Object State -eq "Colorado ").death
Write-Host Cases=$Case
Write-Host Deaths=$Death
}else{
$Data = $Return | Select-Object -ExpandProperty Content | ConvertFrom-Json
$Case = ($Data | Where-Object State -eq $wildvalue).case
$Death = ($Data | Where-Object State -eq $wildvalue).death
Write-Host Cases=$Case
Write-Host Deaths=$Death
}
LM User
Just had a realization. If you aren't interested in all states, you could apply a discovery filter to only include those states where your company has offices.
LM User
Also, I added some graphs. Also, I just committed a new version that groups by country.
LM User
Alright, try this: https://github.com/sweenig/lmcommunity/blob/master/COVID19_by_State/COVID19_by_State.xml
Besides converting to groovy, I converted it to batchscript vs. script. This means that instead of making one call per state ever poll cycle, it makes one call and parses out all the data from that one call. Should help if finnhub ever decides to lower the api limit.
mkerfoot
OPHave at it, @Stuart Weenig!
LM User
Took me a minute to notice that this requires a Windows collector since it's powershell. With your permission, I may rewrite the scripts to groovy so they can run on either Windows or Linux.
mkerfoot
OPXML;