All Projects → mobilityhouse → Ocpp

mobilityhouse / Ocpp

Licence: mit
Python implementation of the Open Charge Point Protocol (OCPP).

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Ocpp

Vibora
Fast, asynchronous and elegant Python web framework.
Stars: ✭ 5,734 (+4414.96%)
Mutual labels:  framework, server, client
Pode
Pode is a Cross-Platform PowerShell web framework for creating REST APIs, Web Sites, and TCP/SMTP servers
Stars: ✭ 329 (+159.06%)
Mutual labels:  hacktoberfest, framework, server
Dragon
⚡A powerful HTTP router and URL matcher for building Deno web servers.
Stars: ✭ 56 (-55.91%)
Mutual labels:  hacktoberfest, framework, server
Mumble
Mumble is an open-source, low-latency, high quality voice chat software.
Stars: ✭ 4,418 (+3378.74%)
Mutual labels:  hacktoberfest, server, client
Novuscore
A modern take on WoW emulation
Stars: ✭ 88 (-30.71%)
Mutual labels:  framework, server, client
Meteor
Meteor, the JavaScript App Platform
Stars: ✭ 42,739 (+33552.76%)
Mutual labels:  hacktoberfest, framework
Gin
Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.
Stars: ✭ 53,971 (+42396.85%)
Mutual labels:  framework, server
Fuego
Fuego is a command line client for the firestore database (https://firebase.google.com/docs/firestore).
Stars: ✭ 110 (-13.39%)
Mutual labels:  hacktoberfest, client
Cyclejs
A functional and reactive JavaScript framework for predictable code
Stars: ✭ 9,996 (+7770.87%)
Mutual labels:  hacktoberfest, framework
Truffle
A tool for developing smart contracts. Crafted with the finest cacaos.
Stars: ✭ 11,909 (+9277.17%)
Mutual labels:  hacktoberfest, framework
Elgg
A social networking engine in PHP/MySQL
Stars: ✭ 1,510 (+1088.98%)
Mutual labels:  hacktoberfest, framework
Vertx Mqtt
Vert.x MQTT
Stars: ✭ 117 (-7.87%)
Mutual labels:  server, client
Scrapy
Scrapy, a fast high-level web crawling & scraping framework for Python.
Stars: ✭ 42,343 (+33240.94%)
Mutual labels:  hacktoberfest, framework
Micro
Micro is a distributed cloud operating system
Stars: ✭ 10,778 (+8386.61%)
Mutual labels:  framework, server
Open62541
Open source implementation of OPC UA (OPC Unified Architecture) aka IEC 62541 licensed under Mozilla Public License v2.0
Stars: ✭ 1,643 (+1193.7%)
Mutual labels:  server, client
Core
🚀 The Node.js Framework highly focused on developer ergonomics, stability and confidence
Stars: ✭ 11,697 (+9110.24%)
Mutual labels:  hacktoberfest, framework
Xtcp
A TCP Server Framework with graceful shutdown, custom protocol.
Stars: ✭ 116 (-8.66%)
Mutual labels:  framework, server
Socket
Non-blocking socket and TLS functionality for PHP based on Amp.
Stars: ✭ 122 (-3.94%)
Mutual labels:  server, client
Downlords Faf Client
Official client for Forged Alliance Forever
Stars: ✭ 121 (-4.72%)
Mutual labels:  hacktoberfest, client
Node Oidc Provider
OpenID Certified™ OAuth 2.0 Authorization Server implementation for Node.js
Stars: ✭ 2,018 (+1488.98%)
Mutual labels:  hacktoberfest, server

.. image:: https://circleci.com/gh/mobilityhouse/ocpp/tree/master.svg?style=svg :target: https://circleci.com/gh/mobilityhouse/ocpp/tree/master

.. image:: https://img.shields.io/pypi/pyversions/ocpp.svg :target: https://pypi.org/project/ocpp/

.. image:: https://img.shields.io/readthedocs/ocpp.svg :target: https://ocpp.readthedocs.io/en/latest/

OCPP

Python package implementing the JSON version of the Open Charge Point Protocol (OCPP). Currently OCPP 1.6 (errata v4), OCPP 2.0 and OCPP 2.0.1 (Final Version) are supported.

You can find the documentation on rtd_.

Installation

You can either the project install from Pypi:

.. code-block:: bash

$ pip install ocpp

Or clone the project and install it manually using:

.. code-block:: bash

$ pip install .

Quick start

Below you can find examples on how to create a simple OCPP 2.0 central system as well as an OCPP 2.0 charge point.

.. note::

To run these examples the dependency websockets_ is required! Install it by running:

.. code-block:: bash

  $ pip install websockets

Central system


The code snippet below creates a simple OCPP 2.0 central system which is able
to handle BootNotification calls. You can find a detailed explanation of the
code in the `Central System documentation_`.


.. code-block:: python

    import asyncio
    import logging
    import websockets
    from datetime import datetime

    from ocpp.routing import on
    from ocpp.v201 import ChargePoint as cp
    from ocpp.v201 import call_result

    logging.basicConfig(level=logging.INFO)


    class ChargePoint(cp):
        @on('BootNotification')
        async def on_boot_notification(self, charging_station, reason, **kwargs):
            return call_result.BootNotificationPayload(
                current_time=datetime.utcnow().isoformat(),
                interval=10,
                status='Accepted'
            )


    async def on_connect(websocket, path):
        """ For every new charge point that connects, create a ChargePoint
        instance and start listening for messages.
        """
        try:
            requested_protocols = websocket.request_headers[
                'Sec-WebSocket-Protocol']
        except KeyError:
            logging.info("Client hasn't requested any Subprotocol. "
                     "Closing Connection")
        if websocket.subprotocol:
            logging.info("Protocols Matched: %s", websocket.subprotocol)
        else:
            # In the websockets lib if no subprotocols are supported by the
            # client and the server, it proceeds without a subprotocol,
            # so we have to manually close the connection.
            logging.warning('Protocols Mismatched | Expected Subprotocols: %s,'
                            ' but client supports  %s | Closing connection',
                            websocket.available_subprotocols,
                            requested_protocols)
            return await websocket.close()

        charge_point_id = path.strip('/')
        cp = ChargePoint(charge_point_id, websocket)

        await cp.start()


    async def main():
        server = await websockets.serve(
            on_connect,
            '0.0.0.0',
            9000,
            subprotocols=['ocpp2.0.1']
        )
        logging.info("WebSocket Server Started")
        await server.wait_closed()

    if __name__ == '__main__':
        asyncio.run(main())

Charge point
~~~~~~~~~~~~

.. code-block:: python

    import asyncio
    import logging
    import websockets

    from ocpp.v201 import call
    from ocpp.v201 import ChargePoint as cp

    logging.basicConfig(level=logging.INFO)


    class ChargePoint(cp):

       async def send_boot_notification(self):
           request = call.BootNotificationPayload(
                   charging_station={
                       'model': 'Wallbox XYZ',
                       'vendor_name': 'anewone'
                   },
                   reason="PowerUp"
           )
           response = await self.call(request)

           if response.status == 'Accepted':
               print("Connected to central system.")


    async def main():
       async with websockets.connect(
           'ws://localhost:9000/CP_1',
            subprotocols=['ocpp2.0.1']
       ) as ws:

           cp = ChargePoint('CP_1', ws)

           await asyncio.gather(cp.start(), cp.send_boot_notification())


    if __name__ == '__main__':
       asyncio.run(main())

License
-------

Except from the documents in `docs/v16` and `docs/v201` everything is licensed under MIT_.
© `The Mobility House`_

The documents in `docs/v16` and `docs/v201` are licensed under Creative Commons
Attribution-NoDerivatives 4.0 International Public License.

.. _Central System documentation: https://ocpp.readthedocs.io/en/latest/central_system.html
.. _MIT: https://github.com/mobilityhouse/ocpp/blob/master/LICENSE
.. _rtd: https://ocpp.readthedocs.io/en/latest/index.html
.. _The Mobility House: https://www.mobilityhouse.com/int_en/
.. _websockets: https://pypi.org/project/websockets/
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].