Skip to content

Python implementation of the Open Charge Point Interface (OCPI)

License

Notifications You must be signed in to change notification settings

TECHS-Technological-Solutions/ocpi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

https://img.shields.io/pypi/v/py-ocpi.svg?style=flat https://pepy.tech/badge/py-ocpi/month https://github.com/TECHS-Technological-Solutions/ocpi/actions/workflows/pypi.yaml/badge.svg?style=svg

Introduction

This Library is a Python implementation of the Open Charge Point Interface (OCPI)

Getting Started

Installation

install Py-OCPI like this:

pip install py-ocpi

How Does it Work?

Modules that communicate with central system will use crud for retrieving required data. the data that is retrieved from central system may not be compatible with OCPI protocol. So the data will be passed to adapter to make it compatible with schemas defined by OCPI. User only needs to modify crud and adapter based on central system architecture.

Example

ocpi/examples/v_2_2_1.py

Lines 1 to 205 in 830dba5

from uuid import uuid4
from py_ocpi import get_application, enums
from py_ocpi.versions.enums import VersionNumber
from py_ocpi.locations.v_2_2_1.schemas import Location
LOCATIONS = [
{
'country_code': 'us',
'party_id': 'AAA',
'id': str(uuid4()),
'publish': True,
'publish_allowed_to': [
{
'uid': str(uuid4()),
'type': 'APP_USER',
'visual_number': '1',
'issuer': 'issuer',
'group_id': 'group_id',
},
],
'name': 'name',
'address': 'address',
'city': 'city',
'postal_code': '111111',
'state': 'state',
'country': 'USA',
'coordinates': {
'latitude': 'latitude',
'longitude': 'longitude',
},
'related_locations': [
{
'latitude': 'latitude',
'longitude': 'longitude',
'name': {
'language': 'en',
'text': 'name'
}
},
],
'parking_type': 'ON_STREET',
'evses': [
{
'uid': str(uuid4()),
'evse_id': str(uuid4()),
'status': 'AVAILABLE',
'status_schedule': {
'period_begin': '2022-01-01T00:00:00+00:00',
'period_end': '2022-01-01T00:00:00+00:00',
'status': 'AVAILABLE'
},
'capabilities': [
'CREDIT_CARD_PAYABLE',
],
'connectors': [
{
'id': str(uuid4()),
'standard': 'DOMESTIC_A',
'format': 'SOCKET',
'power_type': 'DC',
'max_voltage': 100,
'max_amperage': 100,
'max_electric_power': 100,
'tariff_ids': [str(uuid4()),],
'terms_and_conditions': 'https://www.example.com',
'last_updated': '2022-01-01T00:00:00+00:00',
}
],
'floor_level': '3',
'coordinates': {
'latitude': 'latitude',
'longitude': 'longitude',
},
'physical_reference': 'pr',
'directions': [
{
'language': 'en',
'text': 'directions'
},
],
'parking_restrictions': ['EV_ONLY',],
'images': [
{
'url': 'https://www.example.com',
'thumbnail': 'https://www.example.com',
'category': 'CHARGER',
'type': 'type',
'width': 10,
'height': 10
},
],
'last_updated': '2022-01-01T00:00:00+00:00'
}
],
'directions': [
{
'language': 'en',
'text': 'directions'
},
],
'operator': {
'name': 'name',
'website': 'https://www.example.com',
'logo': {
'url': 'https://www.example.com',
'thumbnail': 'https://www.example.com',
'category': 'CHARGER',
'type': 'type',
'width': 10,
'height': 10
}
},
'suboperator': {
'name': 'name',
'website': 'https://www.example.com',
'logo': {
'url': 'https://www.example.com',
'thumbnail': 'https://www.example.com',
'category': 'CHARGER',
'type': 'type',
'width': 10,
'height': 10
}
},
'owner': {
'name': 'name',
'website': 'https://www.example.com',
'logo': {
'url': 'https://www.example.com',
'thumbnail': 'https://www.example.com',
'category': 'CHARGER',
'type': 'type',
'width': 10,
'height': 10
}
},
'facilities': ['MALL'],
'time_zone': 'UTC+2',
'opening_times': {
'twentyfourseven': True,
'regular_hours': [
{
'weekday': 1,
'period_begin': '8:00',
'period_end': '22:00',
},
{
'weekday': 2,
'period_begin': '8:00',
'period_end': '22:00',
},
],
'exceptional_openings': [
{
'period_begin': '2022-01-01T00:00:00+00:00',
'period_end': '2022-01-02T00:00:00+00:00',
},
],
'exceptional_closings': [],
},
'charging_when_closed': False,
'images': [
{
'url': 'https://www.example.com',
'thumbnail': 'https://www.example.com',
'category': 'CHARGER',
'type': 'type',
'width': 10,
'height': 10
},
],
'energy_mix': {
'is_green_energy': True,
'energy_sources': [
{
'source': 'SOLAR',
'percentage': 100
},
],
'supplier_name': 'supplier_name',
'energy_product_name': 'energy_product_name'
},
'last_updated': '2022-01-02 00:00:00+00:00',
}
]
class CRUD:
@classmethod
async def get(cls, module: enums.ModuleID, id):
return LOCATIONS[0]
@classmethod
async def list(cls, module: enums.ModuleID, filters: dict) -> list:
return LOCATIONS, 1, True
class Adapter:
@classmethod
def location_adapter(cls, data) -> Location:
return Location(**data)
app = get_application(VersionNumber.v_2_2_1, [enums.RoleEnum.CPO], CRUD, Adapter)

Documents

Check the Documentation

License

This project is licensed under the terms of the MIT license.

About

Python implementation of the Open Charge Point Interface (OCPI)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •