Vera Data Logging Solution and Tips

Hey everyone, I wanted to share my experience with logging data from my Vera system. For those of you who might be struggling with similar issues, I hope this helps!

I recently purchased a VeraLite (UI5) to manage my heating system and track its activity. While setting up was straightforward, logging the data proved to be a bit of a challenge. My goal was to create a CSV file that would log the status of my boiler, fire alarm, and other devices in real-time. This data would then be combined with logs from my Arduino projects for a comprehensive analysis.

After some research and trial and error, I found that using Vera’s built-in Lua scripting capabilities was the way to go. Here’s what I did:

  1. Script Setup: I created a Lua script that runs at regular intervals (I set it to every 5 minutes). The script queries the relevant devices for their current status and writes the data to a CSV file.
  2. CSV File Management: To keep things organized, I set up the script to create a new CSV file each day. This makes it easier to manage and analyze the data over time.
  3. Integration with External Systems: I also set up a simple PHP script on my private server to pull the data from Vera and combine it with logs from my Arduino sensors. This gives me a unified view of all my home’s systems.

Here’s a snippet of the Lua script I used:

lua
local file = io.open(‘/data/vera_logs/’ … os.date(‘%Y-%m-%d’) … ‘.csv’, ‘a’)
file:write(os.date(‘%Y-%m-%d %H:%M:%S’) … ‘,’)
file:write(getDeviceStatus(‘boiler’) … ‘,’)
file:write(getDeviceStatus(‘fire_alarm’) … ‘\n’)
file:close()

This script appends a new line to the CSV file every 5 minutes with the current timestamp and device statuses. You can modify it to include more devices or different types of data.

One thing I learned is the importance of testing your scripts thoroughly. I initially tried to log too much data too quickly, which caused some instability. By breaking the script into smaller, more manageable parts, I was able to avoid these issues.

Overall, I’m really happy with how this setup turned out. It gives me the detailed data I need to optimize my home’s systems and provides a solid foundation for future projects. If anyone has questions or suggestions, I’d love to hear them!

Happy automating! :rocket: