Hi,
Here is a simple DZvents timer script to track the data from the Revoke Article 50 petition
return {
active = true,
on = {
timer = { 'every 5 minutes' },
httpResponses = { 'art50revoke' } -- matches callback string below
} ,
execute = function(domoticz, item)
if (item.isTimer) then
domoticz.openURL({
url = 'https://petition.parliament.uk/petitions/241584.json',
method = 'GET',
callback = 'art50revoke'

end
if (item.isHTTPResponse and item.ok) then
if (item.isJSON) then -- statusCode == 2xx
domoticz.log(item.json.data.attributes.signature_count)
domoticz.devices('Art 50 revoke signatures').updateCustomSensor(item.json.data.attributes.signature_count)
else
-- oops
-- domoticz.log('Error Petition data not in JSON', domoticz.LOG_ERROR)
end
end
end
}
create dummy device with name 'Art 50 revoke signatures', type: custom sensor, x-axis 'signatures'. Will be added to your Utility tab, why not
Here is a simple DZvents timer script to track the data from the Revoke Article 50 petition
return {
active = true,
on = {
timer = { 'every 5 minutes' },
httpResponses = { 'art50revoke' } -- matches callback string below
} ,
execute = function(domoticz, item)
if (item.isTimer) then
domoticz.openURL({
url = 'https://petition.parliament.uk/petitions/241584.json',
method = 'GET',
callback = 'art50revoke'
end
if (item.isHTTPResponse and item.ok) then
if (item.isJSON) then -- statusCode == 2xx
domoticz.log(item.json.data.attributes.signature_count)
domoticz.devices('Art 50 revoke signatures').updateCustomSensor(item.json.data.attributes.signature_count)
else
-- oops
-- domoticz.log('Error Petition data not in JSON', domoticz.LOG_ERROR)
end
end
end
}
create dummy device with name 'Art 50 revoke signatures', type: custom sensor, x-axis 'signatures'. Will be added to your Utility tab, why not