Ensuite, j'ai testé en créant la commande adéquate comme fonction dans le fichier lua que j'avais récupéré ici viewtopic.php?t=2575
Ne va pas plus vite
Code dans l'interface
Code : Tout sélectionner
dofile('/home/pi/domoticz/scripts/lua/modules.lua')
commandArray = {}
if devicechanged['TestSwitch2'] then
local RandomLine=math.random(1,43)
local filename = 'hex.txt'
local RetrievedValue = ddd
local AppliedValue = aaa
local n=0
for RetrievedValue in io.lines(filename) do
n=n+1
if n==RandomLine then
print("random is "..RandomLine.." and value is "..RetrievedValue)
AppliedValue=RetrievedValue
break
end
end
-- commandArray['OpenURL']='127.0.0.1:7373/json.htm?type=command¶m=setcolbrightnessvalue&idx=7&hex='..AppliedValue..'&brightness=40&iswhite=false'
ApplyIt('ML - Couch',AppliedValue)
end
return commandArrayCode : Tout sélectionner
-- switch on a ML with color
function ApplyIt(device,HexValue)
os.execute(curl..'-u '..domoticzUSER..':'..domoticzPSWD..' "'..domoticzURL..'/json.htm?type=command¶m=setcolbrightnessvalue&idx='..otherdevices_idx[device]..'&hex='..HexValue..'&brightness=40&iswhite=false&passcode='..domoticzPASSCODE..'" &')
end2017-11-19 14:55:07.757 User: Admin initiated a switch command (37/TestSwitch2/Off)
2017-11-19 14:55:07.761 (GenericDummyHardware) Light/Switch (TestSwitch2)
2017-11-19 14:55:07.883 LUA: random is 34 and value is 000080
2017-11-19 14:55:08.521 (MiLight Gateway) Lighting Limitless/Applamp (ML - Couch)
2017-11-19 14:55:09.026 (MiLight Gateway) Lighting Limitless/Applamp (ML - Couch)
2017-11-19 14:55:10.228 User: Admin initiated a switch command (37/TestSwitch2/On)
2017-11-19 14:55:10.232 (GenericDummyHardware) Light/Switch (TestSwitch2)
2017-11-19 14:55:10.355 LUA: random is 7 and value is 00ffff
2017-11-19 14:55:10.824 (MiLight Gateway) Lighting Limitless/Applamp (ML - Couch)
2017-11-19 14:55:11.329 (MiLight Gateway) Lighting Limitless/Applamp (ML - Couch)
2017-11-19 14:55:13.075 User: Admin initiated a switch command (37/TestSwitch2/Off)
2017-11-19 14:55:13.079 (GenericDummyHardware) Light/Switch (TestSwitch2)
2017-11-19 14:55:13.190 LUA: random is 11 and value is 006400
2017-11-19 14:55:13.626 (MiLight Gateway) Lighting Limitless/Applamp (ML - Couch)
2017-11-19 14:55:14.131 (MiLight Gateway) Lighting Limitless/Applamp (ML - Couch)
2017-11-19 14:55:14.314 User: Admin initiated a switch command (37/TestSwitch2/On)
2017-11-19 14:55:14.318 (GenericDummyHardware) Light/Switch (TestSwitch2)
2017-11-19 14:55:14.440 LUA: random is 35 and value is 808000
2017-11-19 14:55:14.905 (MiLight Gateway) Lighting Limitless/Applamp (ML - Couch)
2017-11-19 14:55:15.410 (MiLight Gateway) Lighting Limitless/Applamp (ML - Couch)