Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New chart for power production for all inverters in a same graph #129

Open
autourdupc opened this issue Nov 15, 2024 · 35 comments
Open

New chart for power production for all inverters in a same graph #129

autourdupc opened this issue Nov 15, 2024 · 35 comments

Comments

@autourdupc
Copy link

autourdupc commented Nov 15, 2024

Hello Patience.

Let me provide a new php file that displays power measurements for all inverters in one single chart.

It displays in real time the total power for all inverters, displays the max power of the day and other stuffs.
One can change the date on the calendar to get chart for other days.
It refreshs every 112 secondes
It works on phone device and on computers browser.

image

image

Find below the php file named lbo_chart_p.php
Put it in the /var/www/html/chartjs folder -> /var/www/html/chartjs/lbo_chart_p.php
Need to sudo chmod +x /var/www/html/chartjs/lbo_chart_p.php

Then call it via http://your-ip/chartjs/lbo_chart_p.php

You will find the source code fully commented for maintenance and explanations.
I actually do not know how to link it to your existing main page, but I will work on it !

23/01/2025 : File updated to V1.70 (Better handling if missing inverters + more robust data reading)
lbo_chart_p.zip

11/01/2025 : File updated to V1.60 (Error counting inverters + better handling possible errors)
lbo_chart_p.zip

28/12/2024 : File updated to V1.50 (Manage day changing - Now chart follow the actual day)
lbo_chart_p.zip

19/12/2024 : File updated to V1.40 (Manage units automatically - Code cleaned)
lbo_chart_p.zip

17/12/2024 : File updated to V1.30 (energy calculation is now ok)
lbo_chart_p.zip

15/12/2024 : File updated to V1.20 (no more "undefined" date after date selection)
lbo_chart_p.zip

15/11/2024 : File updated to V1.10
lbo_chart_p.zip

15/11/2024 : Original file V1.00
lbo_chart_p.zip

I hope to live up to your expectations.

Cheers,
Laurent.

@defaliz
Copy link

defaliz commented Nov 18, 2024

Thank a lot Autourdupc, very useful
i'll try..
french ? bonne journée et merci encore...

@autourdupc
Copy link
Author

Thank a lot Autourdupc, very useful i'll try.. french ? bonne journée et merci encore...
Oui :)

I also made a calculation of energy, but seem to be not the same as the one calculated by Patience, expecially on low values...
I don't know who got the truth... This is why this calculation is still not available in this chart... I need to see with Patience when he got time.

@defaliz
Copy link

defaliz commented Nov 18, 2024

hi,
in the file there is a include setTimezone.php, but where is this file ?
regards

@defaliz
Copy link

defaliz commented Nov 18, 2024

here is the warnings
Warning: include(setTimezone.php): failed to open stream: No such file or directory in /var/www/html/chartjs/lbo_chart_p.php on line 34

Warning: include(): Failed opening 'setTimezone.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/chartjs/lbo_chart_p.php on line 34

@autourdupc
Copy link
Author

autourdupc commented Nov 18, 2024

in the file there is a include setTimezone.php, but where is this file ?

Hum... No warning here...
I run version RPI-ECU 4_2.
Anyway, I do not use the timezone because I only read data and display them so you can comment both lines like this

// We need to set the timezone = ok
//include 'setTimezone.php';
//$tz = date_default_timezone_get();

@defaliz
Copy link

defaliz commented Nov 18, 2024 via email

@autourdupc
Copy link
Author

Ok thanks..
Is it running well ?

@defaliz
Copy link

defaliz commented Nov 18, 2024 via email

@autourdupc
Copy link
Author

autourdupc commented Nov 18, 2024

, i need tobuodate..

DO not forget to backup database !!! But should work because chart is not RPI version dependant

@autourdupc
Copy link
Author

autourdupc commented Nov 21, 2024

@defaliz

Warning: include(setTimezone.php): failed to open stream: No such file or directory in /var/www/html/chartjs/lbo_chart_p.php on line 34

In fact, this file is mandory. If not present the timezone comes UTC so chart time values come bad.
Maybe the chart can be ok in previous version of RPI-ECU without this line but time sould be wrong.

In the 4.2 version, there is no warning and everything goes right with thoses lines.

@defaliz
Copy link

defaliz commented Nov 21, 2024

Ok i really need to update my rpiEcu...

@patience4711
Copy link
Owner

patience4711 commented Nov 25, 2024

Hi Laurent, Apparently you had a good time playing with the software. With nice result. I cannot test with your chart (because i have only one inverter), but i trust that it works oke. I have never put any effort into this overall graph because i cannot test and.... wel the chart will pretty much look like the charts of the individual inverters so i thought it wouldn't add much of value.
Another assumption was that this is a fairly complicated operation that could lead to unacceptable long response times when quering the chart, especially with >5 inverters.

But again, i could not verify this assumption since i have only one inverter. So how do you experience the response time?

