HomeGenie Forum

Automation Program Plugins and Wizard Scripting => Help => Topic started by: codedmind on November 26, 2015, 10:37:00 PM

Title: Understandig energy module
Post by: codedmind on November 26, 2015, 10:37:00 PM
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?
Title: Re: Understandig energy module
Post by: Gene on November 27, 2015, 05:00:18 PM
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.
Title: Re: Understandig energy module
Post by: codedmind on November 27, 2015, 05:16:20 PM
Great.

Thanks gene
Title: Re: Understandig energy module
Post by: codedmind on November 27, 2015, 10:18:12 PM
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
Title: Re: Understandig energy module
Post by: Gene on November 28, 2015, 04:16:25 PM
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.
Title: Re: Understandig energy module
Post by: codedmind on November 28, 2015, 09:39:55 PM
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)
Title: Re: Understandig energy module
Post by: Gene on November 28, 2015, 10:09:59 PM
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.
Title: Re: Understandig energy module
Post by: codedmind on November 28, 2015, 10:16:50 PM
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?
Title: Re: Understandig energy module
Post by: Gene on November 28, 2015, 10:23:57 PM
Can you please me show the code where you read the value and put it into "Meter.Watts" parameter?

g.
Title: Re: Understandig energy module
Post by: codedmind on November 28, 2015, 11:04:07 PM
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)
Title: Re: Understandig energy module
Post by: Gene on November 30, 2015, 09:37:23 AM
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.
Title: Re: Understandig energy module
Post by: codedmind on December 02, 2015, 06:51:26 PM
I gene

I have done thatm however the "problem" is the same, i don't have total in the widget always 0 KW
Title: Re: Understandig energy module
Post by: Gene on December 02, 2015, 07:39:43 PM
The attacched program is working fine.

g.