LinuxMCE Forums

General => Developers => Topic started by: los93sol on May 24, 2010, 03:40:33 pm

Title: DataLogger Plugin - Energy Monitoring
Post by: los93sol on May 24, 2010, 03:40:33 pm
I'm working on a new device that logs power usage, and will be making use of/enhancing the DataLogger Plugin to get the data to the user in a meaningful way.  Currently, I can already harvest all the data off the device and have it stored in a few hashes ready to be pumped out as events to the DataLogger Plugin.  I looked at the C++ code for the plugin and see a function ProcessEvent, as I understood it, that should be a command that the device accepts, but checking out the template in the web admin, I do not see any events or commands in the template.  I also searched through Advanced>DCE>Commands and through Events and did not find Process Event anywhere?  Is Process Event generic in the sense that I literally just create a new event and send it to the DataLogger from my device and it falls into the ProcessEvent function by default?
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: sambuca on May 24, 2010, 08:50:56 pm
The events and commands defined in the device template is the events the device emits and the commands it accepts. In the case of the datalogger plugin, I believe it registers itself to receive all events within lmce, check out the ::Register method.

So it will receive any events, also new ones that you may need to create.

best regards,
sambuca
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: hari on May 25, 2010, 12:31:22 am
correct, it registers to all events. Btw, it only logs temp/hum/brightness/co2 level changed events for now.

br Hari
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: los93sol on May 25, 2010, 07:27:09 am
Aha!  That's exactly what I was after guys, thanks for the clarification...been a few months since I was into the C++ devices...I need to brush up on things again.  :)  In that case, my job from here should be relatively straightforward to get the data to the logger, just need to decide what data to send in the event and create the events/send the data on over.

A side note:  Apagg, I saw your note in the dev channel, dropped you a pm there as well, feel free to post back here, what information does your graphing require to be generated and is it currently tied to the datalogger plugin?  Since I'm already gathering all the data from the device I'm using and you're graphing already works, I'd like to meet somewhere in the middle to adapt what I have to work with what you have and possibly extend your work to provide more infromation based on what I can provide.  Please let me know, I've got the data already, just need to pass it in the form of an event appropriately.
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: apagg on May 25, 2010, 09:25:07 pm
my code for the energyMonitor can be fond here http://code.google.com/p/apagg-lmce/source/browse/#svn/trunk

I have added logging of "state changed" to DataLogger_Plugin.cpp and used unit=5 for the database

The energyGraph that I am working on uses the "state" from the datalogger and the "energy consumption" parameter I have added to template 37, 38 and 1897. I am still struggling to plot the correct data in the graph, but I think that energyMonitor.php should display the correct data.

all my devices that report state are z-wave I dont know how things like X-10 or KNX will work.
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: hari on May 25, 2010, 10:53:52 pm
why don't you use our own svn?

br Hari
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: apagg on May 25, 2010, 11:13:18 pm
Quote
why don't you use our own svn?

1. This is the first time I have coded anything and I dont want to brake anything :)

2. I dont have access to the svn

regards
apagg
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: hari on May 25, 2010, 11:18:26 pm
2.) is easy to fix :-)
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: coley on May 27, 2010, 12:35:14 pm
Guys,
What kind of energy monitors are you using to gather the data?
I've a CurrentCost monitor and would be willing to try and help and add support for this into your work.
It outputs an xml string of its state every five seconds.

-Coley.
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: los93sol on May 29, 2010, 06:25:51 pm
Coley:  I'm working with the TED5000 currently, please drop by the dev channel to discuss your device.
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: los93sol on May 30, 2010, 03:33:13 am
For those interested in this, I have a little screenshot action for you.  This is my current progress.  Feedback is welcome!

(http://img63.imageshack.us/img63/2338/screenshotoc.png)
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: apagg on May 30, 2010, 09:56:38 am
Looks nice   :)

Did you have to make any changes to dataLogger.php or graph.php?
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: los93sol on May 30, 2010, 05:49:22 pm
No changes in viewDatalog.php or graph.php yet, I want to see what else I can do in there to enhance the graphing a bit so that may change, for example, I'd like to be able to provide some additional information to the graph, like month to date figures, etc.  Below is the running list of changes so far for this...

-Found a dependency problem with graph.php, it requires php-image-graph package
-Added new event category, Energy Monitoring
-Added new events, Voltage Changed, Energy Cost Changed, and Power Usage Changed
-New manufacturer, TheEnergyDetective
-New device template, TED5000
-Enhanced DataLogger_Plugin to log Voltage, Energy Cost, and Power usage
-Applied enhancement from Apagg for DataLogger_Plugin to log State Changed events

I think that's everything, there might be more...
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: l3mce on May 30, 2010, 06:42:20 pm
Nice work!!
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: apagg on May 30, 2010, 10:54:01 pm
I now have a working energyGraph.php that uses the State Changed event and I did some changes to graph.php to plot state better.

Quote
-Found a dependency problem with graph.php, it requires php-image-graph package
I thought sambuca had taken care of this http://svn.linuxmce.org/trac.cgi/ticket/630

Latest files can be found here http://code.google.com/p/apagg-lmce/source/browse/#svn/trunk/www/lmce-admin/operations/datalog

apagg
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: los93sol on May 30, 2010, 11:53:03 pm
Apagg:  Looks like we'll have to do some further testing of the php-image-graph package, I see the sqlCVS changes were actually put in place, but I did do a sqlCVS update prior to starting on this last week and it did not work for me, I had to run pear install image_graph-0.7.1 to get the package before it would graph properly because the include was not there from the package.

