Author Topic: Working PlotWatt integration script  (Read 12113 times)

Offline flaquito

  • Jr. Member
  • **
  • Posts: 60
  • Karma: +3/-0
Working PlotWatt integration script
« on: July 03, 2014, 09:50:18 pm »
Since I built my own IR-based pulse meter to monitor my whole-house power usage, I started looking around for a cloud-based solution for storing and analyzing the data. I specifically wanted something with disaggregation, so that it can identify my appliances and devices. A friend of mine uses Bidgely, but that looked like it was going to be difficult to integrate with Vera. Then I stumbled across PlotWatt. It's free for residential users, is based around their disaggregation algorithms, and offers a straightforward API.

So, here's the script that I'm using to upload to PlotWatt. I don't know how to write plugins, so it isn't one. Also, a lot of credit goes to guessed for his SEG code, on which this is very heavily based.

I haven't tested this with multiple meters, but it should work.

The Directions
  • Register for an account at PlotWatt
  • After registering, it should ask you to add a meter. Select the "PlotWatt API" option
  • Their next instructions will take you to the PlotWatt API documentation. The documentation will have your new API key listed at the top
  • SSH into your Vera or another Linux box. Run the command from the API for adding meters, but change the number_of_new_meters to 1:
Code: [Select]
curl -X POST -d "number_of_new_meters=1" http://YOUR_API_KEY:@plotwatt.com/api/v2/new_meters
  • Record the generated Meter ID
  • Download the attached PlotWatt.lua
  • Edit the file, entering your PlotWatt API key, Meter ID, and the Vera Device ID for your whole-house meter device
  • In the Vera UI, go to Apps -> Develop Apps -> Luup Files
  • On the right, click "Choose File". Browse to and select your edited PlotWatt.lua file, and click "Go"
  • On the left, click "Edit Startup Lua"
  • Add the following line:
Code: [Select]
require("PlotWatt.lua")
  • Click "Go"
  • Click "Save"
  • Enjoy your data flowing to PlotWatt

The Details

PlotWatt can handle data resolution of up to one read per second. They can accept data in batches, and don't want data to be uploaded any more frequently than once per minute. This script keeps track of each value from the Vera meter device every time it changes, and only uploads all of the values and times to PlotWatt if it's been more than 60 seconds since the last upload.
« Last Edit: July 03, 2014, 11:44:13 pm by flaquito »

Offline korttoma

  • Hero Member
  • *****
  • Posts: 666
  • Karma: +22/-5
  • Keep it simple, stupid
Re: Working PlotWatt integration script
« Reply #1 on: July 04, 2014, 12:22:47 am »
Very interesting, nice work!! Please give a review about the analysis from PlotWatt when you have some thing ;)
- Tomas

Offline flaquito

  • Jr. Member
  • **
  • Posts: 60
  • Karma: +3/-0
Re: Working PlotWatt integration script
« Reply #2 on: July 04, 2014, 10:47:26 am »
Very interesting, nice work!! Please give a review about the analysis from PlotWatt when you have some thing ;)

Thanks! I'll definitely do that.

I also decided that sleep wasn't all that important last night, and tackled the Bidgely API. I have functional -- but nasty -- code. I need to rework and clean it up before I post it, but I'm now sending my data to both services, and will be able to compare the two.

Offline fullmoonguru

  • Full Member
  • ***
  • Posts: 164
  • Karma: +0/-1
Re: Working PlotWatt integration script
« Reply #3 on: July 05, 2014, 03:34:53 pm »
I've just tried this and I'm not getting any numbers over at PlotWatt.  I'm wondering if it's a problem with the device ID.  I have the Aeon Labs HEM.  I used the device ID for the main unit (8), but not clamps 1 & 2, which are what is actually recording the watts.

OK, actually I just tried substituting 8 with e1 (device ID for clamp one) & that didn't change anything.

When I ran the first code in the terminal it returned this:

Code: [Select]
[934315]root@MiOS_35017007:~#
I assumed the first number to be the generated meter ID.


Offline fullmoonguru

  • Full Member
  • ***
  • Posts: 164
  • Karma: +0/-1
Re: Working PlotWatt integration script
« Reply #4 on: July 05, 2014, 03:59:21 pm »
I barely know what's going on with code but I did notice that the device id does not have the single quotation marks around it like the other parameters do.

Offline fullmoonguru

  • Full Member
  • ***
  • Posts: 164
  • Karma: +0/-1
Re: Working PlotWatt integration script
« Reply #5 on: July 05, 2014, 04:20:10 pm »
Sorry, my bad.  I had renamed the lua file so of course it wasn't started.  I'm getting real-time readings right now on PlotWatt. I assume the other info. will start filling in later.

Offline flaquito

  • Jr. Member
  • **
  • Posts: 60
  • Karma: +3/-0
Re: Working PlotWatt integration script
« Reply #6 on: July 05, 2014, 10:57:08 pm »
Great! Glad it's working for you.

