Houseenergy and metern_log.txt

Talks about metering
TonyP62
Posts: 97
Joined: Fri May 01, 2015 11:07 pm

Houseenergy and metern_log.txt

Post by TonyP62 » Mon Nov 27, 2017 11:11 am

Hello all.
I have a question for us.
I am using 1 SDM120C for Consumption and i need an help for configuring MeterN to use it.
I have put the com_daemon.php and com_daemon_loop.php into comapps giving them permission www-data users-group . Then i modified the config_daemon.php for starting the com_daemon .
It seems to work, but every time i use the houseenergy commands, i obtain :

Code: Select all

root@raspberrypi:/var/www/metern# houseenergy -energy
cat: /dev/shm/metern_log.txt: File o directory non esistente
cat: /dev/shm/metern_log.txt: File o directory non esistente
cat: /dev/shm/metern_log.txt: File o directory non esistente
cat: /dev/shm/metern_log.txt: File o directory non esistente
cat: /dev/shm/metern_log.txt: File o directory non esistente
cat: /dev/shm/metern_log.txt: File o directory non esistente
root@raspberrypi:/var/www/metern# houseenergy -power
cat: /dev/shm/metern_log.txt: File o directory non esistente
cat: /dev/shm/metern_log.txt: File o directory non esistente
cat: /dev/shm/metern_log.txt: File o directory non esistente
2(0*W)
It seems that meter_log.txt was not created by software.
Can you give me an help ?

Thanks,
Tony

jeanmarc
Posts: 1606
Joined: Thu Aug 29, 2013 7:16 am

Re: Houseenergy and metern_log.txt

Post by jeanmarc » Mon Nov 27, 2017 1:59 pm

Maybe your php service don't have the permission to write into /dev/shm.
Enable mN debug, your webserver logs for more details.

TonyP62
Posts: 97
Joined: Fri May 01, 2015 11:07 pm

Re: Houseenergy and metern_log.txt

Post by TonyP62 » Mon Nov 27, 2017 8:25 pm

jeanmarc wrote:
Mon Nov 27, 2017 1:59 pm
Maybe your php service don't have the permission to write into /dev/shm.
Enable mN debug, your webserver logs for more details.
Thanks Jean-Marc. The permission for /dev/shm/ are www-data:www-data for all files.
I think that MeterN is not executing the com_daemon_loop that execute the SDM120 file and must create the /dev/shm/metern_log.txt

The com_daemon.php into comapps don't have the launch for sdm120c, so i have set to use the com_daemon_loop into the config_daemon.php . It's right ?
In which way can i see if com_daemon is been execute ? I don't remember linux commands.

Thanks.

jeanmarc
Posts: 1606
Joined: Thu Aug 29, 2013 7:16 am

Re: Houseenergy and metern_log.txt

Post by jeanmarc » Mon Nov 27, 2017 8:46 pm

1) edit metern/config/config_daemon.php to enable the daemon (uncomment, ajust the path)

2) You may also edit the daemon (/srv/http/comapps/com_daemon.php) to ajust the path

3) Edit the infinite loop (/srv/http/comapps/com_daemon_loop.php) for your needs

4) Restart mN and check if the daemon is running (ps -ef | grep com_daemon)

5) If not, enable debug in mN and report the log

6) You may also try the daemon alone : Stop mN, then launch (php com_daemon.php start)
Check if there is /dev/shm/metern_log.txt filed with values
Stop the beast (php com_daemon.php stop) and, if you runned the script as root, remove (rm /dev/shm/metern_log.txt)

TonyP62
Posts: 97
Joined: Fri May 01, 2015 11:07 pm

Re: Houseenergy and metern_log.txt

Post by TonyP62 » Mon Nov 27, 2017 9:18 pm

Thanks Jean-Marc . With your explanation i have found the error.
I have made a symbolic link of /var/www/comapps/com_daemon.php into /usr/bin/com_daemon
and i have insert this as an executable file into config_daemon.php
The correct way for start the daemon is to call the php file:

exec php /var/www/comapps/com_daemon.php start

Sorry for disturb and many many thanks for all.

TonyP62
Posts: 97
Joined: Fri May 01, 2015 11:07 pm

Re: Houseenergy and metern_log.txt

Post by TonyP62 » Sun Dec 03, 2017 2:21 pm

Hello All.
I need an explanation about house energy works.
I have the first SDM220C for Production (MeterID = 1) and a second for Consumption ( MeterID = 2 ).
Now i want configure houseenergy for MeterN, but i don't understand how it works. Why the default file has 7 virtual meters ? I must configure virtual meters for Volt,Freq e Cos ?
I have this configuration :

Code: Select all

// Consumption
$HOUSEID     = '1'; // ID was elect
$HOUSEmetnum = 2; // meter number
// Selfconsumption
$SELFID      = 'self';
$SELFCmetnum = 7;

//// Set up real meters ////
// Production
$PRODID       = '1'; // ID was solar
$PRODcmd      = 'pool123s -energy'; // Energy command
$POWERPRODcmd = 'pool123s -power'; // Power
// TOT return the total power (eg if import = 45W, export -55W)
$TPID        = '1_P';
$TOTPOWERcmd = 'cat /dev/shm/metern_log.txt | egrep "^1_P\(" | grep "*W)"';

// Energy Imported
$IMPID     = '1_IE';
$IMPcmd    = 'cat /dev/shm/metern_log.txt | egrep "^1_IE\(" | grep "*Wh)"';
$IMPmetnum = 5;

