j ai vue ça avec api domogeek http://api.domogeek.fr/schoolholiday/C/now je ne sais pas comment faire le script
merci pour votre aide
Code : Tout sélectionner
-- domoticz/scripts/lua/script_time_vacances.lua
-- School Holiday Status Request from Domogeek API
-- http://api.domogeek.fr/static/doc/index.html#api-Domogeek-GetSchoolHoliday
-- Prerequis: 3 switch On/Off: "Zone A", "Zone B", "Zone C"
-- Path to curl
-- Windows: curl = 'C:\\bin\\curl.exe'
curl = "curl"
-- Devices (Switch On/Off on virtual hardware)
switchA = "Zone A"
switchB = "Zone B"
switchC = "Zone C"
-- Function to get result of HTTP request
function os.capture(cmd, raw)
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
if raw then return s end
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', ' ')
return s
end
-- Function to update a switch
function updateZoneSwitch(zone, switch)
local cmd = curl .. " http://api.domogeek.fr/schoolholiday/" .. zone .. "/now"
local vac = os.capture(cmd, true)
print("¤¤¤ School Holiday Status: " .. cmd .. ": " .. vac)
if (vac == "False") then
if (otherdevices[switch] == "On") then
commandArray[switch] = "Off";
end
else
if (otherdevices[switch] == "Off") then
commandArray[switch] = "On";
end
end
end
commandArray = {}
time = os.date("*t")
-- Trigger at 0:02 every day
if (time.min == 2 and time.hour == 0) then
-- Zone A
updateZoneSwitch("A", switchA)
-- Zone B
updateZoneSwitch("B", switchB)
-- Zone C
updateZoneSwitch("C", switchC)
end
return commandArray
Normalement, tous les jours à 0:02, il fait l'appel à l'API: http://api.domogeek.fr/schoolholiday/A/nowatlantis007 a écrit :j ai un souci avec le script il ne me récupère pas info vacance tous les jour juste le jour ou on le met en place
Code : Tout sélectionner
2015-02-05 00:02:00 LUA: ¤¤¤ School Holiday Status: C:\bin\curl.exe http://api.domogeek.fr/schoolholiday/A/now: False
2015-02-05 00:02:00 LUA: ¤¤¤ School Holiday Status: C:\bin\curl.exe http://api.domogeek.fr/schoolholiday/B/now: False
2015-02-05 00:02:01 LUA: ¤¤¤ School Holiday Status: C:\bin\curl.exe http://api.domogeek.fr/schoolholiday/C/now: False