Working PlotWatt integration script

Is it possible to send individual lighting loads to plotwatt? I didn’t see a way on their site.

The idea is that we could look back and say: well the outside lighting is costing this much, and the bar lights cost this much, etc.

[quote=“victorb17, post:21, topic:181840”]Is it possible to send individual lighting loads to plotwatt? I didn’t see a way on their site.

The idea is that we could look back and say: well the outside lighting is costing this much, and the bar lights cost this much, etc.[/quote]

Yes.
You have to add a new meter
https://plotwatt.com/docs/api

So you can use 2,3,4 … meters and send the watt info using the needed meter id.
The only problem is that I do not know how get separated money info for each meter.

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.[/quote]

How did it go with your code? Did it work and how was the difference between bidgely and plotwatt? Is it possible to get your script?
Thanks!

Anyone know if this works with UI7? I’ve followed the steps to a T, but PlotWatt isn’t showing “no_connection” under “Current Status”. When I go to “View” the luup file in Vera, I get the error “error on line 1 at column 1: Document is empty”

Can you confirm that the device ID does not need the ’ ’ around it? Also, does the API code need the quotes?

Thank you!

Peter

Hey all, sorry I’ve completely disappeared – my energy meter stopped reading properly, and I haven’t had time to work on that. At any rate, several of you have asked about the Bidgely script I put together. Since it’s been several months, I don’t really remember exactly what state it was in, but I’m pretty sure this version of the script was working. Here it is, presented as-is, with no guarantee of functionality. Have fun!

flaquito,

Thank you for posting your Bidgely API code, it’s working great for me. I did have to make a few minor changes, shown below.

Your code: local B_URL = “http://api.bidgely.com/v1/users/” … B_KEY … “/homes/1/gateways/1/upload”

My change: local B_URL = “http://api.bidgely.com/v1/users/” … B_KEY … “/homes/1/gateways/5/upload”

I also decided to use Watts instead of kWh.

{node=‘vera’, deviceId=105, serviceId=‘urn:micasaverde-com:serviceId:EnergyMetering1’, serviceVar=“Watts”},

]]

[quote=“pdenbigh, post:24, topic:181840”]Anyone know if this works with UI7? I’ve followed the steps to a T, but PlotWatt isn’t showing “no_connection” under “Current Status”. When I go to “View” the luup file in Vera, I get the error “error on line 1 at column 1: Document is empty”

Can you confirm that the device ID does not need the ’ ’ around it? Also, does the API code need the quotes?

Thank you!

Peter[/quote]

+1 on this,

Here is a snippet of the code I’m using and it is uploading to PlotWatt. But I do see a “no connection” on the current status on the Plotwatt webpage.

– For each meter, specify the PlotWatt meter ID and Vera Device ID
PW_DEVICES = {
{node=‘vera’, meterId=‘xxxxxxx’, deviceId=105, serviceId=‘urn:micasaverde-com:serviceId:EnergyMetering1’, serviceVar=“Watts”},
}

I’m not very experienced with this but I do have it working so I’ll tell you what I know.

Danni, I do have this working with UI7, but I actually set it up in UI6 & then upgraded. The device ID does not need ’ ’ around it. The API key does need quotes.

FireBird, your code looks good assuming the x’s you show for your meter ID are actually the numbers of you meter ID?

The thing that comes to my mind is that you might be using the wrong device ID. Seems like there are two ID’s for devices in Vera…

Here’s my lua code exactly how it is except for x’s in place of the numbers I’m using:

[code]-- v1.1
– Script for uploading data to PlotWatt
– Visit PlotWatt.com for more information

– See API documentation at https://plotwatt.com/docs/api
– (Select Low-level details with Curl examples)

– PlotWatt API Key
local PW_KEY = “XXXXXXXXXXXXXXXX”

– For each meter, specify the PlotWatt meter ID and Vera Device ID
PW_DEVICES = {
{node=‘vera’, meterId=‘XXXXXX’, deviceId=XX, serviceId=‘urn:micasaverde-com:serviceId:EnergyMetering1’, serviceVar=“Watts”},
}

– Upload Frequency in seconds
– The PlotWatt API specifies an upload interval of no more frequent than 60 seconds
local uploadFreq = 60

– Extra debug messages
local DEBUG = false

– Shouldn’t need to change anything below this line
local http = require(‘socket.http’)
http.TIMEOUT = 5

