[Solved] Looping through global variable ?
Posted: Sunday 13 June 2021 19:04
Hello,
I'm trying to loop through global variables without knowing if it's even possible. I want to get back the values stored in a global variable by another script to update a custom sensor. I tried that :
Considering ValueX is declared in global_data.lua
Then tried that :
and
but both end with errors.
Do I try to do something possible or not ?
Thx
I'm trying to loop through global variables without knowing if it's even possible. I want to get back the values stored in a global variable by another script to update a custom sensor. I tried that :
Code: Select all
local capteurs = {
{ custom = 'Custom_Test1', GV = 'Value1' },
{ custom = 'Custom_Test2', GV = 'Value2' },
{ custom = 'Custom_Test3', GV = 'Value3' },
}
Then tried that :
Code: Select all
for _,sonde in ipairs(capteurs) do
local X = tostring(sonde.GV)
local temp = dz.globalData.X.getLatest()
dz.devices(sonde.custom).updateCustomSensor(temp)
end
and
Code: Select all
for _,sonde in ipairs(capteurs) do
local temp = dz.globalData.(sonde.GV).getLatest()
dz.devices(sonde.custom).updateCustomSensor(temp)
end
Do I try to do something possible or not ?
Thx