Serie: ocpp
python
47 líneas
· Actualizado 2025-10-10
charge_point.py
ocpp/homework/ocpp_many/examples/v16/charge_point.py
import asyncio
import logging
try:
import websockets
except ModuleNotFoundError:
print("This example relies on the 'websockets' package.")
print("Please install it by running: ")
print()
print(" $ pip install websockets")
import sys
sys.exit(1)
from ocpp.v16 import ChargePoint as cp
from ocpp.v16 import call
from ocpp.v16.enums import RegistrationStatus
logging.basicConfig(level=logging.INFO)
class ChargePoint(cp):
async def send_boot_notification(self):
request = call.BootNotification(
charge_point_model="Optimus", charge_point_vendor="The Mobility House"
)
response = await self.call(request)
if response.status == RegistrationStatus.accepted:
print("Connected to central system.")
async def main():
async with websockets.connect(
"ws://localhost:9000/CP_1", subprotocols=["ocpp1.6"]
) as ws:
cp = ChargePoint("CP_1", ws)
await asyncio.gather(cp.start(), cp.send_boot_notification())
if __name__ == "__main__":
# asyncio.run() is used when running this example with Python >= 3.7v
asyncio.run(main())
Artículos relacionados
ocpp
python
Actualizado 2026-02-03
central_system.py
central_system.py — python source code from the ocpp learning materials (ocpp/homework/central_system.py).
Leer artículo →
ocpp
python
Actualizado 2026-02-03
charge_point.py
charge_point.py — python source code from the ocpp learning materials (ocpp/homework/ocpp/charge_point.py).
Leer artículo →
ocpp
python
Actualizado 2026-02-03
exceptions.py
exceptions.py — python source code from the ocpp learning materials (ocpp/homework/ocpp/exceptions.py).
Leer artículo →
ocpp
python
Actualizado 2026-02-03
messages.py
messages.py — python source code from the ocpp learning materials (ocpp/homework/ocpp/messages.py).
Leer artículo →
ocpp
python
Actualizado 2026-02-03
routing.py
routing.py — python source code from the ocpp learning materials (ocpp/homework/ocpp/routing.py).
Leer artículo →
ocpp
python
Actualizado 2026-02-03
__init__.py
__init__.py — python source code from the ocpp learning materials (ocpp/homework/ocpp/v16/__init__.py).
Leer artículo →