Anyway when i have time i can study your code. At a first shot i saw that it is much more complicated than a simple query of one inverter.

If you are wondering about the energy values, the wiki explains how they are calculated.

@autourdupc
Copy link
Author

autourdupc commented Nov 25, 2024

Hello.

wel the chart will pretty much look like the charts of the individual inverters so i thought it doesn't add much valuable

Grrrrr !
It depends on how the panels / inverters are oriented... If all are the same position, sure, it is the same chart... But if they are east/south/west, then the SUM is interesting (and of course, it is the SUM of each charts) !

Response time is good... Nothing special on Pi zero CPU load ! (I also tested 1 month on 1 chart, it was a pain but working... Approx 1 minute response time, and 6 months up to 10 minutes).

Concerning calculation, it is a little bit complicated bec. I had to query each values for each inverters in one query then SUM them via a PHP loop.
Code seem complicated bec. I play with sunrise/sunset, time calculations, and also linear extrapolation if 1 point is missing (yes yes... Sometimes some points are missing in the database).

Concerning power, I got it, but I find values not the same as yours... I asked Ai "Claude" to help me, and my calculation is okay according to Claude, so I need to do more tests.

Today, due to the storm all my 5 panels went away... Cables I made are still in good health, but thoses I bought are broken (the crimps have come loose).
I need to rebuild all the supports for the panels... Need some days !

@autourdupc
Copy link
Author

autourdupc commented Nov 30, 2024

Well... I'm not lucky...
I've just reinstalled my solar panels, and found RPI-ECU working strangely...
Made a reboot and nothing !
Seem that the SD-CARD went corrupt.

It a SAMSUNG EVO...
I lost again my database

@autourdupc
Copy link
Author

autourdupc commented Dec 8, 2024

Hello @patience4711

I published a new release of the chart with energy calculation (available in the first post of this thread), but I found a big difference with your calculation.
I asked an AI (Claude) to help me resolve the issue but the AI gave me the same results.
I also gave the AI a full day measurements table and it gave the same calculation as me...

I'm really confused with the Energy values. What is your opinion about it ?

@patience4711
Copy link
Owner

I don't see the problem. The energy values come from the inverter, it is the difference between a counters begin- (normally 0 at reboot, start of the day) and end-value. You don't have to calculate that.

I don't know how you calculate, maybe average current * average voltage or so? these values are not useable because they reflect only the level at polling time.
If you poll a voltage of 40 and 5 min later another poll of 44 you can't say that the average voltage in this period is 42 because meanwhile the voltage could be 50 at some time. The same goes for the current. So you never can tell what the amount of energy was during the period between 2 polls, let alone during a whole day.

@autourdupc
Copy link
Author

autourdupc commented Dec 13, 2024

Energy can be calculated...
It is the power given during a time period.
We can calculate the energy even if we have one measure each 5 minutes. Of course, we don't have the value between the 2 points, but the energy calculation is still good.
Try to read some websites, or ask AI systems on energy calculation, they ill give you the same answer.

As I told you, I tried to give the whole dataset for a full day to an AI, and it give me the same results as me...

Actually in my region we have fog, so the values are bad - aroud 40 W produced (with peak at 120 W) for 1200 W installed.
The power variation between 2 collected points will not vary very much...
ANd we can also say that we could have same variation less than variation more... So in the average the SUM of variations tend to reach 0.

I definitively wonder why energy calculation is so different !

FYI, this is what Claude AI says...

To calculate the total consumption in watt-hours from power measurements taken every 5 minutes, the method is exactly the same as for solar production:
Formula:
CopyTotal consumption (Wh) = (Σ measurement_i) × (5/60)
= (Σ measurement_i) × (1/12)
Example:

If your measurements are: 500W, 600W, 550W, 520W
Sum = 2170W
Consumption = 2170 × (1/12) = 180.83 Wh

@defaliz
Copy link

defaliz commented Dec 13, 2024 via email

@autourdupc
Copy link
Author

autourdupc commented Dec 13, 2024 via email

@defaliz
Copy link

defaliz commented Dec 13, 2024 via email

@autourdupc
Copy link
Author

autourdupc commented Dec 13, 2024

Same here in Normandy, no sun since many days...

Today's production with 1200 watts panels south orientation
Screenshot_20241213-185459

@patience4711
Copy link
Owner

Consider this graph. The black line are power values polled every 5 minutes. When we would poll every second, the power chart could look like the red line.
The energy would be the area of the graph in which case they are quite different.

graph

@autourdupc
Copy link
Author

autourdupc commented Dec 16, 2024

Sure, I understand, but usually, the values above and the values under are quite equals so the error is small...
And this is true when solar intensity varies in cloudy conditions with sun/clouds alternances.
Actually, all the sky is gray so there is a continuous power production without littles variations.

And finally, my calculation is so different of the inverter measurements...
Today, my wattmeter report is 450 Wh, RPI-ECU report is 540 Wh and my calculation is 915 Wh (my result is generally twice the wattmeter value).

@patience4711
Copy link
Owner

Anyway your calculation can't be right, too much difference. I just stick to the values the inverter provides, there is no way i can prove that they are wrong.

If your measurements are: 500W, 600W, 550W, 520W
Sum = 2170W
Consumption = 2170 × (1/12) = 180.83 Wh

Energy calculation is about power over a period of time, if you have a constant powerlevel of 2170 during 5 minutes, then the 180.83 Wh is correct. The closest approach is avarage power level during 5 min/12 but even then, if you don't know what happened during this time you can't calculate the energy.

@autourdupc
Copy link
Author

Hello @patience4711

I'm pleased to tell you that I found my mistake in my code for energy calculation.

Now I'm able to get the same value as yours. V1.30 is now okay. Remains some minors enhancements I need to do

@defaliz
Copy link

defaliz commented Jan 7, 2025

Hi autourdupc
i've test your last version 1.5 with last version de rpiecu and i've errors in the page, like that :

Fatal error: Uncaught InfluxDB\Client\Exception: error parsing query: found WHERE, expected identifier at line 1, char 28 in /usr/lib/cgi-bin/ecu/vendor/influxdb/influxdb-php/src/InfluxDB/ResultSet.php:49 Stack trace: #0 /usr/lib/cgi-bin/ecu/vendor/influxdb/influxdb-php/src/InfluxDB/ResultSet.php(39): InfluxDB\ResultSet->validate() #1 /usr/lib/cgi-bin/ecu/vendor/influxdb/influxdb-php/src/InfluxDB/Driver/Guzzle.php(107):

@autourdupc
Copy link
Author

@defaliz
This is very strange...
Please give copy of version from http://your_ip/details.php

Then
sudo ls -l /var/www/html/chartjs/
should provide something like
-rwxr-xr-x 1 root root 16640 Dec 28 12:13 lbo_chart_p.php
-> Give me yours

Then
sudo cat /var/www/ecu_data/inverterCount.txt
should provide something like
2
-> Give me yours

sudo ls -l /var/www/ecu_data/inverters/
should provide something like
-rw-r--r-- 1 www-data www-data 427 Dec 7 2021 invData0
-rw-r--r-- 1 www-data www-data 169 Jul 13 10:04 invProperties0
-rw-r--r-- 1 www-data www-data 96 Dec 6 21:35 invProperties1
-> Give me yours

@defaliz
Copy link

defaliz commented Jan 10, 2025

Hi,
yes very strange, il's working with rpiecu 3_10
here is infos...
details.php

software version RPI-ECU-v4_3
number of inverters 1
number of panels 2
polling starts at 08:46 hr
polling stops at 17:19 hr
overall total energy 2.0 kWh
CO2 emission saved: 0.5 kg
trees planted: 0.0

-rwxr-xr-x 1 root root 16697 Jan 7 11:57 /var/www/html/chartjs/lbo_chart_p.php

cat /var/www/ecu_data/inverterCount.txt --> 1 pour l'instant 1 seul inverter

ls -l /var/www/ecu_data/inverters/

-rw-r--r-- 1 www-data www-data 427 Dec 7 2021 invData0
-rw-r--r-- 1 www-data www-data 427 Dec 7 2021 invData0.sav
-rw-r--r-- 1 www-data www-data 98 Sep 22 2022 invProperties0.sav
-rw-r--r-- 1 www-data www-data 177 Apr 21 2023 invProperties0_sav
-rw-r--r-- 1 www-data www-data 174 Jan 9 12:08 invProperties1
-rw-r--r-- 1 www-data www-data 105 Apr 21 2023 invProperties1_sav

@defaliz
Copy link

defaliz commented Jan 10, 2025

i found the error
variable $from is empty...because $InverterCount = 0
if i try $InverterCount = 1 so all works fine...
inverterCount.txt contain 1

actually i've only one inverter because the other is out of order, i think it's in the loop
for ($i=0 ; $i < $InverterCount ; $i++)
{
$from = $from."inv".$i.",";
}

@autourdupc
Copy link
Author

Hello @defaliz

Can you please test this 1.6 version ?
If working I will publish.
lbo_chart_p.zip

@defaliz
Copy link

defaliz commented Jan 11, 2025

Hi
works perfectly ! (just change number version and it's OK)
thanks for quick correction...
do you have succeeded with mosqitto and HA ?

image

@autourdupc
Copy link
Author

autourdupc commented Jan 11, 2025

@defaliz
Please update with the one on top of this topic... There are other modifications.

Concerning HA, got test data coming to HA. Need now to create sensor. I'm also working on some other automations to test/learn HA and scripts stuffs... Not so easy

@defaliz
Copy link

defaliz commented Jan 11, 2025

Ok, i've downloaded last version 1.6, all is good now
thanks and have a good evening

@autourdupc
Copy link
Author

New version 1.70...

@defaliz
Copy link

defaliz commented Jan 23, 2025

Merci 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants