Question cube

Forum dédié à l'intégration de la Gateway ZigBee Xiaomi dans DomoticZ.
Pour les questions concernant les objets ZigBee Xiaomi, merci d'utiliser le forum ZigBee au-dessus.
johnnybravo
Messages : 63
Inscription : 04 mai 2017, 14:15

Re: Question cube

Message par johnnybravo »

J'ai essayé en déplaçant la commande, en la mettant en dehors de la boucle, ça n'a pas amélioré le temps.
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&param=setcolbrightnessvalue&idx=7&hex='..AppliedValue..'&brightness=40&iswhite=false'
ApplyIt('ML - Couch',AppliedValue)
end
return commandArray
code dans le fichier lua

Code : Tout sélectionner

-- switch on a ML with color 
function ApplyIt(device,HexValue)

	os.execute(curl..'-u '..domoticzUSER..':'..domoticzPSWD..' "'..domoticzURL..'/json.htm?type=command&param=setcolbrightnessvalue&idx='..otherdevices_idx[device]..'&hex='..HexValue..'&brightness=40&iswhite=false&passcode='..domoticzPASSCODE..'" &') 

end
et le résultat dans les logs
2017-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)
landaisbenj
Messages : 695
Inscription : 12 mars 2017, 19:24

Re: Question cube

Message par landaisbenj »

En fait switchOn n’accélère pas l’exécution car il est passé en fonction mais parce qu’il passe par une commande HTML json contrairement a commandArray qui lui dois peut etre etre travaillé par l'application (je ne sais pas).

Le problème c'est la boucle a mon avis.

Réduit ton fichier a 5 couleurs max pour voir la différence.
Rpbi3b: Domoticz + Homebridge + Monit + Freebox scripts + Shellinabox; Rpbi2: Jarvis
Domoticz: Derniere stable; RFLINK: Dernière stable; Xiaomi Gateway
Répondre