CORONAVIRUS
Moderators: leecollings, remb0
- laco
- Posts: 86
- Joined: Tuesday 30 October 2018 12:57
- Target OS: NAS (Synology & others)
- Domoticz version: 2021.1
- Location: Slovensko
- Contact:
CORONAVIRUS
Can anyone create a dzvents script from coronavirus data into virtual scanners?
API:
World: https://coronavirus-19-api.herokuapp.com/all
Slovakia: https://coronavirus-19-api.herokuapp.co ... s/Slovakia
well thank you
API:
World: https://coronavirus-19-api.herokuapp.com/all
Slovakia: https://coronavirus-19-api.herokuapp.co ... s/Slovakia
well thank you
- felix63
- Posts: 244
- Joined: Monday 07 December 2015 9:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.1
- Location: Gouda
- Contact:
Re: CORONAVIRUS
Create two (or more) virtual counters and edit the type of the counter to 'Counter'. I use
'Corona deaths total'
'Corona deaths today'
In the script change the local variable to reflect the country you want to collect the data from. Typically the data gets updated just once per day so there is no need to run it more often.
The script:
'Corona deaths total'
'Corona deaths today'
In the script change the local variable to reflect the country you want to collect the data from. Typically the data gets updated just once per day so there is no need to run it more often.
The script:
Code: Select all
return {
-- Function:
--
-- This script retrieves static data from RPI-monitor instances.
-- The script uses the RPI-monitor API to retrieve static data once a month or at restart. The data is stored in
-- custom variables.
--
on = {
timer = {
'every day at 15:45' -- just an example to trigger the request
},
system = {
'start',
},
httpResponses = {
'Status_Corona', -- must match with the callback passed to the openURL command
},
},
execute = function(domoticz, item)
local country = 'Netherlands'
if (item.isTimer or item.isDevice or item.isService) then
domoticz.openURL({
url = 'https://coronavirus-19-api.herokuapp.com/countries/' .. country,
method = 'GET',
callback = 'Status_Corona', -- see httpResponses above.
})
end
if (item.isHTTPResponse) then
if (item.statusCode == 200) then
if (item.isJSON) then
if (item.callback == 'Status_Corona') then
domoticz.devices('Corona deaths today').updateCounter(item.json.todayDeaths)
domoticz.devices('Corona deaths total').updateCounter(item.json.deaths)
end
end
else
domoticz.log('There was a problem handling the request ' .. item.callback, domoticz.LOG_ERROR)
domoticz.log(item, domoticz.LOG_ERROR)
end
end
end
}
- laco
- Posts: 86
- Joined: Tuesday 30 October 2018 12:57
- Target OS: NAS (Synology & others)
- Domoticz version: 2021.1
- Location: Slovensko
- Contact:
Re: CORONAVIRUS
Thank you, it works great.
World data is updated on an ongoing basis.
How do I make them update every 10 minutes, for example?
https://coronavirus-19-api.herokuapp.com/all
World data is updated on an ongoing basis.
How do I make them update every 10 minutes, for example?
https://coronavirus-19-api.herokuapp.com/all
- laco
- Posts: 86
- Joined: Tuesday 30 October 2018 12:57
- Target OS: NAS (Synology & others)
- Domoticz version: 2021.1
- Location: Slovensko
- Contact:
Re: CORONAVIRUS
I've already found it
Code: Select all
timer = { 'every 10 minutes'}
-
- Posts: 247
- Joined: Sunday 29 November 2015 20:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.9639
- Location: Spain
- Contact:
Re: CORONAVIRUS
You can do that yourself easily Laco.laco wrote: ↑Sunday 22 March 2020 17:58 Can you create a script for the world?
https://coronavirus-19-api.herokuapp.com/all
Thank you!
1. Create a new sensor for total deaths worldwide (the api does not output numbers of deaths per day)
2. Change the callback on line 17 and 28 --> they have to be equal and not be the same as the one from another script
3. Change the url on line 26 to https://coronavirus-19-api.herokuapp.com/all --> make sure to remove the part .. country
4. Put the name of that sensor on line 37 instead of ('Corona deaths total')
5. Remove line 36
- laco
- Posts: 86
- Joined: Tuesday 30 October 2018 12:57
- Target OS: NAS (Synology & others)
- Domoticz version: 2021.1
- Location: Slovensko
- Contact:
Re: CORONAVIRUS
Well thank you.
I enclose a finished dzvents script if someone needed Slovakia and the world
SK:
World:
I enclose a finished dzvents script if someone needed Slovakia and the world
SK:
Code: Select all
return {
-- Function:
--
-- This script retrieves static data from RPI-monitor instances.
-- The script uses the RPI-monitor API to retrieve static data once a month or at restart. The data is stored in
-- custom variables.
--
on = {
timer = { 'every 30 minutes'},
system = {
'start',
},
httpResponses = {
'Status_Corona', -- must match with the callback passed to the openURL command
},
},
execute = function(domoticz, item)
local country = 'Slovakia'
if (item.isTimer or item.isDevice or item.isService) then
domoticz.openURL({
url = 'https://coronavirus-19-api.herokuapp.com/countries/' .. country,
method = 'GET',
callback = 'Status_Corona', -- see httpResponses above.
})
end
if (item.isHTTPResponse) then
if (item.statusCode == 200) then
if (item.isJSON) then
if (item.callback == 'Status_Corona') then
domoticz.devices('Corona nakazení Slovensko').updateCounter(item.json.cases)
domoticz.devices('Corona zomreli dnes').updateCounter(item.json.todayDeaths)
domoticz.devices('Corona zomreli celkovo').updateCounter(item.json.deaths)
end
end
else
domoticz.log('There was a problem handling the request ' .. item.callback, domoticz.LOG_ERROR)
domoticz.log(item, domoticz.LOG_ERROR)
end
end
end
}
Code: Select all
return {
-- Function:
--
-- This script retrieves static data from RPI-monitor instances.
-- The script uses the RPI-monitor API to retrieve static data once a month or at restart. The data is stored in
-- custom variables.
--
on = {
timer = { 'every 10 minutes'},
system = {
'start',
},
httpResponses = {
'Status_Corona_all', -- must match with the callback passed to the openURL command
},
},
execute = function(domoticz, item)
local country = 'all'
if (item.isTimer or item.isDevice or item.isService) then
domoticz.openURL({
url = 'https://coronavirus-19-api.herokuapp.com/' .. country,
method = 'GET',
callback = 'Status_Corona_all', -- see httpResponses above.
})
end
if (item.isHTTPResponse) then
if (item.statusCode == 200) then
if (item.isJSON) then
if (item.callback == 'Status_Corona_all') then
domoticz.devices('Corona nakazení vo svete').updateCounter(item.json.cases)
domoticz.devices('Corona zomreli vo svete').updateCounter(item.json.deaths)
domoticz.devices('Corona uzdravení vo svete').updateCounter(item.json.recovered)
end
end
else
domoticz.log('There was a problem handling the request ' .. item.callback, domoticz.LOG_ERROR)
domoticz.log(item, domoticz.LOG_ERROR)
end
end
end
}
-
- Posts: 18
- Joined: Sunday 12 February 2017 15:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: CORONAVIRUS
Works great, thx. Now let's all hope this counters will stop counting.
-
- Posts: 247
- Joined: Sunday 29 November 2015 20:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.9639
- Location: Spain
- Contact:
Re: CORONAVIRUS
HI.
I made 2 custom icons for the counters.
One represents the corona virus, the other one is for the number of deaths counter
https://www.domoticz.com/forum/viewtopi ... 33#p240233
I made 2 custom icons for the counters.
One represents the corona virus, the other one is for the number of deaths counter
https://www.domoticz.com/forum/viewtopi ... 33#p240233
-
- Posts: 198
- Joined: Thursday 06 October 2016 8:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.7243
- Contact:
Re: CORONAVIRUS
I'm trying to add a script and I can't do anything about it.
Errors only in logs.
What script is this supposed to be? lua, python, dzVents?
Is the script to be added in Events?
Which sensor should I choose exactly?
Counter / Counter?
Do I need to add anything to the sensor settings?
P.S.
Everything is working now
Tell me how to set a notification to Telegram
If the number of infected increases by at least 1 then send a message
I have set:
Last update
Greater
Value (I don't know what to insert here)
Errors only in logs.
What script is this supposed to be? lua, python, dzVents?
Is the script to be added in Events?
Which sensor should I choose exactly?
Counter / Counter?
Do I need to add anything to the sensor settings?
P.S.
Everything is working now
Tell me how to set a notification to Telegram
If the number of infected increases by at least 1 then send a message
I have set:
Last update
Greater
Value (I don't know what to insert here)
- laco
- Posts: 86
- Joined: Tuesday 30 October 2018 12:57
- Target OS: NAS (Synology & others)
- Domoticz version: 2021.1
- Location: Slovensko
- Contact:
Re: CORONAVIRUS
How do I change the counter icon?elmortero wrote: ↑Sunday 22 March 2020 21:55 HI.
I made 2 custom icons for the counters.
One represents the corona virus, the other one is for the number of deaths counter
https://www.domoticz.com/forum/viewtopi ... 33#p240233
I don't see an option.
-
- Posts: 247
- Joined: Sunday 29 November 2015 20:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.9639
- Location: Spain
- Contact:
Re: CORONAVIRUS
First go to Setup--Custom Icon -menu to upload the zip files with the icons
Then click on the Edit button of your counter in order to select a sensor icon
Then click on the Edit button of your counter in order to select a sensor icon
-
- Posts: 247
- Joined: Sunday 29 November 2015 20:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.9639
- Location: Spain
- Contact:
Re: CORONAVIRUS
try this one (adapt your settings to your needs)
Code: Select all
return {
-- Function:
--
-- This script retrieves static data from RPI-monitor instances.
-- The script uses the RPI-monitor API to retrieve static data once a month or at restart. The data is stored in
-- custom variables.
--
on = {
timer = { 'every 30 minutes'},
system = {
'start',
},
httpResponses = {
'Status_Corona', -- must match with the callback passed to the openURL command
},
},
execute = function(domoticz, item)
local country = 'Slovakia'
if (item.isTimer or item.isDevice or item.isService) then
domoticz.openURL({
url = 'https://coronavirus-19-api.herokuapp.com/countries/' .. country,
method = 'GET',
callback = 'Status_Corona', -- see httpResponses above.
})
end
if (item.isHTTPResponse) then
if (item.statusCode == 200) then
if (item.isJSON) then
if (item.callback == 'Status_Corona') then
local prevcountC = domoticz.devices('Corona nakazení Slovensko').counter --get the value of the counter for cases
local prevcountT = domoticz.devices('Corona zomreli dnes').counter --get the value of the counter for todayDeaths
local prevcountD = domoticz.devices('Corona zomreli celkovo').counter --get the value of the counter for (total)deaths
domoticz.devices('Corona nakazení Slovensko').updateCounter(item.json.cases)
domoticz.devices('Corona zomreli dnes').updateCounter(item.json.todayDeaths)
domoticz.devices('Corona zomreli celkovo').updateCounter(item.json.deaths)
if item.json.cases > prevcountC then -- change cases to todayDeaths or deaths according to what you want to
-- compare and change prevcountC also accordingly
--your actions/notifications here
end
end
end
else
domoticz.log('There was a problem handling the request ' .. item.callback, domoticz.LOG_ERROR)
domoticz.log(item, domoticz.LOG_ERROR)
end
end
end
}
- gielie
- Posts: 290
- Joined: Tuesday 12 January 2016 11:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest β
- Location: The Netherlands (Alkmaar)
- Contact:
Re: CORONAVIRUS
I have the same problem, to my knowledge you can not change a counter icon, so im very curious how ts did this.
If I create a custom sensor it won't get updated, if I create a counter it does work but without changing the icon
- Aeon Labs USB Stick met Z-wave plus
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
-
- Posts: 247
- Joined: Sunday 29 November 2015 20:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.9639
- Location: Spain
- Contact:
Re: CORONAVIRUS
My mistake guys.
Counter icons cannot be changed.
I used custom sensor and not a counter in my setup
Counter icons cannot be changed.
I used custom sensor and not a counter in my setup
-
- Posts: 198
- Joined: Thursday 06 October 2016 8:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.7243
- Contact:
Re: CORONAVIRUS
What should I enter in the Value field?elmortero wrote: ↑Wednesday 25 March 2020 13:49try this one (adapt your settings to your needs)Code: Select all
return { -- Function: -- -- This script retrieves static data from RPI-monitor instances. -- The script uses the RPI-monitor API to retrieve static data once a month or at restart. The data is stored in -- custom variables. -- on = { timer = { 'every 30 minutes'}, system = { 'start', }, httpResponses = { 'Status_Corona', -- must match with the callback passed to the openURL command }, }, execute = function(domoticz, item) local country = 'Slovakia' if (item.isTimer or item.isDevice or item.isService) then domoticz.openURL({ url = 'https://coronavirus-19-api.herokuapp.com/countries/' .. country, method = 'GET', callback = 'Status_Corona', -- see httpResponses above. }) end if (item.isHTTPResponse) then if (item.statusCode == 200) then if (item.isJSON) then if (item.callback == 'Status_Corona') then local prevcountC = domoticz.devices('Corona nakazení Slovensko').counter --get the value of the counter for cases local prevcountT = domoticz.devices('Corona zomreli dnes').counter --get the value of the counter for todayDeaths local prevcountD = domoticz.devices('Corona zomreli celkovo').counter --get the value of the counter for (total)deaths domoticz.devices('Corona nakazení Slovensko').updateCounter(item.json.cases) domoticz.devices('Corona zomreli dnes').updateCounter(item.json.todayDeaths) domoticz.devices('Corona zomreli celkovo').updateCounter(item.json.deaths) if item.json.cases > prevcountC then -- change cases to todayDeaths or deaths according to what you want to -- compare and change prevcountC also accordingly --your actions/notifications here end end end else domoticz.log('There was a problem handling the request ' .. item.callback, domoticz.LOG_ERROR) domoticz.log(item, domoticz.LOG_ERROR) end end end }
- Attachments
-
- telegram.jpg (77.23 KiB) Viewed 1705 times
- gielie
- Posts: 290
- Joined: Tuesday 12 January 2016 11:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest β
- Location: The Netherlands (Alkmaar)
- Contact:
Re: CORONAVIRUS
I think you made a mistake with this one too because a custom sensor cannot be updated with the info form your script resulting in the following error.
Code: Select all
Error (2.4.19): Method updateCounter is not available for device "Corona Sick" (deviceType=General, deviceSubType=Custom Sensor). If you believe this is not correct, please report.
- Aeon Labs USB Stick met Z-wave plus
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
-
- Posts: 132
- Joined: Monday 07 August 2017 17:17
- Target OS: Linux
- Domoticz version: Latest β
- Location: Near London (Saaarf!)
- Contact:
Re: CORONAVIRUS
You just need to change ".updateCounter" to ".updateCustomSensor" to the appropriate lines in your script.gielie wrote: ↑Thursday 26 March 2020 14:18I think you made a mistake with this one too because a custom sensor cannot be updated with the info form your script resulting in the following error.Can you explain step by step what you did exactly?Code: Select all
Error (2.4.19): Method updateCounter is not available for device "Corona Sick" (deviceType=General, deviceSubType=Custom Sensor). If you believe this is not correct, please report.
Domoticz Latest β, RPi 4B with 110Gb SSD for Domoticz, RPi 4B with 110Gb SSD for Node-Red & a RPi 2B for logging / IP addressing. RFXCOM, PiZiGate, Z-Wave, Harmony, Hue lamps and a bit of Broadlink.
-
- Posts: 3
- Joined: Friday 24 April 2020 19:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.1
- Location: Polska
- Contact:
Re: CORONAVIRUS
Hello
At the beginning I would like to apologize for my English, but I use Google's translator
I wanted to add to my Domoticz (Version: 2020.1) the above counters. I did everything as described, i.e. I added counter devices, the same names as in the scripts, but unfortunately the counters do not count anything. There are no errors in the logs. How can you check why scripts don't work?
EDIT:
It is working now:)
dzVents was disabled in: Configuration, Settings, Other
... and may the meter stop as soon as possible
EDIT2:
Please, give me a hint how to modify the code to download data about infected in specific regions or cities available on this page:
https://apify.com/vaclavrut/covid-pl
https://api.apify.com/v2/key-value-stor ... irect=true - region
https://api.apify.com/v2/datasets/L3VCm ... on&clean=1 - city
At the beginning I would like to apologize for my English, but I use Google's translator
I wanted to add to my Domoticz (Version: 2020.1) the above counters. I did everything as described, i.e. I added counter devices, the same names as in the scripts, but unfortunately the counters do not count anything. There are no errors in the logs. How can you check why scripts don't work?
EDIT:
It is working now:)
dzVents was disabled in: Configuration, Settings, Other
... and may the meter stop as soon as possible
EDIT2:
Please, give me a hint how to modify the code to download data about infected in specific regions or cities available on this page:
https://apify.com/vaclavrut/covid-pl
https://api.apify.com/v2/key-value-stor ... irect=true - region
https://api.apify.com/v2/datasets/L3VCm ... on&clean=1 - city
Who is online
Users browsing this forum: No registered users and 1 guest