test(ocpp-server): add heartbeart command handler
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 11 Jun 2024 18:40:05 +0000 (20:40 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 11 Jun 2024 18:40:05 +0000 (20:40 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
tests/ocpp-server/server.py

index 308994edc69096a618213eb521a294119ef7cbd5..e507d4f49b89e73b8087f4d2ecfe3c84fa08e379 100644 (file)
@@ -31,10 +31,15 @@ class ChargePoint(ocpp.v201.ChargePoint):
         # an interval of 10 seconds, and an accepted status.
         return ocpp.v201.call_result.BootNotification(
             current_time=datetime.now(timezone.utc).isoformat(),
-            interval=10,
+            interval=60,
             status=RegistrationStatusType.accepted
         )
 
+    @on(Action.Heartbeat)
+    async def on_heartbeat(self, charging_station, **kwargs):
+        logging.info("Received Heartbeat")
+        return ocpp.v201.call_result.Heartbeat(current_time=datetime.now(timezone.utc).isoformat())
+
     # Request handlers to emit OCPP messages.
     async def send_clear_cache(self):
         request = ocpp.v201.call.ClearCache()