Why did you decide to use the state changed event and a separate energy graph outside the generic graphing?  I have not tested your source at all, but with the way the datalogger works for graphing generically with labels for the x and y axis from the unit table of the database, I'd think that wouldn't really work out so well for this type of device since the state changed event is really targetted for generic data.  Can you post a screenshot of your work here?
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: apagg on May 31, 2010, 12:32:35 am
here is a screenshot of the energyGraph.

Quote
Why did you decide to use the state changed event and a separate energy graph outside the generic graphing?
The reason I use the state change event is that its the only data that was available to me for monitoring the energy consumption. I also like the fact that I can plot energy consumption per device.  The reason for making a separate energy graph was that I wanted a different look and the processing of the state data is different from sensor-data. When processing the state data you need to assume the state stays the same until the next state change.
I hope this was understandable English is not my strong point :) 

(http://img94.imageshack.us/img94/1801/energygraph.png)

apagg
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: sambuca on May 31, 2010, 10:11:16 am
Just to clarify on the image-graph dependency. It is the datalogger plugin that depend on this package.

btw. nice work  :)
I really like the stacked bar you made, apagg. This way one can see which device uses the most power.

best regards,
sambuca
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: rages on May 31, 2010, 10:49:23 pm
Very great job,
you could extend this function to the EIB bus?
The  new generation of actuators have on board a current detector on each output.

Emanuele
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: los93sol on June 02, 2010, 02:24:44 pm
rages:  once the code for this device is in, you can extend it to the EIB devices.  That would actually be a very good 'get-your-feet-wet' kind of project.  You think you can take it on?
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: rages on June 02, 2010, 09:16:07 pm
I'm not a coder ... unfortunately ... I know well EIB / KNX but I find it difficult to write code, I tried to take parts of LMCE and try to understand what they do, but with poor results.
I just wanted to suggest a further development, I'm not here to ask someone to do this for me, I think that sometimes there is also need ideas, the creator of this project might not know the KNX actuators.

Emanuele
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: Marie.O on June 02, 2010, 10:38:14 pm
Do you have a list of actuators supporting these current detections? And if they provide any kind of energy usage as well in READ telegrams?
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: rages on June 02, 2010, 10:49:50 pm
I have such an actuator Merten in my house with 12 outlets, each of which has at its disposal a group address that returns a float value of the peak current used.

The Merten is not the only company that produces this type, however once implemented reading from a device KNX open several possibilities for implementation (analog inputs, energy reading tools, etc. ..).

Emanuele
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: Marie.O on June 02, 2010, 11:00:56 pm
Do you have the SKU of the Merten, so I can have a look at the details? I am not doing anything with the eib stuff atm, but am thinking of fitting my house with it.
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: rages on June 02, 2010, 11:49:53 pm
This is my ACTUATORS

http://www.merten.de/download/DL_doku/P6475_584_1_1_EN_Web.pdf

Emanuele
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: valent on June 05, 2010, 10:51:18 am
@apagg What devices you used to gather power usage data?
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: apagg on June 05, 2010, 04:45:14 pm
Quote
@apagg What devices you used to gather power usage data?

z-wave but I think all devices that report state should work
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: valent on June 05, 2010, 10:24:36 pm
Quote
@apagg What devices you used to gather power usage data?

z-wave but I think all devices that report state should work

Could you please give me the link of the exact one you used, because I know that not all zwave devices are the same and not compatible, so I wouldn't like to blow money on wrong one :(

Thanks!
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: apagg on June 05, 2010, 10:50:34 pm
http://wiki.linuxmce.org/index.php/User:Apagg#Home_Automation this is what I use at the moment
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: valent on June 06, 2010, 08:44:20 pm
http://wiki.linuxmce.org/index.php/User:Apagg#Home_Automation this is what I use at the moment

I updated you user page with climate and zwave categories, hope you don't mind.
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: apagg on June 06, 2010, 11:02:21 pm
that's nice :)

I updated the page whit one more working module the Düwi 05433
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: valent on July 23, 2010, 10:39:18 am
Is Energy Monitor code working in latest LinuxMCE snapshots? I'm looking to buy some ZWave devices that do power monitoring and would love to have power monitoring for my flat!
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: sambuca on July 23, 2010, 10:53:37 am
There are some energy monitoring code, mostly the framework for registering and displaying data, iirc, and support for some devices.

I don't think zwave energy meters are fully supported atm. The ZWave driver supports reading the meter of devices that has that function, but it does not pass the data on to the energy monitoring part of LMCE. It wont be that hard to add it though.

best regards,
sambuca
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: valent on July 25, 2010, 01:08:47 pm
That sounds great! I'll be getting some ZWave energy monitoring gear so if you need somebody to testi it out I can help when I get my new ZWave parts.

Cheers,
Valent.
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: slampt on January 21, 2011, 10:51:28 am
I know this is an old thread, but I just started playing with DataLogger and the graphs were not working so I had to do the following;

sudo pear install Image_Color

Just my 2c :P

Cheers
Slampt
Title: Re: DataLogger Plugin - Energy Monitoring
Post by: lblabr on March 04, 2011, 06:47:33 am
hi i´m really new to linuxmce in my energy meter section an error is display ERROR: could not connect to database. where is a good starting point to energy metering or graphing something temperatur etc...

thanks in advance