Code Monkey home page Code Monkey logo

cpd-ocpp's Introduction

Open Charge Point Protocol 1.6

Build Status

This repository contain abstraction layer for easy work with OCPP and validate input and output requests. Currently implemented only version 1.6 JSON. Whereas OCPP2.0 will support only JSON have no plans to implement SOAP.

Article

https://www.eliftech.com/blog/48-a-diy-charging-point-for-an-electric-car-perspective-protocol-and-prototype

Installation

npm install --save ocpp-eliftech

Overview

Open Charge Point Protocol (OCPP, http://www.openchargealliance.org/) is a communication protocol between multiple charging stations ("charge points") and a single management software ("central system").

Usage

Server

import { OCPPServer, OCPPCommands } from 'ocpp-eliftech';

const server = new OCPPServer();

server.listen(9220);

server.onRequest = async function(command) {
    // Handle different commands
    if (command instanceof OCPPCommands.BootNotification) {
        return {
            status: 'Accepted',
            currentTime: new Date().toISOString(),
            interval: 60
        };
    }
}

Client

import { OCPPClient, OCPPCommands } from 'ocpp-eliftech';

const client = new OCPPClient({
    serverUrl: 'http://localhost:9220/webServices/ocpp/CP1111'
});

await client.connect();

const boot = new OCPPCommands.BootNotification({
    chargePointVendor: 'BrandX',
    chargeBoxSerialNumber: 'AQ1234VB5678',
    chargePointSerialNumber: '123',
    chargePointModel: '12'
});

let answer = await client.send(boot);
console.info(answer);

P.S.

If you need professional support with your IOT projects contact us http://www.eliftech.com/.

cpd-ocpp's People

Contributors

esvit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cpd-ocpp's Issues

InternalError: Connectors not defined

I am having issues to get the StatusNotification payload. I wrote a simple charging point simulator and I always get an internal error when trying to send the StatusNotification.

[ 4, 0, "InternalError", "connectors is not defined", null]

My simulator is self-written (html using native in-browser WebSockets), but I get the same error using the chargingPoint.js in the examples folder of this repo.

[PI branch] Unexpected token import

Hi,

I tried to deploy your (awesome) proof of concept on a Pi 3 with raspian but when I run npm start I get a problem with the js import method.

Please let me know how to solve this issue.

Many thanks

SyntaxError: Unexpected token import
at new Script (vm.js:51:7)
at createScript (vm.js:136:10)
at Object.runInThisContext (vm.js:197:10)
at Module._compile (internal/modules/cjs/loader.js:618:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:695:10)
at startup (internal/bootstrap/node.js:201:19)

update npm version

your package on NPM is out dated compared to the files here. Could you please push the update there?

SetChargingProfile schema validation fails due to floating point arithmethic

the limit value is defined via multipleOf: 0.1 which will fail in many cases. When I set value of 0.1 everything is fine, else I will get an error, e.g. if I set 2000

Invalid value "[object Object]" for field csChargingProfiles

I think for validation purposes, the multipleOf requirement should be removed or the validator needs to be adjusted, else it makes it impossible to use the limit property.

the const values in commands not exported by the ocpp-eliftech package

the ocpp-eliftech package at https://www.npmjs.com/package/ocpp-eliftech seems not export the consts defined in each command.

for example in the command StatusNotification, the consts like these are not accessible from codebase that is using this package.

export const STATUS_SUSPENDEDEV = 'SuspendedEV';
export const STATUS_FINISHING = 'Finishing';
export const STATUS_RESERVED = 'Reserved';
export const STATUS_UNAVAILABLE = 'Unavailable';
export const STATUS_FAULTED = 'Faulted';

SyntaxError: The requested module 'ocpp-eliftech' does not provide an export named 'OCPPServer'

Hi,

I have installed the OCPP module using "npm install --save ocpp-eliftech" and use the OCPP Server example in our index.js file as shown below :

import { OCPPServer, OCPPCommands } from 'ocpp-eliftech';
const server = new OCPPServer();
server.listen(9220);
server.onRequest = async function(command) {
// Handle different commands
if (command instanceof OCPPCommands.BootNotification) {
return {
status: 'Accepted',
currentTime: new Date().toISOString(),
interval: 60
};
}
}

When we run npm start then got error "SyntaxError: The requested module 'ocpp-eliftech' does not provide an export named 'OCPPServer'"

Please let me know how to solve this issue.

net::ERR_INVALID_CHUNKED_ENCODING

When I toggle connectors on the chargepoint example, I get this in the console.

(index):1 GET http://localhost:9220/status net::ERR_INVALID_CHUNKED_ENCODING
Any idea why?

AssertionError [ERR_ASSERTION]: you must provide a joi schema

I am writing a simple chargePoint that sends a websocket to the centralSystem. I took the code from the examples and this is where I am facing issues with:

    const boot = new OCPPCommands.BootNotification({
      chargePointVendor: 'BrandX',
      chargeBoxSerialNumber: 'SR' + Math.round(Math.random() * 100000),
      chargePointSerialNumber: '123',
      chargePointModel: '12'
    });

    let answer = await client.send(boot);

OCPPCommands.BootNotification tries to validate the payload with applyPropertiesValidators and it failed to validate with Joi, specifically on this line:

// node_modules/ocpp-eliftech/node_modules/joi/lib/index.js
Hoek.assert(schema && schema instanceof Any, 'you must provide a joi schema');

This is what schema looks like before it fails the schema instanceof Any validation:

{ isJoi: true,
  _currentJoi:
   { isJoi: true,
     _currentJoi:
      { isJoi: true,
        _currentJoi: [Circular],
        _type: 'any',
        _settings: null,
        _baseType: undefined,
        _valids: [InternalSet],
        _invalids: [InternalSet],
        _tests: [],
        _refs: [],
        _flags: {},
        _description: null,
        _unit: null,
        _notes: [],
        _tags: [],
        _examples: [],
        _meta: [],
        _inner: {},
        any: [Function],
        alt: [Function],
        alternatives: [Function],
        array: [Function],
        bool: [Function],
        boolean: [Function],
        binary: [Function],
        date: [Function],
        func: [Function],
        number: [Function],
        object: [Function],
        string: [Function],
        symbol: [Function],
        ref: [Function],
        isRef: [Function],
        validate: [Function],
        describe: [Function],
        compile: [Function],
        assert: [Function],
        attempt: [Function],
        reach: [Function],
        lazy: [Function],
        defaults: [Function],
        extend: [Function],
        extensionSchema: [Object],
        extensionsSchema: [Object],
        version: '13.7.0' },
     _type: 'any',
     _settings: null,
     _baseType: undefined,
     _valids: InternalSet { _set: Set {}, _hasRef: false },
     _invalids: InternalSet { _set: Set {}, _hasRef: false },
     _tests: [],
     _refs: [],
     _flags: {},
     _description: null,
     _unit: null,
     _notes: [],
     _tags: [],
     _examples: [],
     _meta: [],
     _inner: {},
     any: [Function],
     alt: [Function],
     alternatives: [Function],
     array: [Function],
     bool: [Function],
     boolean: [Function],
     binary: [Function],
     date: [Function],
     func: [Function],
     number: [Function],
     object: [Function],
     string: [Function],
     symbol: [Function],
     ref: [Function],
     isRef: [Function],
     validate: [Function],
     describe: [Function],
     compile: [Function],
     assert: [Function],
     attempt: [Function],
     reach: [Function],
     lazy: [Function],
     defaults: [Function],
     extend: [Function],
     extensionSchema:
      { isJoi: true,
        _currentJoi: [Object],
        _type: 'object',
        _settings: [Object],
        _baseType: undefined,
        _valids: [InternalSet],
        _invalids: [InternalSet],
        _tests: [],
        _refs: [],
        _flags: {},
        _description: null,
        _unit: null,
        _notes: [],
        _tags: [],
        _examples: [],
        _meta: [],
        _inner: [Object] },
     extensionsSchema:
      { isJoi: true,
        _currentJoi: [Object],
        _type: 'array',
        _settings: [Object],
        _baseType: undefined,
        _valids: [InternalSet],
        _invalids: [InternalSet],
        _tests: [],
        _refs: [],
        _flags: [Object],
        _description: null,
        _unit: null,
        _notes: [],
        _tags: [],
        _examples: [],
        _meta: [],
        _inner: [Object] },
     version: '13.7.0' },
  _type: 'object',
  _settings: { convert: true },
  _baseType: undefined,
  _valids: InternalSet { _set: Set {}, _hasRef: false },
  _invalids: InternalSet { _set: Set {}, _hasRef: false },
  _tests: [],
  _refs: [],
  _flags: { label: 'BootNotificationRequest' },
  _description: null,
  _unit: null,
  _notes: [],
  _tags: [],
  _examples: [],
  _meta: [],
  _inner:
   { children:
      [ [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object] ],
     renames: [],
     dependencies: [],
     patterns: [] } }

I am not sure if this is a dependency issue or there is something missing on my side. Any help would be appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.