dzVents design question (multiple readings from an arbitrary number of humidity sensors as persistent data)
Posted: Sunday 19 March 2017 8:27
Hi there!
I'd like to store multiple readings from an arbitrary number of humidity sensors as persistent data. Of course I'd like to use the nifty dzVents built in statistical functions to be able to calculate an average over several readings etc.
My first script version stored data like this (The data is an array ) :
As you see the data stored is an array with values read from all my humidity sensors. (2 pcs). My problem with that solution was that I couldn't figure out how to make this work, because the getValue function can only work for a single value, not an array.
So this morning I started to look at another solution where think that the getValue function won't even be needed.
Now I will be able to use the statistic functions but my problem is that the number of humidity sensors is hard coded. I have ["humidityReadings1"] and ["humidityReadings2"]. If I decide to share my code, someone else maybe only have 1 humidity sensor.
Any ideas about how to do this the best way?
Cheers!
I'd like to store multiple readings from an arbitrary number of humidity sensors as persistent data. Of course I'd like to use the nifty dzVents built in statistical functions to be able to calculate an average over several readings etc.
My first script version stored data like this (The data is an array ) :
Code: Select all
-- Persistent Data
local multiRefObjects = {
} -- multiRefObjects
local obj1 = {
["humidityReadings"] = {
[1] = {
["data"] = {
[1] = 31;
[2] = 24;
};
["time"] = "2017-03-18 10:16:00";
};
[2] = {
["data"] = {
[1] = 31;
[2] = 24;
};
["time"] = "2017-03-18 10:15:00";
};
[3] = {
["data"] = {
[1] = 31;
[2] = 24;
};
["time"] = "2017-03-18 10:14:00";
};
};
}
return obj1
So this morning I started to look at another solution where think that the getValue function won't even be needed.
Code: Select all
local multiRefObjects = {
} -- multiRefObjects
local obj1 = {
["humidityReadings1"] = {
[1] = {
["data"] = 27;
["time"] = "2017-03-19 06:57:00";
};
[2] = {
["data"] = 27;
["time"] = "2017-03-19 06:57:00";
};
[3] = {
["data"] = 27;
["time"] = "2017-03-19 06:57:00";
};
};
["humidityReadings2"] = {
[1] = {
["data"] = 22;
["time"] = "2017-03-19 06:57:00";
};
[2] = {
["data"] = 22;
["time"] = "2017-03-19 06:57:00";
};
[3] = {
["data"] = 22;
["time"] = "2017-03-19 06:57:00";
};
};
}
return obj1Any ideas about how to do this the best way?
Cheers!