more G-Labs products

Author Topic: Understandig energy module  (Read 2335 times)

November 26, 2015, 10:37:00 PM
Read 2335 times

codedmind

  • ***
  • Information
  • Full Member
  • Posts: 92
Hy there,

I have a shell script that will get the following information

Quote
Energy:25860668 Wh
Power:510 W
Current: 2215 mA
Voltage:230 V   

How can i put this information in the energy widget, what is the difference off load and and counter
What is what?

November 27, 2015, 05:00:18 PM
Reply #1

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Hi codemind,

to push metering data in the system you have to call the following instruction

Pseudo code:
Code: [Select]
var instantWattReading = [the field that holds the value Power:510 W]; // a string representing a decimal number eg. 510.40
Program.RaiseEvent("Meter.Watts", instantWattReading, "My Meter");

this should be called every minute or 30 seconds to have accurate results in the energy monitor widget.
The energy monitor widget indicates with Load the sum of instant watt reading for all active devices, with Counter the kW/h energy consumption counter (the one you see in the bills).

g.
« Last Edit: November 27, 2015, 05:01:51 PM by Gene »

November 27, 2015, 05:16:20 PM
Reply #2

codedmind

  • ***
  • Information
  • Full Member
  • Posts: 92
Great.

Thanks gene

November 27, 2015, 10:18:12 PM
Reply #3

codedmind

  • ***
  • Information
  • Full Member
  • Posts: 92
I have made the changes, but won't work 100% my font information is only updated from 5 to 5 minutes

Even if i code hg to read the script from 30 to 30 seconds the value always be the same... do you think that is better ?

In this moment the energy widget only show the load

November 28, 2015, 04:16:25 PM
Reply #4

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Hi codemind,

this is correct that is resampled every 5 minutes. You should se the counter increasing after some time. For example if you keep a light consuming 45W switched on for one hour, then the counter should increase by 0.045 (because it is expressed in kW/hour).

g.

November 28, 2015, 09:39:55 PM
Reply #5

codedmind

  • ***
  • Information
  • Full Member
  • Posts: 92
Gene i have done that, the only difference is the time of the read, 5 to 5 minutes,  but the widget never update the counter (i'm guessing the counter is the center value that like you said is in kw), only the load (upper left corner of the widget)

November 28, 2015, 10:09:59 PM
Reply #6

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
As said in my previous message reading must be every 30 seconds or every minute in order to be accurate. In a real situation this is supposed to be a continuos read value, but in this case we can take some Watt sample periodically (that's why is called WattS), then all collected samples will be averaged every 5 minutes and stored in the DB. Having only one sample every 5 minutes won't work.

g.

November 28, 2015, 10:16:50 PM
Reply #7

codedmind

  • ***
  • Information
  • Full Member
  • Posts: 92
I have the script in hg reading in every 1 minute, however the value only change after 5 minutes... because the source... But in the widget that should be the trick to increment the counters.... or not?

November 28, 2015, 10:23:57 PM
Reply #8

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Can you please me show the code where you read the value and put it into "Meter.Watts" parameter?

g.

November 28, 2015, 11:04:07 PM
Reply #9

codedmind

  • ***
  • Information
  • Full Member
  • Posts: 92
This is the module.
I have a scheduler cron to exec it every minute
The module exec a python script that output one line (ex: 25860668;510)

November 30, 2015, 09:37:23 AM
Reply #10

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Hi codemind,

this program is missing a couple of things:

1) Program.Run() instruction in the startup code
2) a while (Program.IsEnabled) loop (with a Pause(60) between each iteration), "polling" the watt value from the script and raising the event

Cheers,
g.

December 02, 2015, 06:51:26 PM
Reply #11

codedmind

  • ***
  • Information
  • Full Member
  • Posts: 92
I gene

I have done thatm however the "problem" is the same, i don't have total in the widget always 0 KW

December 02, 2015, 07:39:43 PM
Reply #12

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
The attacched program is working fine.

g.