@@ -308,7 +308,6 @@ async def test_services(hass, socket_enabled):
308
308
cp .send_meter_err_phases (),
309
309
cp .send_meter_line_voltage (),
310
310
cp .send_meter_periodic_data (),
311
- cp .send_main_meter_clock_data (),
312
311
# add delay to allow meter data to be processed
313
312
cp .send_stop_transaction (2 ),
314
313
),
@@ -370,6 +369,9 @@ async def test_services(hass, socket_enabled):
370
369
pass
371
370
await ws .close ()
372
371
assert int (cs .get_metric ("test_cpid" , "Frequency" )) == int (50 )
372
+ assert float (cs .get_metric ("test_cpid" , "Energy.Active.Import.Register" )) == float (
373
+ 1101.452
374
+ )
373
375
374
376
await asyncio .sleep (1 )
375
377
@@ -410,6 +412,33 @@ async def test_services(hass, socket_enabled):
410
412
411
413
await asyncio .sleep (1 )
412
414
415
+ # test ocpp messages sent from charger that don't support errata 3.9 with meter values with kWh as energy unit
416
+ async with websockets .connect (
417
+ "ws://127.0.0.1:9000/CP_1_non_er_3.9" ,
418
+ subprotocols = ["ocpp1.6" ],
419
+ ) as ws :
420
+ # use a different id for debugging
421
+ cp = ChargePoint ("CP_1_non_errata_3.9" , ws )
422
+ try :
423
+ await asyncio .wait_for (
424
+ asyncio .gather (
425
+ cp .start (),
426
+ cp .send_start_transaction (0 ),
427
+ cp .send_meter_energy_kwh (),
428
+ cp .send_meter_clock_data (),
429
+ # add delay to allow meter data to be processed
430
+ cp .send_stop_transaction (2 ),
431
+ ),
432
+ timeout = 5 ,
433
+ )
434
+ except asyncio .TimeoutError :
435
+ pass
436
+ await ws .close ()
437
+
438
+ assert int (cs .get_metric ("test_cpid" , "Energy.Active.Import.Register" )) == int (1101 )
439
+ assert int (cs .get_metric ("test_cpid" , "Energy.Session" )) == int (11 )
440
+ assert cs .get_unit ("test_cpid" , "Energy.Active.Import.Register" ) == "kWh"
441
+
413
442
# test ocpp rejection messages sent from charger to cms
414
443
cs .charge_points ["test_cpid" ].received_boot_notification = False
415
444
cs .charge_points ["test_cpid" ].post_connect_success = False
@@ -971,6 +1000,31 @@ async def send_meter_err_phases(self):
971
1000
resp = await self .call (request )
972
1001
assert resp is not None
973
1002
1003
+ async def send_meter_energy_kwh (self ):
1004
+ """Send periodic energy meter value with kWh unit."""
1005
+ while self .active_transactionId == 0 :
1006
+ await asyncio .sleep (1 )
1007
+ request = call .MeterValuesPayload (
1008
+ connector_id = 1 ,
1009
+ transaction_id = self .active_transactionId ,
1010
+ meter_value = [
1011
+ {
1012
+ "timestamp" : "2021-06-21T16:15:09Z" ,
1013
+ "sampledValue" : [
1014
+ {
1015
+ "unit" : "kWh" ,
1016
+ "value" : "11" ,
1017
+ "context" : "Sample.Periodic" ,
1018
+ "format" : "Raw" ,
1019
+ "measurand" : "Energy.Active.Import.Register" ,
1020
+ },
1021
+ ],
1022
+ }
1023
+ ],
1024
+ )
1025
+ resp = await self .call (request )
1026
+ assert resp is not None
1027
+
974
1028
async def send_main_meter_clock_data (self ):
975
1029
"""Send periodic main meter value. Main meter values dont have transaction_id."""
976
1030
while self .active_transactionId == 0 :
0 commit comments