Yeah, not sure how long it's supposed to take before it starts providing more data, but I think it can take a couple weeks.

Offline fullmoonguru

  • Full Member
  • ***
  • Posts: 164
  • Karma: +0/-1
Re: Working PlotWatt integration script
« Reply #7 on: July 07, 2014, 02:45:31 pm »
Not very impressed with the UI so far.  I thought the simplified Ergy reporting from within Vera was better.  Of course I say "was" because it's not working at all right now - "failed to authenticate with ergy".

Here is what I'm seeing from Plotwatt for anyone who is interested:


Offline patersom82

  • Sr. Newbie
  • *
  • Posts: 42
  • Karma: +1/-1
Re: Working PlotWatt integration script
« Reply #8 on: July 15, 2014, 04:00:17 pm »
Quote from: flaquito
Code: [Select]
curl -X POST -d "number_of_new_meters=1" http://YOUR_API_KEY:@plotwatt.com/api/v2/new_meters

Hi flaquito.  I've had a quick look at PlotWatt, and I'm really looking forward to trying it out with my VERA energy meter.

Sorry to be a complete newbie, but can you explain what you mean about changing the number_of_new_meters text in the instructions?

Thank you!


Offline flaquito

  • Jr. Member
  • **
  • Posts: 60
  • Karma: +3/-0
Re: Working PlotWatt integration script
« Reply #9 on: July 15, 2014, 08:03:50 pm »
Quote from: flaquito
Code: [Select]
curl -X POST -d "number_of_new_meters=1" http://YOUR_API_KEY:@plotwatt.com/api/v2/new_meters

Hi flaquito.  I've had a quick look at PlotWatt, and I'm really looking forward to trying it out with my VERA energy meter.

Sorry to be a complete newbie, but can you explain what you mean about changing the number_of_new_meters text in the instructions?

Thank you!

The PlotWatt API documentation gives you the proper curl command to create new meters, with your API key already in the URL. However, their example creates 2 new meter objects. Most likely you only need one. So, in the documentation, where it says

Code: [Select]
"number_of_new_meters=2"
change that to

Code: [Select]
"number_of_new_meters=1"

Offline patersom82

  • Sr. Newbie
  • *
  • Posts: 42
  • Karma: +1/-1
Re: Working PlotWatt integration script
« Reply #10 on: July 16, 2014, 06:42:58 am »
Thanks flaquito... got that working nicely now.  I just need to get my Home Energy Meter reporting properly now, but that's a whole other thread!

Offline fullmoonguru

  • Full Member
  • ***
  • Posts: 164
  • Karma: +0/-1
Re: Working PlotWatt integration script
« Reply #11 on: July 16, 2014, 10:41:16 am »
Patersom, which meter do you have.  I just set up one of the Aeon Labs HEM's.  I might be able to save you some frustration.

Offline patersom82

  • Sr. Newbie
  • *
  • Posts: 42
  • Karma: +1/-1
Re: Working PlotWatt integration script
« Reply #12 on: July 17, 2014, 02:39:32 pm »
Patersom, which meter do you have.  I just set up one of the Aeon Labs HEM's.  I might be able to save you some frustration.

Thanks fullmoonguru!  Very kind.  At the moment, it doesn't look too bad.  Yup, I got the Aeon Labs HEM G2 (single clamp EU model).  But then I thought it would be a good idea to install dataMine (so I could check on it properly), which then lead to good idea of sharing some NAS disk space back to Vera (because I couldn't get my USB to mount directly).  None of which is quite working properly! So I've posted about all of this in different threads.  So, long way round, as is often the case with VERA.  But hopefully in a few days I'll be ready to test my Aeon Labs HEM G2 and PlotWatt.

Offline patersom82

  • Sr. Newbie
  • *
  • Posts: 42
  • Karma: +1/-1
Re: Working PlotWatt integration script
« Reply #13 on: August 11, 2014, 12:40:05 pm »
Not very impressed with the UI so far.  I thought the simplified Ergy reporting from within Vera was better.  Of course I say "was" because it's not working at all right now - "failed to authenticate with ergy".

Here is what I'm seeing from Plotwatt for anyone who is interested:

My dashboard looks pretty similar... I've been feeding data to PlotWatt for 3 weeks now, and can't really see anything special or like the analytics in the demo video.  It is telling me how much electricity I am currently using (which I already know) and how electricity much I have been using per week or per month (which I also already know).

Has anyone had better experiences?  Does it get more insightful if it has 1, 2, 3, 6 months of data?

Offline fullmoonguru

  • Full Member
  • ***
  • Posts: 164
  • Karma: +0/-1
Re: Working PlotWatt integration script
« Reply #14 on: August 11, 2014, 02:21:22 pm »
I did contact them & they said it took a few weeks to show up.  I'm at about 5 weeks now though & it's still the same.  I'll hit them again & see what they say.