return { on = { timer = { 'every 15 minutes'}, system = {'start', }, httpResponses = { 'Status_Corona_all', -- must match with the callback passed to the openURL command }, }, logging = { level = domoticz.LOG_INFO,ERROR, marker = 'Swiat', }, 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('Wszyscy świat').updateCounter(item.json.cases) domoticz.devices('Zgony świat').updateCounter(item.json.deaths) domoticz.devices('Wyleczeni świat').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 }