- # Define a handler for the BootNotification message.
- @on('BootNotification')
- async def on_boot_notification(self, charging_station, reason, **kwargs):
- logging.info("Received BootNotification")
- # Create and return a BootNotification response with the current time,
- # an interval of 10 seconds, and an accepted status.
- return call_result.BootNotification(
- current_time = datetime.now(timezone.utc).isoformat(),
- interval=10,
- status=RegistrationStatusType.accepted
- )
-
- # Define a handler for the GetBaseReport message.
- @on('GetBaseReport')
- async def on_get_base_report(self, request_id, report_base, **kwargs):
- try:
- logging.info(f"Received GetBaseReport request with RequestId: {request_id} and ReportBase: {report_base}")
-
- # Create a mock response for demonstration purposes, indicating the report is accepted.
- response = call_result.GetBaseReport(
- status=GenericDeviceModelStatusType.accepted
- )
-
- logging.info(f"Sending GetBaseReport response: {response}")
- return response
- except Exception as e:
- # Log any errors that occur while handling the GetBaseReport request.
- logging.error(f"Error handling GetBaseReport request: {e}", exc_info=True)
- # Return a rejected status in case of error.
- return call_result.GetBaseReport(
- status=GenericDeviceModelStatusType.rejected
- )
+ # Define a handler for the BootNotification message.
+ @on('BootNotification')
+ async def on_boot_notification(self, charging_station, reason, **kwargs):
+ logging.info("Received BootNotification")
+ # Create and return a BootNotification response with the current time,
+ # an interval of 10 seconds, and an accepted status.
+ return call_result.BootNotification(
+ current_time=datetime.now(timezone.utc).isoformat(),
+ interval=10,
+ status=RegistrationStatusType.accepted
+ )
+
+ # Define a handler for the GetBaseReport message.
+ @on('GetBaseReport')
+ async def on_get_base_report(self, request_id, report_base, **kwargs):
+ try:
+ logging.info(
+ f"Received GetBaseReport request with RequestId: {request_id} and ReportBase: {report_base}")
+
+ # Create a mock response for demonstration purposes, indicating the report is accepted.
+ response = call_result.GetBaseReport(
+ status=GenericDeviceModelStatusType.accepted
+ )
+
+ logging.info(f"Sending GetBaseReport response: {response}")
+ return response
+ except Exception as e:
+ # Log any errors that occur while handling the GetBaseReport request.
+ logging.error(f"Error handling GetBaseReport request: {e}", exc_info=True)
+ # Return a rejected status in case of error.
+ return call_result.GetBaseReport(
+ status=GenericDeviceModelStatusType.rejected
+ )
+