I am trying to make a variable file with all my device.
In this file, I try to make a function to print all of them... but I'm stuck on this part.
You will find after an excerpt from my file variable.lua :
Code: Select all
-- -----------------------------------------
-- ------- Variables ------------
-- -----------------------------------------
local V={};
-- -----------------------------------------
-- Switch ON/OFF
-- -----------------------------------------
V.prise_Cuisine = ''
V.prise_Chambre = ''
V.prise_Salon = ''
-- -----------------------------------------
-- Les volets
-- -----------------------------------------
V.les_volets = {};
V.les_volets[1] = {volet="Volets Salon", fenetre = "Fenêtre salon", temperature="salon", idx="192"}
-- -----------------------------------------
-- Les chauffages avec fil pilote
-- -----------------------------------------
V.les_chauffages = {};
V.les_chauffages[1] = {chauffage="Chauffage Chambre", piece = "Chambre"}
V.les_chauffages[2] = {chauffage="Chauffage Salon", piece = "Salon"}
V.les_chauffages[3] = {chauffage="Chauffage SDB", piece = "Salle de Bain"}
-- -----------------------------------------
-- Les volets
-- -----------------------------------------
function V.afficher_variables ()
for a,b in pairs(V) do
print ("==> a : '".. a .. "'");
print ("type : "..type(b));
if (type(b) == "table") then
for x,y in pairs(b) do
print ("====> x : '".. x .. "'");
print ("type : "..type(y));
if (type(y) == "table") then
for c,d in pairs(b) do
print ("=======> c : '".. c .. "'");
print ("=======> d : '".. d .. "'");
end
elseif (type(y) == "string") then
print ("====> y : '".. y .. "'");
end
end
elseif (type(b) == "string") then
print ("==> b : '".. b .. "'");
end
end
return true;
end
return V;
Code: Select all
2016-07-12 12:02:06.771 LUA: ==> a : 'thermostat_chambre_amis'
2016-07-12 12:02:06.771 LUA: type : string
2016-07-12 12:02:06.772 LUA: ==> b : 'THCAMIS'
2016-07-12 12:02:06.772 LUA: ==> a : 'les_volets'
2016-07-12 12:02:06.772 LUA: type : table
2016-07-12 12:02:06.772 LUA: ====> x : '1'
2016-07-12 12:02:06.773 LUA: type : table
2016-07-12 12:02:06.773 LUA: =======> c : '1'
2016-07-12 12:02:06.774 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_time_TEST.lua: ./variables.lua:58: attempt to concatenate local 'd' (a table value)