I wrote a simple program that has 2 timers and 2 callbacks.
Each timer launches a database query (one to select Temperature and one to select KWH) with a callback
Code: Select all
if (MyMinute == MyMinute2Run ) then --Get Temperature data
--Prepare CMD with SELECT-FROM-WHERE
dz.executeShellCommand( { command = cmd, callback = 'myTMPcallback', })
endI defined those tables as "global" in the "data" section
Code: Select all
data = {global_myKWHTable = { initial={} }, global_myTMPTable = { initial={} },},Code: Select all
execute = function(dz, triggeredItem, triggerInfo)
myKWHTable = dz.data.global_myKWHTable
myTMPTable = dz.data.global_myTMPTableCode: Select all
if (triggeredItem.statusCode == 0) and (triggerInfo.trigger == "myTMPcallback") then
myTMPTable={}
myTMPTable[1]={}
myTMPTable[2]={}
local myPayload = triggeredItem.data
--Format of received data: 4|TempHumBaro|10.80|2026-03-05
--I store the data in myTMPTable table - index [1] holds Temperature and index [2] holds dates
--I can print out the contents of the myTMPTable table
endSince both tables are global I thought I would be able to use its contents everywhere in my program. But that's not the case. Those tables seems to be "local" to each callback.
What I'm doing wrong here?
In advance many thanks for your help
Willy