Hello,
Merci Vil1driver pour cette bibliotheque LUA tres pratique.
Je suis reparti de celle-ci pour créer une nouvelle fonction pour récuperer les schedules de mes switchs.
Mon objectif est de mettre en place plusieurs schedules sur differents switch et d'activer l'un ou l'autre via a un selector switch.
J'ai pris pour example la fonction jsonInfos
Code : Tout sélectionner
function jsonInfos(device)
local rid = assert(io.popen(curl..'-u '..domoticzUSER..':'..domoticzPSWD..' "'..domoticzURL..'/json.htm?type=devices&rid='..otherdevices_idx[device]..'"'))
local list = rid:read('*all')
rid:close()
return json:decode(list).result[1]
end
et ma fonction est la suivante
Code : Tout sélectionner
local function getDevicesSchedule()
print('top1')
local rid = assert(io.popen(curl..'-u '..domoticzUSER..':'..domoticzPSWD..' "'..domoticzURL..'/json.htm?type=schedules&filter=device"'))
print('top2')
local list = rid:read('*all')
print('top3')
rid:close()
print('top4')
return json:decode(list).result
end
c'est une v1, il me reste encore a filtrer le resultat pour un device donné, mais j'ai déja un gros probleme de performance avec l'operation "rid:read('*all')" qui prend 11 secondes!
2017-12-11 22:46:54.222 dzVents: Planning selector:Planning Eco-Confort
2017-12-11 22:46:54.222 dzVents: top1
2017-12-11 22:46:54.225 dzVents: top2
2017-12-11 22:47:04.206 Error: EventSystem: Warning!, lua script sc_planning has been running for more than 10 seconds
2017-12-11 22:47:04.207 (Chauffage_RDC_Devices) Light/Switch (Planning Eco-Confort)
2017-12-11 22:47:04.226 dzVents: top3
2017-12-11 22:47:04.226 dzVents: top4
2017-12-11 22:47:04.232 dzVents: table = {
[1] = {
["IsThermostat"] = "false";
["TimerID"] = 2;
["TimerTypeStr"] = "On Time";
["DevName"] = "Mode_Chauffage_RDC";
["Days"] = 128;
["TimerCmd"] = 0;
["Occurence"] = 0;
["Month"] = 0;
["Level"] = 30;
["Type"] = "Device";
["ScheduleDate"] = "2017-12-12 07:00:00";
["TimerType"] = 2;
["MDay"] = 0;
["Time"] = "07:00";
["Active"] = "true";
["DeviceRowID"] = 10;
["Hue"] = 0;
["Randomness"] = "false";
["Date"] = "";
};
[2] = {
["IsThermostat"] = "false";
["TimerID"] = 1;
["TimerTypeStr"] = "On Time";
["DevName"] = "Mode_Chauffage_RDC";
["Days"] = 128;
["TimerCmd"] = 0;
["Occurence"] = 0;
["Month"] = 0;
["Level"] = 20;
["Type"] = "Device";
["ScheduleDate"] = "2017-12-11 23:30:00";
["TimerType"] = 2;
["MDay"] = 0;
["Time"] = "23:30";
["Active"] = "true";
["DeviceRowID"] = 10;
["Hue"] = 0;
["Randomness"] = "false";
["Date"] = "";
};
};
pour info la fonction est appelée dans un script device avec cette commande "print(table_show(getDevicesSchedule()))"
J'ai vérifié si j'avais le meme probleme de perf avec la fonction d'origine avec "print(table_show(jsonInfos(device[2])))"
=> meme probleme de perf
2017-12-11 22:59:49.567 User: Admin initiated a switch command (13/Planning Eco-Confort/Set Level)
2017-12-11 22:59:49.721 dzVents: table = {
["Planning Eco-Confort"] = "De Matin";
};
2017-12-11 22:59:49.721 dzVents: Planning selector:Planning Eco-Confort
2017-12-11 22:59:59.704 Error: EventSystem: Warning!, lua script sc_planning has been running for more than 10 seconds
2017-12-11 22:59:59.706 (Chauffage_RDC_Devices) Light/Switch (Planning Eco-Confort)
2017-12-11 22:59:59.728 dzVents: table = {
["Unit"] = 1;
["LevelOffHidden"] = true;
["Data"] = "Set Level: 20 %";
["Image"] = "ComputerPC";
["HardwareName"] = "Chauffage_RDC_Devices";
["Notifications"] = "false";
["LastUpdate"] = "2017-12-11 22:59:49";
["idx"] = "13";
["BatteryLevel"] = 255;
["HaveTimeout"] = false;
["Description"] = "";
["TypeImg"] = "Light";
["Name"] = "Planning Eco-Confort";
["MaxDimLevel"] = 100;
["SelectorStyle"] = 0;
["SignalLevel"] = "-";
["Level"] = 20;
["StrParam2"] = "";
["AddjMulti2"] = 1;
["HardwareTypeVal"] = 15;
["LevelInt"] = 20;
["HaveGroupCmd"] = true;
["AddjMulti"] = 1;
["LevelActions"] = "||||";
["XOffset"] = "0";
["HardwareType"] = "Dummy (Does nothing, use for virtual switches only)";
["SwitchType"] = "Selector";
["YOffset"] = "0";
["HardwareID"] = 5;
["Used"] = 1;
["Type"] = "Light/Switch";
["SubType"] = "Selector Switch";
["PlanID"] = "0";
["Timers"] = "false";
["IsSubDevice"] = false;
["SwitchTypeVal"] = 18;
["CustomImage"] = 17;
["StrParam1"] = "";
["Status"] = "Set Level: 20 %";
["Favorite"] = 1;
["ShowNotifications"] = true;
["Protected"] = false;
["AddjValue2"] = 0;
["ID"] = "0001405D";
["HaveDimmer"] = true;
["AddjValue"] = 0;
["PlanIDs"] = {
[1] = 0;
};
["UsedByCamera"] = false;
["LevelNames"] = "Off|Repos|De Matin|D'Aprem|Horaire Bureau";
};
Avez vous déja eu ce genre de probleme? Savez vous comment le résoudre?
Je bloque la dessus depuis quelques jours, toute piste pour avancer serait grandement appréciée!
Merci,
Arno
ps: désolé pour tous les accents manquants, sur un clavier qwerty, c'est pas facile
