General > Power Management

Contribution: Monitor and visualize energy usage with emoncms.org in Vera

(1/12) > >>

wezzix:
I found a really nice looking service called emoncms.org to visualise energy consumption measured in Vera. It's free and open source. You can use emoncms.org or setup your own server at home. You can also use it to log arbitrary numerical variables in vera, such as battery level, light, temperature etc. You can create custom dashboards and export to CSV.

Here is how I did it:

Setup Vera (instructions for UI7)

* Register for an account at emoncms.org
* Look up your write API key on your profile page
* Download the attached EnergyMonitor.lua
* Edit the file, enter your emoncms API key and setup your devices in VARIABLES according to the sample code already there
* Please note that the energy can be fetched in two ways. The first way is directly from the Watts variable of your device. The second way is to use a lua function to calculate the energy. The second option is useful if you don't control the device directly from Vera. I use it to measure if my computer is on using a PingSensor, and send the power based on the sensor reading. I also have an 'Other' where I enter the average power of external devices such as Washmachines etc.
* In the Vera UI, go to Apps -> Develop Apps -> Luup Files
* On the right, click "Choose File". Browse to and select your edited EnergyMonitor.lua file, and click "Upload"
* On the left, click "Edit Startup Lua" and add the following line:
--- Code: ---require("EnergyMonitor.lua")
--- End code ---

* Click "Go"
* Enjoy your data flowing to emoncms.org!
Setup emoncms inputs and feeds
You will immediately find your data here: http://emoncms.org/input/view
The inputs are by default not stored. Therefore, you will need to setup what is known as "feeds". Feeds is where the data is stored.

Feeds and inputs are very flexible, and therefore not very intuitive in the beginning. There are some guides at the bottom of this page which explains how to create feeds from your inputs:
http://openenergymonitor.org/emon/guide

In short, what I did was this:

* Go to your inputs at http://emoncms.org/input/view
* Find the input called Total and click the Spanner icon to access its processes.
* You will now create three feeds:
* Enter the following under Add process: Log to feed / CREATE NEW: / Total W / Fixed Interval With Averaging (PHPFIWA) / 10 s. Click Add.
* Enter the following under Add process: Power to kWh / CREATE NEW: / Total kWh / Fixed Interval No Averaging (PHPFINA) / 10 s. Click Add.
* Enter the following under Add process: Power to kWh/d / CREATE NEW: / Total kWhd. Click Add.
* If everything is setup correctly, you will now find your feeds at http://emoncms.org/feed/list
Setup emoncms energy app
Now for the fun part, setting up the dashboard.

* Click Apps > My Electric
* Click the Spanner icon at the top right
* Choose feeds as follows:
* Power feed (Watts): Total W
* Bar graph feed: Total kWh
* Wh or kWh feed?: kWh elapsed
* Set currency and unit cost if you wish.
* Click Save.
* Enjoy your energy dashboard!
The result
Attached is the code and examples of the two dashboards. My Electric displays current and historic energy consumption. I played around with My Solar to visualize how much energy I could save if I would switch to LED instead of halogen lights.
You can also design your own dashboard. I recommend that you watch the YouTube introduction before designing.

This code could be made into a Vera app. If anyone feels like taking the time to make an app, feel free to use my code as a base - just mention my name somewhere :)

FredrikY:
Really realy nice, will give it a try! Good work!

konradwalsh:
thanks for this...

still struggling to get the feeds running..

could do with some more examples..

track on time of a switch for example

wezzix:
I found an error in the code and just uploaded a fixed file (deviceId was missing from VARIABLES).

I also made "Total" exclude any variables but Watts. That means that you can easily do arbitrary logging of switches, light level, battery level etc.
I included an example for a switch also:
Set up the feed as in my first post (first feed), that is, use the "Log to feed" processing. You can simply check on your feed by clicking on the "eye"-icon in the feed list. Attached is a sample of how my switch looks really zoomed in (zoom in by click and select in the graph). Not sure if that fits your needs. You can always export the feed data as CSV.


--- Code: ----- Setup your devices here. You can use a function to calculate the power as illustrated in the sample.
-- For device logging, use: key, deviceId, serviceId, serviceVar
-- For function based logging, use: key, calculate, serviceVar
local VARIABLES = {
{ key="Livingroom", deviceId = 12, serviceId='urn:micasaverde-com:serviceId:EnergyMetering1', serviceVar="Watts" }, -- Send device energy
{ key="Kitchen", deviceId = 13, serviceId='urn:micasaverde-com:serviceId:EnergyMetering1', serviceVar="Watts" },
{ key='KitchenSwitch', deviceId=13, serviceId="urn:upnp-org:serviceId:SwitchPower1", serviceVar="Status"}, -- Send switch status
{ key='Computer', calculate=function() return (IsComputerPingSensorTripped() and 38 or 1) end, serviceVar="Watts" }, -- Send variable value
{ key='Other', calculate=function() return 15 end, serviceVar="Watts" } -- Send a constant value
}
--- End code ---

amg0:
yes it looks quite good.
for your info, I made an native integration for it in ALTUI plugin. http://apps.mios.com/plugin.php?id=8246

Navigation

[0] Message Index

[#] Next page

Go to full version