HTTPResponses array?
Posted: Monday 30 March 2020 13:48
I wish query a website several times by changing a parameter for each request in the same script
with the domoticz.openURL command
httpTesponses can be an array?
how to recover the name of multiple httpresponses?
the beginning of my script
with the domoticz.openURL command
httpTesponses can be an array?
how to recover the name of multiple httpresponses?
the beginning of my script
Code: Select all
local les_horoscopes = {}
les_horoscopes[#les_horoscopes+1] = {device = 'Horoscope 1', signe = 'belier'}
les_horoscopes[#les_horoscopes+1] = {device = 'Horoscope 2', signe = 'taureau'}
local horoscope = ''
local device = ''
local signe = ''
local site_url = 'https://astro.rtl.fr/horoscope-jour-gratuit' -- url
return {
active = true,
on = {
timer = { 'every hour' },--https://www.domoticz.com/wiki/DzVents:_next_generation_LUA_scripting#timer_trigger_rules
httpResponses = { 'belier, taureau, gemeaux, cancer, lion, vierge, balance, scorpion, sagittaire, capricorne, verseau, poissons' } -- Trigger
},
execute = function(dz, item)
local function logWrite(str,level) -- Support function for shorthand debug log statements
dz.log(tostring(str),level or dz.LOG_DEBUG)
end
if (item.isTimer) then
for k,v in pairs(les_horoscopes) do-- On parcourt chaque horoscope
device = v.device
if device ~= nil and device ~= '' and dz.devices(device).name ~= nil then
logWrite('--- --- --- traitement '..device..' --- --- --')
signe = v.signe
dz.openURL({--https://www.domoticz.com/wiki/DzVents:_next_generation_LUA_scripting#httpResponses
url = site_url..'/'..signe,
callback = signe
})
end
end --for
end
if (item.isHTTPResponse and item.ok) then
for k,v in pairs(les_horoscopes) do-- On parcourt chaque horoscope
device = v.device
if device ~= nil and device ~= '' and dz.devices(device).name ~= nil then
logWrite('--- --- --- traitement '..device..' --- --- --')
signe = v.signe
end
end --for
--test the callback name or httpresponsename
end
end
}