Results 1 to 1 of 1

Thread: Easy Power Management output from Wiser or Touch Screen

  1. #1
    Automated Home Jr Member
    Join Date
    Nov 2011
    Location
    Sydney, Australia
    Posts
    14

    Default Easy Power Management output from Wiser or Touch Screen

    Hi All,

    I wrote some logic for a client who wanted a text output rather than looking at the pretty graphs. Thought someone here might also find it useful for your own purposes.

    It displays the last 12 months of Current Measurement Data (from the 5504CMU C-Bus module) and gives an easy to read output to assess your power use for the period. You just go into PICED, select your project and 'refresh project from unit' so it downloads the latest power CSV file. Of course, don't upload an earlier project to your screen or Wiser or you will overwrite your power data.

    You can run this in the PICED logic window by setting your 'logic options' in the logic window to 'Allow use of all functions for testing' and 'Send WriteLn output to log'. You then look for the output in the PICED log file under the 'View' pull down menu in the main PICED window.

    Output is as follows:

    Code:
    C-Bus Network Power Measurement
         
    Total Energy (in kWh) Use Measured as at 17/05/2013
    This Months Power Use To Date  = 665 kWh
    This Months Expected Power Use = 1241 kWh
        
    Previous 12 Months
        April 2013 Power Use = 1238 KWh
        March 2013 Power Use = 2166 KWh
      Febuary 2013 Power Use = 2324 KWh
      January 2013 Power Use = 1527 KWh
     December 2012 Power Use = 1514 KWh
     November 2012 Power Use = 1826 KWh
      October 2012 Power Use = 1607 KWh
    September 2012 Power Use = 1353 KWh
       August 2012 Power Use = 1708 KWh
         July 2012 Power Use = 1850 KWh
         June 2012 Power Use = 1784 KWh
          May 2012 Power Use = 1632 KWh
         
    Average Monthly Energy Use          =  1711 kWh
    This Month's Expected Power Use     =  1241 kWh
    This Month's Energy Use vs Average  =     -27.5 %
    Setup in a new module in PICED Logic called [Power Monitor] (or whatever)

    Code:
    WriteLn('C-Bus Network Power Measurement');
    WriteLn('     ');
    DateToString(Date, Today);
    DataString := Today;
    WriteLn('Total Energy (in kWh) Use Measured as at ',DataString);
    MonthPower := GetRealIBSystemIO("Power Meter Total Energy",3, 1, 0, 0, 0, -1);
    Format(DataString, 'This Months Power Use To Date  = ', (MonthPower/1000):0:0,' kWh');
    WriteLn(DataString);
    CMonthPower := GetRealIBSystemIO("Power Meter Total Energy",3, 1, 0, 0, 1, -1);
    Format(DataString, 'This Months Expected Power Use = ', (CMonthPower/1000):0:0,' kWh');
    WriteLn(DataString);
    WriteLn('    ');
    WriteLn('Previous 12 Months');
    countup := 1;
    while countup <= 12 do
      begin
      MonthPower := GetRealIBSystemIO("Power Meter Total Energy", 3, 1, countup, 0, 0, -1);
      Format(DataString, ' Power Use = ', (MonthPower/1000):0:0);
      MonthValue:=Date-(31*countup);
      DecodeDate(MonthValue, CYear, CMonth, CDay);
        case CMonth of //Select Month
        1 : DMonth:='January';
        2 : DMonth:='Febuary';
        3 : DMonth:='March';
        4 : DMonth:='April';
        5 : DMonth:='May';
        6 : DMonth:='June';
        7 : DMonth:='July';
        8 : DMonth:='August';
        9 : DMonth:='September';
        10 : DMonth:='October';
        11 : DMonth:='November';
        12 : DMonth:='December';
        end; 
    WriteLn(DMonth:9,CYear:5,DataString,' KWh');
      countup := Succ(countup);
      MonthAv:=MonthAv + MonthPower; 
      end;
    WriteLn('     ');
    WriteLn('Average Monthly Energy Use          = ',(MonthAv/12)/1000:5:0,' kWh');
    Format(DataString, 'This Month''s Expected Power Use     = ', (CMonthPower/1000):5:0,' kWh');
    WriteLn(DataString);
    WriteLn('This Month''s Energy Use vs Average  = ',(-((MonthAv/12)-CMonthPower)/(MonthAv/12)*100):9:1,' %');  
    DisableModule("Power Monitor");
    It is designed to just run once and you can use it from PICED or your touch screen using a button etc.


    and you need these variables defined in 'Global Variables'

    Code:
    Global Variables
    countup : integer;
    DataString : string;
    Today :string;
    s :string;
    MonthPower : real;
    CMonthPower : real;
    CYear:integer;
    CMonth:integer;
    MonthAv : real;
    DMonth:string;
    CDay:integer;
    MonthValue:integer;


    In the case you wanted to write the output to a text file to keep as a power history, either on a Colour Touch Screen or from PICED after downloading the power data from the touch screen, use the following:

    Code:
    AssignFile(file2, '12Month_Power_Data.txt');
    ReWrite(file2);
    WriteLn(file2,'C-Bus Network Power Measurement');
    WriteLn(file2,'     ');
    DateToString(Date, Today);
    DataString := Today;
    WriteLn(file2,'Total Energy (in kWh) Use Measured as at ',DataString);
    MonthPower := GetRealIBSystemIO("Power Meter Total Energy",3, 1, 0, 0, 0, -1);
    Format(DataString, 'This Months Power Use To Date  = ', (MonthPower/1000):0:0,' kWh');
    WriteLn(file2,DataString);
    CMonthPower := GetRealIBSystemIO("Power Meter Total Energy",3, 1, 0, 0, 1, -1);
    Format(DataString, 'This Months Expected Power Use = ', (CMonthPower/1000):0:0,' kWh');
    WriteLn(file2,DataString);
    WriteLn(file2,'    ');
    WriteLn(file2,'Previous 12 Months');
    countup := 1;
    while countup <= 12 do
      begin
      MonthPower := GetRealIBSystemIO("Power Meter Total Energy", 3, 1, countup, 0, 0, -1);
      Format(DataString, ' Power Use = ', (MonthPower/1000):0:0);
      MonthValue:=Date-(31*countup);
      DecodeDate(MonthValue, CYear, CMonth, CDay);
        case CMonth of //Select Month
        1 : DMonth:='January';
        2 : DMonth:='Febuary';
        3 : DMonth:='March';
        4 : DMonth:='April';
        5 : DMonth:='May';
        6 : DMonth:='June';
        7 : DMonth:='July';
        8 : DMonth:='August';
        9 : DMonth:='September';
        10 : DMonth:='October';
        11 : DMonth:='November';
        12 : DMonth:='December';
        end; 
    WriteLn(file2,DMonth:9,CYear:5,DataString,' KWh');
      countup := Succ(countup);
      MonthAv:=MonthAv + MonthPower; 
      end;
    WriteLn(file2,'     ');
    WriteLn(file2,'Average Monthly Energy Use          = ',(MonthAv/12)/1000:5:0,' kWh');
    Format(DataString, 'This Month''s Expected Power Use     = ', (CMonthPower/1000):5:0,' kWh');
    WriteLn(file2,DataString);
    WriteLn(file2,'This Month''s Energy Use vs Average  = ',(-((MonthAv/12)-CMonthPower)/(MonthAv/12)*100):9:1,' %');  
    CloseFile(file2);
    DisableModule("Power Monitor");
    Please note this code was knocked up quickly till late last night and may have some minor bugs. If you find one, be nice and PM me rather than replying and I will correct it for everyone.

    Otherwise Enjoy and I hope you find it useful.

    Blacky7
    Last edited by blacky7; 17th May 2013 at 04:50 AM.
    Nous House - Smart Home... Smart Owner!

    http://www.noushouse.com.au/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •