Author Topic: DataLogger Plugin - Energy Monitoring  (Read 8030 times)

los93sol

  • Guru
  • ****
  • Posts: 396
    • View Profile
DataLogger Plugin - Energy Monitoring
« 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?

sambuca

  • Guru
  • ****
  • Posts: 444
    • View Profile
Re: DataLogger Plugin - Energy Monitoring
« Reply #1 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

hari

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 2420
    • View Profile
    • ago control
Re: DataLogger Plugin - Energy Monitoring
« Reply #2 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
rock your home - http://www.agocontrol.com home automation

los93sol

  • Guru
  • ****
  • Posts: 396
    • View Profile
Re: DataLogger Plugin - Energy Monitoring
« Reply #3 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.

apagg

  • Veteran
  • ***
  • Posts: 60
    • View Profile
Re: DataLogger Plugin - Energy Monitoring
« Reply #4 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.

hari

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 2420
    • View Profile
    • ago control
Re: DataLogger Plugin - Energy Monitoring
« Reply #5 on: May 25, 2010, 10:53:52 pm »
why don't you use our own svn?

br Hari
rock your home - http://www.agocontrol.com home automation

apagg

  • Veteran
  • ***
  • Posts: 60
    • View Profile
Re: DataLogger Plugin - Energy Monitoring
« Reply #6 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

hari

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 2420
    • View Profile
    • ago control
Re: DataLogger Plugin - Energy Monitoring
« Reply #7 on: May 25, 2010, 11:18:26 pm »
2.) is easy to fix :-)
rock your home - http://www.agocontrol.com home automation

coley

  • Guru
  • ****
  • Posts: 473
    • View Profile
Re: DataLogger Plugin - Energy Monitoring
« Reply #8 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.

los93sol

  • Guru
  • ****
  • Posts: 396
    • View Profile
Re: DataLogger Plugin - Energy Monitoring
« Reply #9 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.

los93sol

  • Guru
  • ****
  • Posts: 396
    • View Profile
Re: DataLogger Plugin - Energy Monitoring
« Reply #10 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!


apagg

  • Veteran
  • ***
  • Posts: 60
    • View Profile
Re: DataLogger Plugin - Energy Monitoring
« Reply #11 on: May 30, 2010, 09:56:38 am »
Looks nice   :)

Did you have to make any changes to dataLogger.php or graph.php?

los93sol

  • Guru
  • ****
  • Posts: 396
    • View Profile
Re: DataLogger Plugin - Energy Monitoring
« Reply #12 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...

l3mce

  • NEEDS to work for LinuxMCE
  • ***
  • Posts: 1081
    • View Profile
Re: DataLogger Plugin - Energy Monitoring
« Reply #13 on: May 30, 2010, 06:42:20 pm »
Nice work!!
I never quit... I just ping out.

apagg

  • Veteran
  • ***
  • Posts: 60
    • View Profile
Re: DataLogger Plugin - Energy Monitoring
« Reply #14 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