Page 1 of 1

init persistent data with value

Posted: Tuesday 11 March 2025 13:52
by pierrotori
Hi
i have this

Code: Select all

data = { 
	value= { history = true, maxItems = 12}
	}
And to init

Code: Select all

-- init the persistent data  to zero
for i=1,12 do
	dz.data.value.add(0)
end
is it the best solution to init the persistent data ?
Pierrotori

Re: init persistent data with value

Posted: Tuesday 11 March 2025 18:53
by waltervl
Why do you need to initialize the data?
Normally you just let if fill and do the math afterwards. Do you get errors?
You also define a persistent data table named value but you add data to a table named mesure. Could be a typing error due to copy/paste but you better not use it into one script... :)

Re: init persistent data with value

Posted: Wednesday 12 March 2025 8:20
by pierrotori
i initialize the data, because the data will be insert every 5 minutes, it's take 60 minutes to have all the mesure and i have a function that calculate the standard deviation with the all values
i used the parameter size or check if the data is not equal to nil, but in my case it's more easy to add zero when the script start , because the value zero is the value for no consumption water for the last hour

in fact it's a error for the table name, i updated