javaocpp

How to get OCPP charging station parameters


I'm new to OCPP (Open Charge Point Protocol) and I have significant difficulties to start diving in subject, any help will be highly appropriated.

I need to write a kind of monitoring tool which should connect to charging station via OCPP and get a set of parameters from it. For example, max charging power, current charging percentage etc. I use online OCPP charging station emulator (https://cs.ocpp-css.com/ocpp (login: demo, password: demo), https://github.com/apostoldevel/ocpp-cs) to test my development.

First of all, I can not find the actual Java library to work with OCPP. https://github.com/ChargeTimeEU/Java-OCA-OCPP looks abandoned. I tried it, but I was not able even to connect to the emulator. After establishing the connection I immediately get a disconnect.
May be you can suggest me a working Java library.

I tried to use Kotlin library https://github.com/IZIVIA/ocpp-toolkit. I was able to connect to the station and pass through the authorization. But I don't know what to do next. How to get parameters?

Here is my code:

private static void testOcppConnection() throws ConnectException {
    final var chargePointId = "EFACECQCTEST";
    ChargePointOperations connection = ApiFactory.Companion.ocpp16ConnectionToCSMS(chargePointId,
            "ws://ws.ocpp-css.com/ocpp",
            TransportEnum.WEBSOCKET,
            null,
            null,
            Collections.emptyList(),
            new OcppCallbacks());

    connection.connect();
    final var idTag = "demo";
    var authResponse = connection.authorize(new RequestMetadata(chargePointId, null), new AuthorizeReq(idTag)).getResponse();
    if (authResponse.getIdTagInfo().getStatus() ==  AuthorizationStatus.Accepted) {
        log.info("Auth accepted");
        var transactionResponse = connection.startTransaction(new RequestMetadata(chargePointId, null), new StartTransactionReq(1, idTag, 0,
                Instant.Companion.fromEpochSeconds(java.time.Instant.now().getEpochSecond(), 0), null)).getResponse();
        var transactionId = transactionResponse.getTransactionId();
        log.info("Start transaction: {}", transactionId);
        log.info("{}", transactionResponse.getIdTagInfo());
        //What to do next???
    } else {
        log.info("Auth rejected");
    }
}

Solution

  • Initially, I misunderstood the communication pattern and confused CSMS and CS roles. I thought that CS is a server and CSMS is a client. But actually, the things are exactly the opposite. To get data from the CS one should implement CSMS as a server and setup CS to connect with this CSMS. Hope that it will be useful for someone.