sincze / Domoticz

Pass2PHP Domoticz Scripts
17 stars 12 forks source link

Unexpected http code #17

Open spacewalker56 opened 1 year ago

spacewalker56 commented 1 year ago

Dear Sincze,

I installed the Delta_inverter.php in Domoticz I altered the username, password and Domoticzdevice and also the website port number to port 8084. Executing the php command I get no error but in the log I see this error. I get no values in my Delta screen. How could I solve this?

2023-07-08 07:45:02.686 Status: --->> Cookie File: /var/tmp/Delta.cookie exists! 2023-07-08 07:45:02.691 Status: --->> Cookie File: /var/tmp/Delta.cookie is writable! 2023-07-08 07:45:02.695 Status: --->> Login OK to proceed -> 2023-07-08 07:45:02.897 Status: --->> Delta inverter: Data: Unexpected HTTP code:

sincze commented 1 year ago

10:15: mmm damn I would have hoped the last line would have mentioned the code it received. Let me check. 10:20: I committed / released a new version of the script. Can you try that one so we can see the results ?

spacewalker56 commented 1 year ago

Hi Sincze, thank you for your very quick reply.

I altered the script and restarted it, I got no error in the log file.

2023-07-08 12:24:00.257 Status: --->> Cookie File: /var/tmp/Delta.cookie exists! 2023-07-08 12:24:00.257 Status: [web:8084] Incoming connection from: 127.0.0.1 2023-07-08 12:24:00.263 Status: --->> Cookie File: /var/tmp/Delta.cookie is writable! 2023-07-08 12:24:00.267 Status: --->> Login OK to proceed ->

So far so good. I now have to wait till I can see some values. Still 0 watt. It should give me 3000 Watt at this moment.

Thank you for your assistance. I hope I get it to work. If you have more clues I would like to hear them.

spacewalker56 commented 1 year ago

Extra information,

I have very often a reset all device statuses...

2023-07-08 12:33:40.734 Status: EventSystem: reset all device statuses... 2023-07-08 12:34:05.383 Status: --->> Cookie File: /var/tmp/Delta.cookie exists! 2023-07-08 12:34:05.388 Status: --->> Cookie File: /var/tmp/Delta.cookie is writable! 2023-07-08 12:34:05.391 Status: --->> Login OK to proceed -> 2023-07-08 12:35:12.694 RFXCOM: Temp + Humidity (Cresta)

sincze commented 1 year ago

Is it working as expected??

spacewalker56 commented 1 year ago

Hi Sandor,

I get no error message but I also receive no data.

Scherm­afbeelding 2023-07-09 om 17 22 46 Scherm­afbeelding 2023-07-09 om 17 23 15 Scherm­afbeelding 2023-07-09 om 17 27 35

2023-07-09 17:25:02.824 Status: --->> Cookie File: /var/tmp/Delta.cookie exists! 2023-07-09 17:25:02.829 Status: --->> Cookie File: /var/tmp/Delta.cookie is writable! 2023-07-09 17:25:02.832 Status: --->> Login OK to proceed -> 2023-07-09 17:25:23.063 Tuyacloud: onHeartbeat called time=1688916323.063605

spacewalker56 commented 1 year ago

I would like to know of there is code or a command so i can see of any data is received or available.

sincze commented 1 year ago

I would like to know of there is code or a command so i can see of any data is received or available.

Option: Change: //print_r($result); To: print_r($result);

And run the script from the prompt.

spacewalker56 commented 1 year ago

This is what i got back at the prompt.

pi@Domoticz:~/domoticz/scripts/pass2php $ php /home/pi/domoticz/scripts/pass2php/delta_inverter.php {"errmsg":"","sucmsg":""}pi@Domoticz:~/domoticz/scripts/pass2php $

In the logfile eveything seems normal.

sincze commented 1 year ago

Did it ever work or stopped working. The DELTA inverter from my monitoring system has been replaced by GoodWe so I don't have working credentials anymore to do further testing on the login proces.

spacewalker56 commented 1 year ago

It has never worked. I never tried before.

It a pity you can’t test anymore. Thank you for you replies and for the script.

Good luck.

Ruud On 9 Jul 2023 at 18:16 +0200, Sandor @.***>, wrote:

Did it ever work or stopped working. The DELTA inverter from my monitoring system has been replaced by GoodWe so I don't have working credentials anymore to do further testing on the login proces. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

sincze commented 1 year ago

It has never worked. I never tried before. It a pity you can’t test anymore. Thank you for you replies and for the script. Good luck. Ruud On 9 Jul 2023 at 18:16 +0200, Sandor @.>, wrote: Did it ever work or stopped working. The DELTA inverter from my monitoring system has been replaced by GoodWe so I don't have working credentials anymore to do further testing on the login proces. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.>

If you want. you can assign a temp pwd to it and I'll try to use yours to fix the script so you can use it.

sincze commented 1 year ago

Working on it. I do already see 1 thing and that is there are 2 inverters listed in your account.

In your case 20:32 I now have: Delta Inverter: for domoticz: 147;25891

2023-07-10 20:37:47.883 Status: --->>Delta: Delta Inverter: 128 for domoticz: 128;25891
2023-07-10 20:37:47.885 Status: --->>Delta: (udevice) | **** => 0,128;25891
spacewalker56 commented 1 year ago

Sorry Sandor, I was very busy and did not check my email for the last 2 days.

You found a way to solve the problem. I also notices I have 2 inverters listed but because of former problems i am afraid to delete the first one. Maybe i delete him anyway.

spacewalker56 commented 1 year ago

Hi Sandor,

I did not edit the plant information yet.

this is the error i get running the php script'

pi@Domoticz:~/domoticz/scripts/pass2php $ php /home/pi/domoticz/scripts/pass2php/delta_inverter.php extract_plantid_from_data PHP Notice: Undefined offset: 0 in /home/pi/domoticz/scripts/pass2php/delta_inverter.php on line 289

Notice: Undefined offset: 0 in /home/pi/domoticz/scripts/pass2php/delta_inverter.php on line 289

spacewalker56 commented 1 year ago

Hi Sandor

I tried to remove the ['0'] at the end if line 289. After that i didnt get an error message running the script but i still get no data in Domoticz

The last line was temporary, running the script now gives me again the php notice.

I am no programmer, but has this failure to do with the P_cid value?

sincze commented 1 year ago

Mmmm interesting. I got Delta Inverter: for domoticz: 107;25891

... let me tweak it a bit. for you. New script is live added 1 line of code.

Do not alter the script! with the keys e.g. it should work just fine.

2023-07-12 21:01:17.386 Status: --->>Delta: Login OK to proceed ->
2023-07-12 21:01:39.258 Status: --->>Delta: Delta Inverter: 79 for domoticz: 79;25891
2023-07-12 21:01:39.261 Status: --->>Delta: (udevice) | **** => 0,79;25891
spacewalker56 commented 1 year ago

Hi Sandor,

thank you for you reply. I copied the script into the folder. After running the php script I get no errors on the prompt. Of course I tried with my credentials and then there were the same errors as before. Changing it back removed the php notifications. My idx is 2116. I think I should use that? I also changed my portnumber to 8084.

I notice, there is something else going on. Using my deltasolar- owner-account I still get the error messages. Using the account I provided to you everything seems to work as I hoped for. I received with those credentials the total of energy I produced this year. I will have al look tomorrow, when the sun shines again what values I receive.

Thank you so far. I will get a new password on my head account. I have no idea why this login which I use on the website too, doesn't work. I keep you posted.

I would never have solved this on my own.

spacewalker56 commented 1 year ago

Something strange happens,

off course I tried to use my owner username and password and I don't get that to work. After changing back to the username and the password I provided to you, I get the same php notifications all the time. maybe I am being refused bij the website now. I will try tomorrow again.

I removed the empty plant so I only have one plant now. Maybe this influences the result.

thanks ,

spacewalker56 commented 1 year ago

I am not able to get it to work anymore.

I added some accounts with the same passwords and it doesn't solve the problem. I think it has something to do with the accounts, because the owner account didn't work from the start and the viewer account you use worked, till yesterday evening.

This is the errormessage again:

pi@Domoticz:~/domoticz/scripts/pass2php $ php /home/pi/domoticz/scripts/pass2php/delta_inverter.php extract_plantid_from_data PHP Notice: Undefined offset: 0 in /home/pi/domoticz/scripts/pass2php/delta_inverter.php on line 290

Notice: Undefined offset: 0 in /home/pi/domoticz/scripts/pass2php/delta_inverter.php on line 290

I feel a little silly because it seemed to work yesterday.

My plant-id is 5502re27tijs and i have only one inverter.

sincze commented 1 year ago

I can see that with the credentials I got provided there now is only 1 inverter left. I updated the code for you.

Delta Inverter: for Domoticz: 270;25891

Tested 21:13 with separate script still for me shows:

Login: OK ready to proceed
Retrieve Data OK
Parsing Received Data OK
Delta Inverter: for Domoticz: 63;25891
spacewalker56 commented 1 year ago

Hi Sandor,

I imported the script and I get values now. The value 25891 is the same as yesterday. It could be the total I produced since my registration

Today I produced 15,46 kWh according to myDeltaSolar.

Thank you so far.  I would like to know what commands you used to get info from myDeltaSolar .

Thank you again.

Ruud On 13 Jul 2023 at 19:58 +0200, Sandor @.***>, wrote:

I can see that with the credentials I got provided there now is only 1 inverter left. I updated the code for you. Delta Inverter: for domoticz: 270;25891 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

sincze commented 1 year ago

Hi Sandor, I imported the script and I get values now. The value 25891 is the same as yesterday. It could be the total I produced since my registration Today I produced 15,46 kWh according to myDeltaSolar. Thank you so far.  I would like to know what commands you used to get info from myDeltaSolar . Thank you again. Ruud On 13 Jul 2023 at 19:58 +0200, Sandor @.>, wrote: I can see that with the credentials I got provided there now is only 1 inverter left. I updated the code for you. Delta Inverter: for domoticz: 270;25891 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.>

A well we will get there eventually. At least you have some data now. The DELTA website is a bit sluggish..... (SLOWWWWWWWWWWW).

To see the commands I used check the URL's in the script that are being called.

If you install 'FIDDLER' for example, login to delta portal, you can see all the hidden stuff flying by by just clicking on the delta webpage.

I do notice that the DELTA app reveils the total number generated in MWh. Let me try to get that value.

spacewalker56 commented 1 year ago

Thank you again.

Tomorrow I wil take a look at the new data again.

Ruud On 13 Jul 2023 at 21:40 +0200, Sandor @.***>, wrote:

Hi Sandor, I imported the script and I get values now. The value 25891 is the same as yesterday. It could be the total I produced since my registration Today I produced 15,46 kWh according to myDeltaSolar. Thank you so far.  I would like to know what commands you used to get info from myDeltaSolar . Thank you again. Ruud … On 13 Jul 2023 at 19:58 +0200, Sandor @.>, wrote: I can see that with the credentials I got provided there now is only 1 inverter left. I updated the code for you. Delta Inverter: for domoticz: 270;25891 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.> A well we will get there eventually. At least you have some data now. The DELTA website is a bit sluggish..... (SLOWWWWWWWWWWW). To see the commands I used check the URL's in the script that are being called. If you install 'FIDDLER' for example, login to delta portal, you can see all the hidden stuff flying by by just clicking on the delta webpage. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

sincze commented 1 year ago

It could be that we still need 1 tweak as stated by you.

The 25891 in the webinterface is so it seems MWh (total generated). To put this into a Domoticz sensor this needs to be done in:

ENERGY = Integer, total cumulative energy in Watt-hours (Wh)

So a small tweak in the following function can do that:


function extract_today_power_from_data($plant_id,$queryresult)
{
    $today_power=false;
    $queryresult = json_decode($queryresult, JSON_PRETTY_PRINT);
    if(isset($queryresult['P_cid'])) 
    {
        $today_power=$queryresult['P_cid'][$plant_id]['0'];
        $today_power=$today_power*1000;  // Shown in MWh convert to kWh
        $today_power=$today_power*1000;  // Convert kWh to Wh
    }
}
spacewalker56 commented 1 year ago

Hi Sandor,

I put this data in the script and it works, but is not giving me the correct values. We have beautiful weather so the values should change and the value 25891 is not changing. Using fiddler I found this data : {"no_table":[],"dc_fix":{"25891":false},"pid_arr":[47458],"tbid_arr":["47458"],"mt_pid_arr":[],"bt_pid_arr":[],"ev_pid_arr":[],"today_start":"2023-07-17 00:00:01","today_end":"2023-07-17 23:59:59","a_pos":"2023-07-17","start_time":"2023-08-01 The value 25891 comes back here. I found another value, that could be interesting "{"plant_ID":["47458"],"tariff":["0"],"te":[19010],"le":[2601690],"btcap":[0],"bt_num":0,"plt_cap":["0"],"de":[153],"btcap_arr":[],"pid_arr":["47458"],"tbid_arr":["47458"],"mt_pid_arr":[],"bt_pid_arr":[],"ev_pid_arr":[],"sum_soc":0,"avbtsoc":0,"plt_type_max":1,"commercial":0,"residential":1,"storage":0}

“te” stand for today energy. And ”le” is the total amount of generated energy. these values are on page https://mydeltasolar.deltaww.com/includes/process_init_energy.php

besides that I can't find the descriptor or value for P_cid.

Are those values we (you) can work with.

And fiddler is an wonderfull programm.

My best regards,

Ruud

Op 15 jul. 2023, om 13:57 heeft Sandor @.***> het volgende geschreven:

It could be that we still need 1 tweak as stated by you.

The 25891 in the webinterface is so it seems MWh (total generated). To put this into a Domoticz sensor this needs to be done in:

ENERGY = Integer, total cumulative energy in Watt-hours (Wh) https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's So a small tweak in the following function can do that:

function extract_today_power_from_data($plant_id,$queryresult) { $today_power=false; $queryresult = json_decode($queryresult, JSON_PRETTY_PRINT); if(isset($queryresult['P_cid'])) { $today_power=$queryresult['P_cid'][$plant_id]['0']; $today_power=$today_power1000; // Shown in MWh convert to kWh $today_power=$today_power1000; // Convert kWh to Wh } } — Reply to this email directly, view it on GitHub https://github.com/sincze/Domoticz/issues/17#issuecomment-1636746175, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHLQL6BAWFPJSPXES347BN3XQKATLANCNFSM6AAAAAA2CUQFT4. You are receiving this because you authored the thread.