Quand on regarde ta ligne du timer id et l'exemple qu'on t'a donné, il y a 2 erreurs : L / l et ( / {
Il faut un peu se relire et chercher surtout quand on débute
Code : Tout sélectionner
local mon_ip = "127.0.0.1:8080"
commandArray = {}
if (devicechanged['Mode chauffage'] == 'Auto') then
local timer_id = {"11","16","17","10","12","13","14","15","8","9"}
for i,v in ipairs (timer_id) do
cmd_timer = "curl " .. '"' .. mon_ip .. "/json.htm?type=command¶m=enabletimer&idx=" .. v ..'"'
print ("Commande envoyée : " .. cmd_timer)
ret = os.execute (cmd_timer)
end
local idx_id = {"37","40","74","43"}
for i,v in ipairs (idx_id) do
cmd_setpoint = "curl " .. '"' .. mon_ip .. "/json.htm?type=command¶m=setsetpoint&idx=" .. v .. "setpoint=19" .. '"'
print ("Commande envoyée : " .. cmd_setpoint)
ret = os.execute (cmd_setpoint)
end
elseif (devicechanged['Mode chauffage'] == 'Confort') then
local timer_id = {"11","16","17","10","12","13","14","15","8","9"}
for i,v in ipairs (timer_id) do
cmd_timer = "curl " .. '"' .. mon_ip .. "/json.htm?type=command¶m=disabletimer&idx=" .. v ..'"'
print ("Commande envoyée : " .. cmd_timer)
ret = os.execute (cmd_timer)
end
local idx_id = {"37","40","74","43"}
for i,v in ipairs (idx_id) do
cmd_setpoint = "curl " .. '"' .. mon_ip .. "/json.htm?type=command¶m=setsetpoint&idx=" .. v .. "setpoint=21" .. '"'
print ("Commande envoyée : " .. cmd_setpoint)
ret = os.execute (cmd_setpoint)
end
elseif (devicechanged['Mode chauffage'] == 'Eco') then
local timer_id = {"11","16","17","10","12","13","14","15","8","9"}
for i,v in ipairs (timer_id) do
cmd_timer = "curl " .. '"' .. mon_ip .. "/json.htm?type=command¶m=disabletimer&idx=" .. v ..'"'
print ("Commande envoyée : " .. cmd_timer)
ret = os.execute (cmd_timer)
end
local idx_id = {"37","40","74","43"}
for i,v in ipairs (idx_id) do
cmd_setpoint = "curl " .. '"' .. mon_ip .. "/json.htm?type=command¶m=setsetpoint&idx=" .. v .. "setpoint=14" .. '"'
print ("Commande envoyée : " .. cmd_setpoint)
ret = os.execute (cmd_setpoint)
end
elseif (devicechanged['Mode chauffage'] == 'Absent') then
local timer_id = {"11","16","17","10","12","13","14","15","8","9"}
for i,v in ipairs (timer_id) do
cmd_timer = "curl " .. '"' .. mon_ip .. "/json.htm?type=command¶m=disabletimer&idx=" .. v ..'"'
print ("Commande envoyée : " .. cmd_timer)
ret = os.execute (cmd_timer)
end
local idx_id = {"37","40","74","43"}
for i,v in ipairs (idx_id) do
cmd_setpoint = "curl " .. '"' .. mon_ip .. "/json.htm?type=command¶m=setsetpoint&idx=" .. v .. "setpoint=10" .. '"'
print ("Commande envoyée : " .. cmd_setpoint)
ret = os.execute (cmd_setpoint)
end
elseif (devicechanged['Mode chauffage'] == 'Ete') then
local timer_id = {"11","16","17","10","12","13","14","15","8","9"}
for i,v in ipairs (timer_id) do
cmd_timer = "curl " .. '"' .. mon_ip .. "/json.htm?type=command¶m=disabletimer&idx=" .. v ..'"'
print ("Commande envoyée : " .. cmd_timer)
ret = os.execute (cmd_timer)
end
local idx_id = {"37","40","74","43"}
for i,v in ipairs (idx_id) do
cmd_setpoint = "curl " .. '"' .. mon_ip .. "/json.htm?type=command¶m=setsetpoint&idx=" .. v .. "setpoint=28" .. '"'
print ("Commande envoyée : " .. cmd_setpoint)
ret = os.execute (cmd_setpoint)
end
return commandArray
endCode : Tout sélectionner
2019-09-21 15:36:00.572 Error: EventSystem: in script_device_chauffage.lua: [string "local mon_ip = "127.0.0.1:8080"..."]:3: attempt to index global 'devicechanged' (a nil value)Code : Tout sélectionner
2019-09-21 15:41:53.216 Status: User: Admin initiated a switch command (75/Mode chauffage/Set Level)
2019-09-21 15:41:53.476 Status: LUA: Commande envoyée : curl "127.0.0.1:8080/json.htm?type=command¶m=disabletimer&idx=11"
2019-09-21 15:41:53.554 Status: Incoming connection from: 127.0.0.1
2019-09-21 15:41:53.562 Status: LUA: Commande envoyée : curl "127.0.0.1:8080/json.htm?type=command¶m=disabletimer&idx=16"
2019-09-21 15:41:53.647 Status: LUA: Commande envoyée : curl "127.0.0.1:8080/json.htm?type=command¶m=disabletimer&idx=17"
2019-09-21 15:41:53.732 Status: LUA: Commande envoyée : curl "127.0.0.1:8080/json.htm?type=command¶m=disabletimer&idx=10"
2019-09-21 15:41:53.818 Status: LUA: Commande envoyée : curl "127.0.0.1:8080/json.htm?type=command¶m=disabletimer&idx=12"
2019-09-21 15:41:53.908 Status: LUA: Commande envoyée : curl "127.0.0.1:8080/json.htm?type=command¶m=disabletimer&idx=13"
2019-09-21 15:41:53.993 Status: LUA: Commande envoyée : curl "127.0.0.1:8080/json.htm?type=command¶m=disabletimer&idx=14"
2019-09-21 15:41:53.225 Error: SQLHelper: Error script not found '/home/pi/domoticz/scripts/lua/script_device_chauffage.lua'
2019-09-21 15:41:54.083 Status: LUA: Commande envoyée : curl "127.0.0.1:8080/json.htm?type=command¶m=disabletimer&idx=15"
2019-09-21 15:41:54.204 Status: LUA: Commande envoyée : curl "127.0.0.1:8080/json.htm?type=command¶m=disabletimer&idx=8"
2019-09-21 15:41:54.307 Status: LUA: Commande envoyée : curl "127.0.0.1:8080/json.htm?type=command¶m=disabletimer&idx=9"
2019-09-21 15:41:54.400 Status: LUA: Commande envoyée : curl "127.0.0.1:8080/json.htm?type=command¶m=setsetpoint&idx=37setpoint=14"
2019-09-21 15:41:54.486 Status: LUA: Commande envoyée : curl "127.0.0.1:8080/json.htm?type=command¶m=setsetpoint&idx=40setpoint=14"
2019-09-21 15:41:54.566 Status: LUA: Commande envoyée : curl "127.0.0.1:8080/json.htm?type=command¶m=setsetpoint&idx=74setpoint=14"
2019-09-21 15:41:54.651 Status: LUA: Commande envoyée : curl "127.0.0.1:8080/json.htm?type=command¶m=setsetpoint&idx=43setpoint=14"
2019-09-21 15:42:00.417 Error: EventSystem: in script_device_chauffage.lua: [string "local mon_ip = "127.0.0.1:8080"..."]:3: attempt to index global 'devicechanged' (a nil value)Code : Tout sélectionner
local timer_temp_id = {37,28,40,28,74,28,43,28}
for i = 1, #timer_temp_id, 2 do
cmd_timer = "curl " .. '"' .. mon_ip .. "/json.htm?type=command¶m=setsetpoint&idx="..timer_temp_id[i].."&setpoint="..timer_temp_id[i+1] ..'"'
print ("Commande envoyée : " .. cmd_timer)
ret = os.execute (cmd_timer)
endCode : Tout sélectionner
local mon_ip = "127.0.0.1:8080"
commandArray = {}
if (devicechanged['Mode chauffage'] == 'Auto') then
local timer_id = {"11","16","17","10","12","13","14","15","8","9"}
for i,v in ipairs (timer_id) do
cmd_timer = "curl " .. '"' .. mon_ip .. "/json.htm?type=command¶m=enabletimer&idx=" .. v ..'"'
print ("Commande envoyée : " .. cmd_timer)
ret = os.execute (cmd_timer)
end
local timer_temp_id = {37,19,40,18,74,25,43,19}
for i = 1, #timer_temp_id, 2 do
cmd_timer = "curl " .. '"' .. mon_ip .. "/json.htm?type=command¶m=setsetpoint&idx="..timer_temp_id[i].."&setpoint="..timer_temp_id[i+1] ..'"'
print ("Commande envoyée : " .. cmd_timer)
ret = os.execute (cmd_timer)
end
elseif (devicechanged['Mode chauffage'] == 'Confort') then
local timer_id = {"11","16","17","10","12","13","14","15","8","9"}
for i,v in ipairs (timer_id) do
cmd_timer = "curl " .. '"' .. mon_ip .. "/json.htm?type=command¶m=disabletimer&idx=" .. v ..'"'
print ("Commande envoyée : " .. cmd_timer)
ret = os.execute (cmd_timer)
end
local timer_temp_id = {37,21,40,21,74,25,43,19}
for i = 1, #timer_temp_id, 2 do
cmd_timer = "curl " .. '"' .. mon_ip .. "/json.htm?type=command¶m=setsetpoint&idx="..timer_temp_id[i].."&setpoint="..timer_temp_id[i+1] ..'"'
print ("Commande envoyée : " .. cmd_timer)
ret = os.execute (cmd_timer)
end
elseif (devicechanged['Mode chauffage'] == 'Eco') then
local timer_id = {"11","16","17","10","12","13","14","15","8","9"}
for i,v in ipairs (timer_id) do
cmd_timer = "curl " .. '"' .. mon_ip .. "/json.htm?type=command¶m=disabletimer&idx=" .. v ..'"'
print ("Commande envoyée : " .. cmd_timer)
ret = os.execute (cmd_timer)
end
local timer_temp_id = {37,14,40,14,74,14,43,14}
for i = 1, #timer_temp_id, 2 do
cmd_timer = "curl " .. '"' .. mon_ip .. "/json.htm?type=command¶m=setsetpoint&idx="..timer_temp_id[i].."&setpoint="..timer_temp_id[i+1] ..'"'
print ("Commande envoyée : " .. cmd_timer)
ret = os.execute (cmd_timer)
end
elseif (devicechanged['Mode chauffage'] == 'Absent') then
local timer_id = {"11","16","17","10","12","13","14","15","8","9"}
for i,v in ipairs (timer_id) do
cmd_timer = "curl " .. '"' .. mon_ip .. "/json.htm?type=command¶m=disabletimer&idx=" .. v ..'"'
print ("Commande envoyée : " .. cmd_timer)
ret = os.execute (cmd_timer)
end
local timer_temp_id = {37,10,40,10,74,10,43,10}
for i = 1, #timer_temp_id, 2 do
cmd_timer = "curl " .. '"' .. mon_ip .. "/json.htm?type=command¶m=setsetpoint&idx="..timer_temp_id[i].."&setpoint="..timer_temp_id[i+1] ..'"'
print ("Commande envoyée : " .. cmd_timer)
ret = os.execute (cmd_timer)
end
elseif (devicechanged['Mode chauffage'] == 'Ete') then
local timer_id = {"11","16","17","10","12","13","14","15","8","9"}
for i,v in ipairs (timer_id) do
cmd_timer = "curl " .. '"' .. mon_ip .. "/json.htm?type=command¶m=disabletimer&idx=" .. v ..'"'
print ("Commande envoyée : " .. cmd_timer)
ret = os.execute (cmd_timer)
end
local timer_temp_id = {37,28,40,28,74,28,43,28}
for i = 1, #timer_temp_id, 2 do
cmd_timer = "curl " .. '"' .. mon_ip .. "/json.htm?type=command¶m=setsetpoint&idx="..timer_temp_id[i].."&setpoint="..timer_temp_id[i+1] ..'"'
print ("Commande envoyée : " .. cmd_timer)
ret = os.execute (cmd_timer)
end
end
return commandArrayCode : Tout sélectionner
2019-09-21 18:11:00.696 Error: EventSystem: in script_device_chauffage.lua: [string "local mon_ip = "127.0.0.1:8080"..."]:3: attempt to index global 'devicechanged' (a nil value)Code : Tout sélectionner
elseif (devicechanged['Mode chauffage'] == 'Absent' or devicechanged['Mode chauffage'] == 'Ete') then
…Code : Tout sélectionner
-- mode = enable , disable
function settimer (mode, value)
cmd_timer = "curl " .. '"' .. mon_ip .. "/json.htm?type=command¶m=" .. mode .. "timer&idx=" .. value ..'"'
return cmd_timer
endCode : Tout sélectionner
commandArray {}
...
local timer_id = {"11","16","17","10","12","13","14","15","8","9"}
for i = 1, #timer_id do
cmd_timer = settimer ("enable", timer_id[i]) -- ou
-- cmd_timer = settimer ("disable", timer_id[i])
print ("Commande envoyée : " .. cmd_timer)
end
...
return commandArrayCode : Tout sélectionner
http://<IP_DZ:port>/json.htm?type=schedules&filter=device