Code Monkey home page Code Monkey logo

ocpp-mqtt's Introduction

Simple implementation of the OCPP - MQTT bridge

Enables to send mqtt commands (and receive mqtt messages as responses and status updates, though not implemented right now). I use this bridge for managing charge station from OpenHAB.

Send mqtt commands to /ocpp/cmd

Poetry is used to manage dependencies.

To start program: poetry run python ./central_system.py

For automation needs I implemented these commands:

  • start (start charging)
  • stop
  • trigger
  • profile [arg] ( set charging profile, in my implementation argument is max current in Amps, message e.g. profile 8)
  • configuration (read local CP configuration)
  • change_configuration (set local CP configuration item)
  • exit (stop bridge)

Note: to provide secrets, you need to place .env file in the directory: MQTT_USERNAME=xxx MQTT_PASSWORD=xxx LISTEN_ADDR=0.0.0.0 TAG_ID=xxx

Note: check specific dependencies if implemented without poetry, as latest versions of some packages break functionalities.

Note: Every charge station may have peculiarities of OCPP implementation. The code is tested and fully works with:

Dependencies and Contributions

OCPP implementation: https://github.com/mobilityhouse/ocpp

ocpp-mqtt's People

Contributors

rzylius avatar

Stargazers

Kirill Rudenko avatar

Watchers

 avatar

ocpp-mqtt's Issues

Does this code works for anyone ?

I'm trying to build something from this code and I get errors about missing arguments in the lines self.call(payload) like this :

    async def set_charging_profile(self, amps, **kwargs):
        print('set_charging_profile')
        return await self.call(call.SetChargingProfilePayload(
            connector_id=1,
            cs_charging_profiles={
                'charging_profile_id': int(amps),
                'stack_level': 0,
                'charging_profile_purpose': ChargingProfilePurposeType.tx_profile,
                'charging_profile_kind': ChargingProfileKindType.absolute,
                'charging_schedule': {
                    'charging_rate_unit': ChargingRateUnitType.amps,
                    'charging_schedule_period': [{
                        'start_period': 0,
                        'limit': float(amps),
                    }]
                },
                'transaction_id': 112
            }
        ))

errors are :

{'cmd': 'availability', 'values': [{'state': 'Operative'}]}
Changing availability to Operative
INFO:ocpp:EVB-P20261797: send [2,"0a475978-ffdf-4b6d-a30a-8cc620defb01","ChangeAvailability",{"connectorId":1,"type":"Inoperative"}]
INFO:ocpp:EVB-P20261797: receive message [4,"0a475978-ffdf-4b6d-a30a-8cc620defb01"]
ERROR:ocpp:Unable to parse message: '[4,"0a475978-ffdf-4b6d-a30a-8cc620defb01"]', it doesn't seem to be valid OCPP: ProtocolError: Payload for Action is incomplete, {'cause': 'Message is missing elements.'}
Traceback (most recent call last):
  File "/home/pagag186/ocpp/ocpp-mqtt-gateway/venv/lib/python3.10/site-packages/ocpp/messages.py", line 103, in unpack
    return cls(*msg[1:])
TypeError: CallError.__init__() missing 2 required positional arguments: 'error_code' and 'error_description'

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.