return { on = { timer = { 'every 30 minutes'}, system = { 'start', }, httpResponses = { 'Status_Corona', -- must match with the callback passed to the openURL command }, }, logging = { level = domoticz.LOG_INFO,ERROR, marker = 'Polska', }, execute = function(domoticz, item) local country = 'Poland' 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('Wszystkie Polska').updateCounter(item.json.cases) domoticz.devices('Zgony Polska').updateCounter(item.json.deaths) domoticz.devices('Wyleczeni Polska').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 }