init persistent data with value

Subforum for general discussions. Do not dump your questions/problems here, but try to find the subforum where it belongs!

Moderators: leecollings, remb0

Post Reply
User avatar
pierrotori
Posts: 118
Joined: Tuesday 15 May 2018 0:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: France
Contact:

init persistent data with value

Post 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
Last edited by pierrotori on Wednesday 12 March 2025 8:20, edited 1 time in total.
rpi : Raspberry Pi 2 Model B Rev 1.1 / Modele : Cortex-A7 armv7l GNU/Linux / Os Name : bullseye
Docker/Domoticz/zwave-ui/homebridge/mosquitto/wireguard
User avatar
waltervl
Posts: 5852
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: init persistent data with value

Post 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... :)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
pierrotori
Posts: 118
Joined: Tuesday 15 May 2018 0:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: France
Contact:

Re: init persistent data with value

Post 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
rpi : Raspberry Pi 2 Model B Rev 1.1 / Modele : Cortex-A7 armv7l GNU/Linux / Os Name : bullseye
Docker/Domoticz/zwave-ui/homebridge/mosquitto/wireguard
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest