Store and send values?

So, I figured out how to send the current light level via email (thanks all!). So, I want to collect data on the light level throughout the day. I don’t want to send an email every 15 minutes. So, how can I read the light sensor alue every 15 minutes, store that in a string(append) or array or ?? and send that via email at dusk? I wasn’t sure of all variables are wiped clean each time a scene’s schedule runs? Any ideas?

This is partly a learnign experiecne and partly trying to decide at what light level I want to turn on the outside lights if it is cloudy an hour before dusk. Currently, I send an email with the light level and the weather plugin’s description of the current weather (cloudy, suny, etc.)

Thanks,

Tony - not a programmer and barely a hack.

local variables are created when Lua code in a scene is executed and then destroyed after it terminates.

Global (not local) variables are retained, however, as long as Vera is not restarted. You could have your scene code append the new data to a global variable. All Lua code in scenes and Startup Lua share the same context so you can access a global variable from any of them. This means that you should take care with the name of the variable if you want to have more than one collecting data.

If you need your accumulator to survive restarts, you could either create a device variable in one of your devices, use the VariableContainer plugin or write it to a text file in Vera’s file system.

If you want more information on these methods, just ask.

Do you know if one method (using state varibles vs. text files) is more resource intensive? That is (generally speaking) would you be more concerned about over-use of state variables, or over use of text-files for storing persistent data? Or…not really concerned about either…

Do you know if one method (using state varibles vs. text files) is more resource intensive? That is (generally speaking) would you be more concerned about over-use of state variables, or over use of text-files for storing persistent data? Or…not really concerned about either…[/quote]

In terms of memory usage, I would expect them to be about the same. I think using a text file would require a little more CPU time but that is not usually an issue on Veras. If the data is updated frequently it would be better to use a state variable to avoid over-stressing the Flash memory. Vera saves the configuration data to Flash every six minutes so that would be my threshold below which I would use a state variable.

I use text files for data that I want to access from outside Vera. I create the files in /www so that they can be accessed by the url http:///.txt from a browser, MSExcel, MSAccess, etc.

Just my two cents on this… I am using the DataMine plug in to just do this (as well as other variables I am interested in). Data is stored and timestamped in the DataMine directory tree on the USB stick, so no impact on the flash and base filesystem and it survives reboots.

Thanks! I think I’ll start slow with a Global variable. I have experimented with the variable plugin and am able to store a couple of values there. This isn’t critical.

Tony