//// Indicators ////
$VOLTID  = '1_V';
$VOLTcmd = 'cat /dev/shm/metern_log.txt | egrep "^1_V\(" | grep "*V)"';
$FRQID   = '1_F';
$FRQcmd  = 'cat /dev/shm/metern_log.txt | egrep "^1_F\(" | grep "*Hz)"';
$COSID   = '1_PF';
$COScmd  = 'cat /dev/shm/metern_log.txt | egrep "^1_PF\(" | grep "*F)"';

// Path to metern
$MNDIR = '/srv/http/metern';
// Save previous values in a file, make sure your http user can write there
$prevfile = '/srv/http/comapps/prevhouseenergy.json';
but when i call houseenergy it returns the error for meters 4,6,7 that are not configured.
Can you give me an explanation ?

Thanks.

TonyP62
Posts: 97
Joined: Fri May 01, 2015 11:07 pm

Re: Houseenergy and metern_log.txt

Post by TonyP62 » Sun Dec 03, 2017 4:04 pm

I found the solution.
Now my houseenergy.php is working with this config:

Code: Select all

//// Set the 2 virtual meters ////
// Consumption
$HOUSEID     = 'elect'; // ID
$HOUSEmetnum = 2; // meter number
// Selfconsumption
$SELFID      = 'self';
$SELFCmetnum = 5; // 7

//// Set up real meters ////
// Production
$PRODID       = 'solar'; // ID
$PRODcmd      = 'pool123s -energy'; // Energy command
$POWERPRODcmd = 'pool123s -power'; // Power
// Energy Imported
$IMPID     = '1_IE';
$IMPcmd    = 'cat /dev/shm/metern_log.txt | egrep "^1_IE\(" | grep "*Wh)"';
$IMPmetnum = 3; // 5

// Energy Exported
$EXPID     = '1_EE';
$EXPcmd    = 'cat /dev/shm/metern_log.txt | egrep "^1_EE\(" | grep "*Wh)"';
$EXPmetnum = 4; // 6

//// Indicators ////
$VOLTID  = '1_V';
$VOLTcmd = 'cat /dev/shm/metern_log.txt | egrep "^1_V\(" | grep "*V)"';
$FRQID   = '1_F';
$FRQcmd  = 'cat /dev/shm/metern_log.txt | egrep "^1_F\(" | grep "*Hz)"';
$COSID   = '1_PF';
$COScmd  = 'cat /dev/shm/metern_log.txt | egrep "^1_PF\(" | grep "*F)"';

// Path to metern
$MNDIR = '/var/www/metern';
// Save previous values in a file, make sure your http user can write there
$prevfile = '/var/www/comapps/prevhouseenergy.json';
The problem now is that values from Consumption, Imported and Exported, are not real as SDM220c measured.
It seems that MeterN or HouseEnergy has added a value to them into the DashBoard.
How can i solve it ?

jeanmarc
Posts: 1606
Joined: Thu Aug 29, 2013 7:16 am

Re: Houseenergy and metern_log.txt

Post by jeanmarc » Sun Dec 03, 2017 4:12 pm

Houseenergy is an example. It assume you have one real meter for the whole house (import/export values) and another real meter for production.
Check the schema at the top the the script for details.

If you own reals meters for the consumption and for production, you need to make your own script. So, you can make 3 virtuals meters for : the export (if Prod > Consu it equal Prod - Consu else 0), the import (Consu - Prod and can't be negative) and the self consumption (if prod >0 and if export is 0 it equal to prod but also if prod >0 and export >0 it equal to prod - export)
If i get it right :lol:

Other requests if just for getting indicators values (Volt, Freq, Cos phi)

TonyP62
Posts: 97
Joined: Fri May 01, 2015 11:07 pm

Re: Houseenergy and metern_log.txt

Post by TonyP62 » Mon Dec 04, 2017 4:18 pm

Finally i have understood as houseenergy works and it seems to work well. But i have another question for you.
I want to pickup the real values from the electrical meters and write them into the meters_log.txt .
I have modified the file in this way:

Code: Select all

// Energy Exported
$EXPID     = '1_EE';
// $EXPcmd    = 'cat /dev/shm/metern_log.txt | egrep "^1_EE\(" | grep "*Wh)"';
$EXPcmd    = 'sdm120c -a1 -b9600 -PN -w5 -2 -m -e /dev/ttyUSB0';
$EXPmetnum = 6;
and all works. But i think is better that it works like:

Code: Select all

// Energy Exported
$EXPID     = '1_EE';
$EXP_EE    = 'sdm120c -a1 -b9600 -PN -w5 -2 -m -e /dev/ttyUSB0';
// Insert here the code that writes the value into /dev/shm/metern_log.txt
$EXPcmd    = 'cat /dev/shm/metern_log.txt | egrep "^1_EE\(" | grep "*Wh)"';
$EXPmetnum = 6;


Can you help me into the
// Insert here the code that writes the value into /dev/shm/metern_log.txt
?

jeanmarc
Posts: 1606
Joined: Thu Aug 29, 2013 7:16 am

Re: Houseenergy and metern_log.txt

Post by jeanmarc » Mon Dec 04, 2017 7:16 pm

Well, houseenergy reads the values not write.
You can use com_daemon and check com_daemon_loop script for that purpose.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest