I am struggling for 2 days to activate persistent data.
I run Domoticz on a Raspberry pi, and have 2 zsticks reading house and solar panel consumption. I want to create a composite meter showing how much electricity I use from the utility; the problem is that sometime I create more electricity that I use, but unfortunately my meter is not electromechanical, and so cannot turn backwards anymore so I need to store the amount of electricity I send back to the grid.
I have - more or less - understood lua and dzVents, and everything seems to work except for storing this amount between invocations.
In order to pinpoint the problem, I wrote the following minimal dzVent script:
Code: Select all
return {
active = true,
on = {
['timer'] = {
'every minute'
}
},
data = {
mydata = { initial = 10 },
},
execute = function(domoticz)
print("Old mydata: ")
print(mydata)
mydata = 20
print("New mydata: "..mydata)
end
}
But the variable mydata is always nil, as shown in this logfile: https://pastebin.com/MrTwvvhG
I cleared everything before starting the log.
The first script invocation occurs at line 82
The second invocation occurs at line 159
In both cases, Old mydata is nil
Just in case, the content of domoticzData.lua is available here: https://pastebin.com/iB6qa6vh
What did I do wrong?
Thanks!