DeltaVetal26 / SteVe-OCPP-HTTP-Client

Basic HTTP client for sending commands remotely to the Steve OCPP control panel
10 stars 8 forks source link

API not working #3

Open mathief123 opened 3 years ago

mathief123 commented 3 years ago

Hello.

I implemented the api on my vm and called it as indicated, but instead of working it just shows me the html code of the webpage whithout filling the form, how could i solve it?

Thanks.

DeltaVetal26 commented 3 years ago

Hello.

HTML code and form was displayed due to my error. I haven't disabled its echo output since debugging. Sorry.

Updated the code, now the HTML code should not be displayed. To avoid downloading the file again, you can simply comment out the line // echo $content; in the curlConnectTo () function (48-50 line).

I have re-checked this code. I downloaded main.php, filled in the configuration, and placed this file on my webserver. Next, he turned to this file.

http://youraddress:0000/main.php?key=YourKey&ChargeBoxID=001&cmd=getConnectorState&ConnectorID=2

The answer came (displayed the state of the connector).

Also check for the absence of the '&' character in the login, password from Steve's panel, and AuthKey. If it is there, the script will not be able to correctly understand the request.

Otherwise, I haven't changed anything else.

Regards, Alex

mathief123 commented 3 years ago

I checked the absence of '&' in the login, password and AuthKey, and i'm still not able to start my transaction. I want to start reservation on a chargepoint with id 'Oficina1', connector ID=2, idTag 044A6C82815E80, expiry date 2021-07-09+12:30 and with AuthKey 1234. I call it like this:

main.php?key=1234&ChargeBoxID=Oficina1&cmd=ReserveNow&ConnectorID=1&idTag=044A6C82815E80&Expiry=2021-07-09+12:30

Am i doing something wrong? For some reason i can check the connector status, but i cant do any operation.

DeltaVetal26 commented 3 years ago

Checked the station reservation.

main.php?key=xxxxxx&ChargeBoxID=xxxxxx&cmd=ReserveNow&ConnectorID=1&idTag=ABCDE&Expiry=2021-01-30+12:30

1

This is most likely due to the DOMDocument.

Class 'DOMDocument' not found in /var/www/html/main.php:110

You mentioned this error in the logs. It is DOMDocument that is responsible for interacting with the Steve panel.

Description of the error. https://stackoverflow.com/questions/14395239/class-domdocument-not-found

It is not present or it is disabled in the PHP assembly of your web server. If you have full access to the Web server console, you can connect the DOM (commands for the console are described there). If you are renting hosting, you can contact support and ask them to enable the DOM.

You can check if you have DOM enabled. Create a php file and write there: <?php phpinfo();

Then upload the file to a web server and navigate to it in your browser. All PHP information will be there. The DOM / XML section will indicate if the DOM is included.

mathief123 commented 3 years ago

Do i also need to enable DOM also on the web server where steve is?

DeltaVetal26 commented 3 years ago

No. Only where this script is located.

DeltaVetal26 commented 3 years ago

Checked?

mathief123 commented 3 years ago

It still doesnt work, don't know why.

DeltaVetal26 commented 3 years ago

I'm sorry. Did you manage to connect the DOM and did the error go away?

For my part, I did nothing, this script works without additional actions. The PHP version on my server is 7.2.34.

If it is important for you to launch it, I am ready to help with something, if possible.

mathief123 commented 3 years ago

Thank u so much for your help.

Just asking to see if i did something wrong, what version of steve do u have installed?

El mar, 2 feb 2021 a las 12:41, Alex (notifications@github.com) escribió:

I'm sorry. Did you manage to connect the DOM and did the error go away?

For my part, I did nothing, this script works without additional actions. The PHP version on my server is 7.2.34.

If it is important for you to launch it, I am ready to help with something, if possible.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/DeltaVetal26/SteVe-OCPP-HTTP-Client/issues/3#issuecomment-771577060, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARGNTC4K3NJVI76NQQ5FVDTS47QFXANCNFSM4WVOWNOA .

DeltaVetal26 commented 3 years ago

Steve version - 3.4.2.

I saw that there is an update to 3.4.4.

I will update (tomorrow) and check it out.

Did you manage to get the DOM up and running on your web server where the script resides? The DOM is responsible for parsing Steve's HTML pages where he interacts with forms.

mathief123 commented 3 years ago

Yes, DOM is installed right now on my webserver, but i still dont know what fails.

mathief123 commented 3 years ago

I tried using Steve 3.4.2 and it still wont work, can u try with SOAP and with ocpp1.5 to ckeck? image

DeltaVetal26 commented 3 years ago

Hello, @mathief123

I apologize. I promised five days ago and disappeared.

I have updated my Steve to 3.4.4.

All teams also work. (Got the status of the connector, stopped the transaction, booked the connector).

https://mydomain.xx/main.php?key=12345&ChargeBoxID=001&cmd=ReserveNow&ConnectorID=2&idTag=ABCDE&Expiry=2021-02-10+12:30 1

https://mydomain.xx/main.php?key=12345&ChargeBoxID=001&cmd=getConnectorState&ConnectorID=2

That's all I enter into the browser. I got "OK" for my booking and "Available" for the connector status.

The question: what do you get when you enter these commands?

I have JSON in the configuration since in my case the station works through it. Not SOAP. My version is OCPP 1.6

Do you only have OCPP SOAP on the station?

mathief123 commented 3 years ago

Yes, currently i have only ocpp SOAP 1.5 on the station.

When i ask for the command getConnectorState i still get the response i would expect, but when i try to start a reservation or a transaction it just tells me "ok", but neither the transaction nor the reservation starts.

DeltaVetal26 commented 3 years ago

If he sent "OK", then the script interacts with Steve.

You can send a log from Steve at the time of sending commands (in particular, starting a transaction or reserve)? Steve's panel has a LOG button.

mathief123 commented 3 years ago

Sorry that i took a long time writing. If i try to use the script and then i check the log file i get this: image Do u know how could i solve this?

DeltaVetal26 commented 3 years ago

Things are good.

I created a ticket for this error from Steve. https://github.com/RWTH-i5-IDSG/steve/issues/514

I tried to access a JSON station with a script configured for SOAP. The error is identical.

But in my case, it shouldn't have worked, because the station supports JSON.

Looking forward to hearing from Steve.

Is your station really running on SOAP, not JSON? Steve's panel (section "Number of Charge points") shows your station's protocol. If there is a J next to the version, this is JSON, if S is SOAP.

mathief123 commented 3 years ago

Yes, i checked with other charging stations and if i try to use the script with json 1.6 it works, but for some reason when i try it with SOAP 1.5 it doesnt image This is the version that im running that station.

mathief123 commented 3 years ago

Do i have to change something else other than this to make the script running on SOAP? image

DeltaVetal26 commented 3 years ago

Hello, @mathief123

If you haven't found a solution yet.

Updated the code. In the information section about your station, take its endpoint url (example on the screenshot).

1

In the configuration section of this script, I added the line "endpointURL" - insert the endpoint url of your station there.

Check the work. This should work.

The option of manually adding the station url to the config is a temporary solution.

If you have a task to manage several stations, this can be done.

mathief123 commented 3 years ago

Thank you so much.

DeltaVetal26 commented 3 years ago

If you check, please report the result ;)

Shivraj-Patil commented 3 years ago

Commands seem to be not working for me, I checked my PHP, apache2, and Dom as well.

DeltaVetal26 commented 3 years ago

Hello @Shivraj-Patil,

Please, specify the information: 1) OCPP: SOAP or JSON 2) Is it possible to query the status of the connector? (This command doesn't depend on SOAP or JSON, it just grabs the state from Steve panel). What does the script give out when sending commands? (OK?) 3) Is there any information in Steve's logs at the time the script is executed? (Logs can be seen in the "Logs" section of Steve home page).

This ticket was generated due to script problems in OCPP SOAP stations. The latest update should have fixed the bug (but not verified by the user, Because I don't have a SOAP station.).

Shivraj-Patil commented 3 years ago

Thanks for your reply @DeltaVetal26, I'm using OCPP: SOAP, I get nothing when I send a command for getting the status of the connectors, I'm using the following command for the same: curl http://localhost:8090/main.php?key=1234&ChargeBoxID=Ecc029&cmd=getConnectorState&ConnectorID=2

I'm getting nothing in Steve's log regarding this request.

DeltaVetal26 commented 3 years ago

As far as I understand, this script is on the same server with Steve and you use curl in the terminal of this server.

Add quotation 'marks' to the address after curl. Like this: curl 'http://localhost:8090/main.php?key=1234&ChargeBoxID=Ecc029&cmd=getConnectorState&ConnectorID=2' I checked this without them and curl didn't quite understand the request correctly.

1

If after that you will receive only StateNotExist, although the station is connected in Steve's panel, then most likely the script has no connection with Steve.

If Steve and this script are on the same server - Steve port (8080) can be closed with a local firewall. You can check this: curl http://localhost:8080

This can be solved either by opening this port in the firewall, or in the configuration of this script, in the '$steveServerAddres' parameter, instead of http://localhost:8080, specify the external IP through which your charging station communicates with Steve.

$steveServerAddres = 'http://localhost:8080'; change to $steveServerAddres = 'http://xx.xx.xxx.xx:8080';

teepisutt commented 2 years ago

Hi, I am also face similar connection problem.

curl http://xxx.xxx.xxx.xx/main.php?key=12345&ChargeBoxID=SN1005&cmd=getConnectorState&ConnectorID=2

But I'm getting nothing in return

image

At least it should return something right?

teepisutt commented 2 years ago

Right, What I have testing so far is that the script did not run any function.I try Echo something out here and there and find out that. The first function that not executed is within curlConnectionInit. Here is script and result

image

and Result return "1" but noting afterward.

image

probably something funny about my PHP installation? I missing something?

teepisutt commented 2 years ago

Right, I Sorted it out. It's appeared that

sudo apt-get install curl

is not enough, I also have to install

sudo apt-get install php7.3-curl

also for PHP 7.3

teepisutt commented 2 years ago

another stupid mistake I made is here in the setting.

image

There should be no "/" after port. I don't know why I putted it there though