local PW_URL = “http://” … PW_KEY … “:@plotwatt.com/api/v2/push_readings”
local pwLog = function (text) luup.log('PlotWatt Logger: ’ … (text or “empty”)) end
local lastUpload = os.time()

local powerArray = {}

local function findMeter(deviceId, serviceId, serviceVar)
for k, v in pairs(PW_DEVICES) do
if (v.deviceId == deviceId and
v.serviceId == serviceId and
v.serviceVar == serviceVar) then
return v.node, v.meterId
end
end

return nil, nil
end

local function initWatch()
for k, v in pairs(PW_DEVICES) do
luup.variable_watch(‘powerWatch’, v.serviceId, v.serviceVar, v.deviceId)
end
end

function powerWatch(deviceId, serviceId, serviceVar, oldValue, newValue)
local nodeName, meterID = findMeter(deviceId, serviceId, serviceVar)

if (nodeName == nil or meterID == nil) then
pwLog(string.format(“Node not found for %s,%s,%s”, deviceId, serviceId, serviceVar))
return
end

timeNow = os.time()

powerArray[#powerArray + 1] = meterID
powerArray[#powerArray + 1] = newValue/1000
powerArray[#powerArray + 1] = timeNow

if (DEBUG) then pwLog("Got update of " … newValue … " at " … timeNow) end

if (timeNow - lastUpload >= uploadFreq) then
if (DEBUG) then pwLog(“Updating with: " … table.concat(powerArray,”,“)) end
http.request(PW_URL,table.concat(powerArray,”,"))
lastUpload = timeNow
powerArray = {}
end
end

initWatch()[/code]

I ran the script from a linux box as shown below and I’m not getting anything. I replaced my API code with the x’s. Did I do something wrong?

curl -X POST -d “number_of_new_meters=1” http://YXXXXXXXX@plotwatt.com.com/api/v2/new_meters

  • Domain Sponsor Redirect

Try checking the Plottwatt api website, you can also Putty into your Vera that’s what I did.

https://plotwatt.com/docs/api

Adding Meters to your House

$ curl -X POST -d “number_of_new_meters=2” http://3b0f9e9a9d98137c:@plotwatt.com/api/v2/new_meters
[123,214]

Only POST request is allowed.

Note that you cannot have more than 50 meters total.

what’s the password for Vera? I tried my default and root but no go

Update: Scratch that, I found the password… let me try this again

I think I’m almost there, got my meter id generated (2 of them) I only add the 1st one to the lua file. went through the rest of the process, plotwatt also shows my 2 meter. I’m not seeing any real time update or any update yet. Does it take while for anything to update?

Also, which of the two meter ID is correct? How do I confirm that vera accept the .lua file I uploaded?

on the website under “connected gateway” I’m getting “no_connection”

"on the website under “connected gateway” I’m getting “no_connection” " Mine shows this too, but it’s working fine might be a bug on the PlotWatt website.

I’m trying to do a comparison of PlotWatt and Bidgely services. PlotWatt is working just fine for me and I have the Bidgely lua from earlier in this thread. What I’m not sure about is if I need to do another curl and if so, what are the parameters of the curl command.

Thanks

Thank you very much flaquito! The Bidgely integration is working flawlessly! I’m hoping to get some disaggregation a little quicker than with Plotwatt, I’ve been using Plotwatt for a month now and I have yet to get any appliance level information which seems to be a common problem with Plottwatt.

winebob, I had Plotwatt setup first like you and I was able to just plug in the necessary info into the Bidgely lua file, upload it, and run it at startup and it is working great.

nevermind the original question…

For whatever reason, I’m unable to get this to work. Got the Meter ID, API and everything correct

I followed the instructions in the first post and also used that lua file (with adjustment). I read all the other posts and made sure I have things right. I did create two meters and do see those in plotwatt. After a while I got a graph but everything is 0. Going into Settings->Connected Gateway I see Current Status = no_connection. Why is this not working? Note that I am using Aeon Labs DSC06106-ZWUS Energy Switches.

It suddenly occurred to me that maybe the no_connection does not mean anything. Maybe this is meant for when plotwatt is retrieving data but in our case we are pushing data, hence plotwatt does not make any connections. I might be wrong but based on this I started to look into the lua file. I followed the code but could not really see anything wrong. I then turned the debug flag to true but that didn’t produce more data in the log file (not sure where that debug information is going to). I also saw that retrieved wattage is divided by 1000. In my case the wattage is very low (about 30W) so if this is an integer division it will go to 0. Hence I changed the division to 1000.0. At some point plotwatt actually started to show some data. I then did try to figure out what made it show the data but could not reproduce it except for the fact that at one point it did go back to 0 (note that I also unplugged the device a few times for testing) and then showed some values again.

I realized that when looking at the graph I can also download the data points. It turns out that the last data entry was more than 1.5h ago. Maybe plotwatt is running behind or maybe they are blocking me because I pulled up the graph too many times (there is some 60s limit but I am not sure if that also applies to pulling up graphs on their website).

At this point I think I have to let this whole thing rest and check later again. Later on I will check if maybe the change from 1000 to 1000.0 made data appear. Or maybe it’s just vera that is acting up (considering that suddenly several people have the same problem that is a quite possible scenario). Anyways, I am just writing this in case somebody else is looking into this and maybe finds these observations useful.