Visualizing smart home data using Veraplus + Telegraf + InfluxDB + Granafa + Raspberry PI

Visualizing smart home data using Veraplus + Telegraf + InfluxDB + Granafa + Raspberry PI

I am using a Veraplus to control everything in my house through mobile and Alexa. Here are a few examples:

1. Smart devices: https://www.youtube.com/watch?v=y9kkjaEJTfM

2. Siri: https://www.youtube.com/watch?v=MK2I0rjkoN4

3. Android tablet: https://www.youtube.com/watch?v=-SMCvhWNkkI

Although Vera has two plugins (DataMines and Datayours) that could be used to visualize Vera logs, it requires a lot of memory and storage. As a result, I try to find another solution that does not play a heavy burden on my Veraplus which already has a few hundred devices and ten plugins or more. Here is my approach that seems to work well.

Pre-requisites:

1. A Veraplus from Vera Control. You can learn more about Veraplus from their forum: http://forum.micasaverde.com/index.php

2. A Raspberry Pi (https://www.amazon.ca/CanaKit-Raspberry-Starter-Premium-Black/dp/B07BD56DW5/ref=sr_1_4?s=pc&ie=UTF8&qid=1532697299&sr=1-4&keywords=raspberry+pi+3+b%2B)

3. Telegraf

4. InfluxDB

5. Grafana

Step 1: Install Influx DB + Telegraf + Granafa on a Raspberry Pi from this link https://makemypi.wordpress.com/2018/02/19/iot-with-influxdb-telegraph-and-grafana-on-the-raspberry-pi-3/

Step 2: Mount Vera log folder to a shared folder in the Raspberry.

  •  Disable USB logging in Vera
  •  Mount to a shared folder in Raspberry:
    • sudo mkdir /pi
    • mount -t cifs -o user=<username>,pass=<password> //<raspberry pi ip>/<share> /pi
  • Make sure the mount is still valid after a Vera reboot
    • sudo vi /etc/rc.local
    • Add these lines to the top
    • mount -t cifs -o user=<username>,password=<password> //raspberry IP/<share> /pi &ln -s /pi /tmp/log

      ln -s /pi/cmh /tmp/log/cmh

Step 3: after step 2, Vera will write logs to a shared folder in the Raspberry PI. Next, we will use telegraf collect data to influx DB.

  • sudo pico /etc/telegraf/telegraf.conf
  • Make telegraf.conf input and output look like this:
    • [[inputs.logparser]]
      ## files to tail.
      files = [“<raspberrypiIP>/<sharefolder>/cmh/LuaUPnP.log”]
      ## Read file from beginning.
      from_beginning = false
      ## Override the default measurement name, which would be “logparser_grok”name_override = “powerusage”
      ## For parsing logstash-style “grok” patterns:
      [inputs.logparser.grok]
      patterns = [‘(.*) device: 364 (.*)KWH([^R])(.*)was: %{BASE10NUM:previouskwh:float} now: %{BASE10NUM:currentkwh:float}(.*)’]
    • [[outputs.influxdb]]
      ## The full HTTP or UDP endpoint URL for your InfluxDB instance.
      urls = [“http://<raspberrypiIP>:8086”] # required
      ## The target database for metrics (telegraf will create it if not exists).
      database = “powerusage” # required
      ## Write timeout (for the InfluxDB client), formatted as a string.
      timeout = “5s”
  • Telegraf will parse (tail) the log LuaUPnP.log with the regular expression and put the data in InfluxDB (database: powerusage).
  • (.*) device: 364 (.*)KWH([^R])(.*)was: %{BASE10NUM:previouskwh:float} now: %{BASE10NUM:currentkwh:float}(.*)
    • 364 is my home energy monitorying device ID
    • REGEX reads two values: currentkwh and previouskwh

Step 4: after storing all the values from the logs in InfluxDB, we can use Grafana to visualize the value. Here are some examples in my case.

  • Power today:

  • Water usage today

  • House temperature

  • House humidity

  • House motions & doors


anh

Leave a Reply

Your email address will not be published. Required fields are marked *