Add ability to reset chargepoints
This commit is contained in:
parent
7780f247fb
commit
38d3064652
3 changed files with 35 additions and 2 deletions
|
@ -5,9 +5,19 @@ from fastapi import APIRouter, HTTPException, Security
|
|||
from fastapi.params import Depends
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ocpp.v201.call import ResetPayload
|
||||
|
||||
from app.database import get_db
|
||||
from app.ocpp_proto import chargepoint_manager
|
||||
from app.schemas.chargepoint import ChargePoint, ChargePointCreate, ChargePointUpdate, ChargePointPassword, ChargePointConnectionInfo
|
||||
from app.schemas.chargepoint import (
|
||||
ChargePoint,
|
||||
ChargePointCreate,
|
||||
ChargePointUpdate,
|
||||
ChargePointPassword,
|
||||
ChargePointConnectionInfo,
|
||||
ChargePointResetRequest,
|
||||
ChargePointResetResponse
|
||||
)
|
||||
from app.models.chargepoint import ChargePoint as DbChargePoint
|
||||
from app.security import get_api_key
|
||||
|
||||
|
@ -112,3 +122,17 @@ async def get_chargepoint_status(
|
|||
return ChargePointConnectionInfo(
|
||||
connected=chargepoint_manager.is_connected(chargepoint_id)
|
||||
)
|
||||
|
||||
@router.post(path="/{chargepoint_id}/reset", response_model=ChargePointResetResponse)
|
||||
async def reset_chargepoint(
|
||||
chargepoint_id: UUID,
|
||||
reset_request: ChargePointResetRequest,
|
||||
api_key: str = Security(get_api_key)
|
||||
):
|
||||
if chargepoint_manager.is_connected(chargepoint_id) == False:
|
||||
raise HTTPException(status_code=423, detail="Chargepoint not connected")
|
||||
response = await chargepoint_manager.call(
|
||||
chargepoint_id,
|
||||
payload=ResetPayload(type=reset_request.type, evse_id=reset_request.evse_id)
|
||||
)
|
||||
return ChargePointResetResponse(status=response.status)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue