sincze / Domoticz

Pass2PHP Domoticz Scripts
17 stars 12 forks source link

Lost Data & Maybe an idea for solution #5

Closed Cees2439867 closed 4 years ago

Cees2439867 commented 4 years ago

Hello Sincze, During the past days I am losing data on my connection to the Growatt server. At first I show you the data from the Growatt app: Screenshot_20200405_222310_com growatt shinephones Now the data showing in Domotics: 2020-04-06 Solar Power Datya Glitches You can see the drops in the data arriving back here in the Netherlands. I suspect that the internet is very busy because of the Corona exchange of data now very high.

Maybe a solution is the take the data retrieved from Growatt servers and update the total for the day with it? There is a difference between the Growatt number, in this example 17 KWh and the Domoticz amount of 15.894 KWh. In the reporting of Domoticz I am short 1.106 for this day.

Sorry if I am not clear enough but I hope I have addressed the issue correctly. Best regards, Cees

sincze commented 4 years ago

Yes I think I understand what you mean, If we grab an other field from the return JSON (total generated) value should always be correct as that one is retrieved from the INVERTER website so should be accurate.

It should be correct... $todaypower = (float)str_ireplace('kWh', '', $data['todayStr']);

Did you configure your device like: image

Cees2439867 commented 4 years ago

afbeelding I Have been struggling with that and thought it hat to be computed? Should it be changed?

sincze commented 4 years ago

Unfortunately 'from device' as that is what I retrieve from the website :)

On Thu, 9 Apr 2020, 22:06 Cees2439867, notifications@github.com wrote:

[image: afbeelding] https://user-images.githubusercontent.com/33065120/78936074-26148a80-7aae-11ea-85f0-9716f5ab5f39.png I Have been struggling with that and thought it hat to be computed? Should it be changed?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sincze/Domoticz/issues/5#issuecomment-611727784, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMCHTNHQHHB6EXNWH6NL33RLYTEZANCNFSM4MCDI3LQ .

Cees2439867 commented 4 years ago

Oeps that works out strangely: afbeelding The day before yesterday I changed to "From Device". Very strange result. Suddenly I have a very big number for the output of my solar system. Just before 00:00 hours I switched back to "Computed". Left it during yesterday. but now the per hour bars have disappeared. This morning I tried again. No difference. I cannot get it working again. What to do now?

sincze commented 4 years ago

I think I spotted the issue. You probably creatd incremental counter. That is an issue if the counter is reset everyday ''todayStr'' starts with 0 every day.

$todaypower = (float)str_ireplace('kWh', '', $data['todayStr']);

Let me check.

sincze commented 4 years ago

Can you modify

$todaypower = (float)str_ireplace('kWh', '', $data['todayStr']);

to $todaypower = (float)str_ireplace('kWh', '', $data['totalValue']);

I've also created a Domoticz plugin. https://github.com/sincze/Domoticz-Growatt-Webserver-Plugin

Cees2439867 commented 4 years ago

I have updated as proposed. The code now looks like: if ($continue) { $data = json_decode($result, JSON_PRETTY_PRINT); $nowpower = (float)str_ireplace('kWh', '', $data['powerValue']); $todaypower = (float)str_ireplace('kWh', '', $data['totalValue']); $str=( $nowpower.';'. $todaypower * 1000 ); #times 1000 to convert the 0.1kWh to 100 WattHour and to convert 2.1kWh to 2100 WattHour lg('Growatt Inverter: '. $nowpower.' for domoticz: '.$str); ud(DOMOTICZDEVICE,0,$str,'GrowattInverter: Generation updated'); } It looks better but the values seem 1000 times to high. afbeelding Do I need to change the conversion? I am so happy you help me with this. Thank you.

Cees2439867 commented 4 years ago

Huge values. I now changed:

$str=( $nowpower.';'. $todaypower * 1000 ); #times 1000 to convert the 0.1kWh to 100 WattHour and to convert 2.1kWh to 2100 WattHour

To: $str=( $nowpower.';'. $todaypower * 1 ); #times 1000 to convert the 0.1kWh to 100 WattHour and to convert 2.1kWh to 2100 WattHour

Values reported in the log file now seem okay. Don't know how to update the values in Domoticz. But that is an nice task for the upcoming days. I am hopeful it works now.

Cees2439867 commented 4 years ago

After I changed the multiplication factor the yellow line is fine. The blue bars stay at zero. I have been looking at the code but donot understand this enough to try something else. The log file says now: 2020-04-13 11:35:02.904 Status: --->> Cookie File: /home/pi/domoticz/scripts/pass2php/growatt.cookie exists! 2020-04-13 11:35:02.907 Status: --->> Cookie File: /home/pi/domoticz/scripts/pass2php/growatt.cookie is writable! 2020-04-13 11:35:04.191 Status: --->> Growatt Inverter: 1880.7 for domoticz: 1880.7;569.1 2020-04-13 11:35:04.213 Status: --->> (udevice) | 11 => 0,1880.7;569.1

Where before I changed the multiplication factor from 1000 to 1 the logfile showed: 2020-04-13 09:50:02.175 Status: --->> Cookie File: /home/pi/domoticz/scripts/pass2php/growatt.cookie exists! 2020-04-13 09:50:02.179 Status: --->> Cookie File: /home/pi/domoticz/scripts/pass2php/growatt.cookie is writable! 2020-04-13 09:50:03.367 Status: --->> Growatt Inverter: 386.1 for domoticz: 386.1;567400 2020-04-13 09:50:03.381 Status: --->> (udevice) | 11 => 0,386.1;567400

Hope this helps.

sincze commented 4 years ago

Leave the code as I suggested it works just fine.

image

If you never worked with totalvalue before you will indeed notice a big spike.. ONLY After 24h it is okay and you can remove the big spike as that is the number of generated energy since installation. )

Cees2439867 commented 4 years ago

You are very right! It works fine now. Thank you very much very your detailed help, much appreciated!

sincze commented 4 years ago

Haha well I've sailed that boat many times. ;-) and sometimes I remember stuff.