DeltaVetal26 / SteVe-OCPP-HTTP-Client

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

How do I add new commands? #6

Open 204maker opened 2 years ago

204maker commented 2 years ago

I would like to change the Charging Profile on-the-fly on the charge point, may I ask how will I be able to add this command on the Php file?

DeltaVetal26 commented 2 years ago

Hi, @204maker

As I understand it, you want to use setChargingProfile?

In this script, there is no universal constructor for commands, since commands have different paths, required data. I'll try to watch it over the next few days.

DeltaVetal26 commented 2 years ago

Added 'SetChargingProfile'.

To avoid customizing the script, you can simply change the script code in several places.

  1. Replace $stevePathArray and its contents with this. (Added the path to the SetChargingProfile command at the bottom.)
    $stevePathArray = array(
    // Local cmd (not use)
    'signin' => '/' . $supervision . '/manager/signin',
    'getTransaction' => '/' . $supervision . '/manager/transactions',
    'getConnectorState' => '/' . $supervision . '/manager/home/connectorStatus',
    // OCPP cmd
    'ReserveNow' => '/' . $supervision . '/manager/operations/' . $ocppVersion . '/ReserveNow',
    'RemoteStartTransaction' => '/' . $supervision . '/manager/operations/' . $ocppVersion . '/RemoteStartTransaction',
    'RemoteStopTransaction' => '/' . $supervision . '/manager/operations/' . $ocppVersion . '/RemoteStopTransaction',
    'UnlockConnector' => '/' . $supervision . '/manager/operations/' . $ocppVersion . '/UnlockConnector',
    'DataTransfer' => '/' . $supervision . '/manager/operations/' . $ocppVersion . '/DataTransfer',
    'Reset' => '/' . $supervision . '/manager/operations/' . $ocppVersion . '/Reset',
    'SetChargingProfile' => '/' . $supervision . '/manager/operations/' . $ocppVersion . '/SetChargingProfile'
    );
  2. Find the function cmdInputSelector($getData), inside the switch case, at the very bottom, under the case 'Reset'.... break; add a new case.
      case 'SetChargingProfile':
         $allow = true; // Allow command?
         if($allow) {
           // Redirect to SetChargingProfile page
           $content = curlConnectTo($steveServerAddres, $stevePath);
           // Get token
           $token = getCSRFToken($content);
           // Prepare form
           $form = "chargePointSelectList=".$ocppProtocol.";".$getData['ChargeBoxID'].";".$endpointURL."&connectorId=".$getData['ConnectorID']."&chargingProfilePk=".$getData['ChargingProfileID']."&_csrf=".$token."";
           // Send form
           curl_setopt($curl, CURLOPT_POSTFIELDS, $form);
           curl_exec($curl);
           return 'Ok';
         }
        break;

Call:

curl "http://localhost:8080/main.php?key=1234&ChargeBoxID=Ecc029&cmd=SetChargingProfile&ChargingProfileID=1&ConnectorID=0"
204maker commented 2 years ago

Thank you so much! I was able to test it successfully today.

204maker commented 2 years ago

How about the MeterValues command? For example, Current.Export or Current.Import as measurand?

DeltaVetal26 commented 2 years ago

If I understand correctly, when charging, the station itself transmits the values ​​of Current.Import, Current.Export?

You just want to get the freshest data from the transaction status page?

1

Or a request via TriggerMessage? (I do not know if he gives there values ​​for the charging current)

2

204maker commented 2 years ago

The idea would be to use the Current.Import or Current.Export to act as a trigger/flag to indicate that charging have started/ended. Our SteVe server is currently down so I have not tried this yet.

Also, with the RemoteStartTransaction command, is it possible to call add a Charging Profile ID to it?

DeltaVetal26 commented 2 years ago

Hi @204maker,

Unfortunately, I will not have time to add this command, as I have to leave for a long time.

I really wanted to help you. Sorry.

Perhaps someone can help you with this, with knowledge of PHP, or try it yourself (the most important thing is to determine what data needs to be sent / received, this can be done through the web inspector in the browser and then you can use command templates).

yadu117 commented 2 years ago

Hai @DeltaVetal26 i implemented steve and api instences.

how to get the data from respective transcation id including start value, stop value, current voltage values, etc.