@@ -165,7 +165,8 @@ def _apply_status_notification(
165
165
):
166
166
"""Update per connector and evse aggregated."""
167
167
if evse_id > len (self ._connector_status ):
168
- self ._connector_status += [[]] * (evse_id - len (self ._connector_status ))
168
+ needed = evse_id - len (self ._connector_status )
169
+ self ._connector_status .extend ([[] for _ in range (needed )])
169
170
if connector_id > len (self ._connector_status [evse_id - 1 ]):
170
171
self ._connector_status [evse_id - 1 ] += [None ] * (
171
172
connector_id - len (self ._connector_status [evse_id - 1 ])
@@ -346,9 +347,18 @@ async def set_charge_rate(
346
347
conn_id : int = 0 ,
347
348
profile : dict | None = None ,
348
349
):
349
- """Set a charging profile with defined limit (OCPP 2.x)."""
350
+ """Set a charging profile with defined limit (OCPP 2.x).
351
+
352
+ - conn_id=0 (default) targets the Charging Station (evse_id=0).
353
+ - conn_id>0 targets the specific EVSE corresponding to the global connector index.
354
+ """
355
+
356
+ evse_target = 0
357
+ if conn_id and conn_id > 0 :
358
+ with contextlib .suppress (Exception ):
359
+ evse_target , _ = self ._global_to_pair (int (conn_id ))
350
360
if profile is not None :
351
- req = call .SetChargingProfile (0 , profile )
361
+ req = call .SetChargingProfile (evse_target , profile )
352
362
resp : call_result .SetChargingProfile = await self .call (req )
353
363
if resp .status != ChargingProfileStatusEnumType .accepted :
354
364
raise HomeAssistantError (
@@ -394,7 +404,9 @@ async def set_charge_rate(
394
404
"charging_schedule" : [schedule ],
395
405
}
396
406
397
- req : call .SetChargingProfile = call .SetChargingProfile (0 , charging_profile )
407
+ req : call .SetChargingProfile = call .SetChargingProfile (
408
+ evse_target , charging_profile
409
+ )
398
410
resp : call_result .SetChargingProfile = await self .call (req )
399
411
if resp .status != ChargingProfileStatusEnumType .accepted :
400
412
raise HomeAssistantError (
@@ -859,6 +871,7 @@ def on_transaction_event(
859
871
if event_type == TransactionEventEnumType .ended .value :
860
872
self ._metrics [(global_idx , csess .transaction_id .value )].value = ""
861
873
self ._metrics [(global_idx , cstat .id_tag .value )].value = ""
874
+ self ._tx_start_time .pop (global_idx , None )
862
875
863
876
if not offline :
864
877
self .hass .async_create_task (self .update (self .settings .cpid ))
0 commit comments