@@ -323,6 +323,7 @@ def __init__(
323
323
self .active_transaction_id : int = 0
324
324
self .triggered_boot_notification = False
325
325
self .received_boot_notification = False
326
+ self .post_connect_success = False
326
327
self .tasks = None
327
328
self ._metrics = defaultdict (lambda : Metric (None , None ))
328
329
self ._metrics [cdet .identifier .value ].value = id
@@ -392,11 +393,7 @@ async def handle_data_transfer(call):
392
393
await self .get_supported_features ()
393
394
resp = await self .get_configuration (ckey .number_of_connectors .value )
394
395
self ._metrics [cdet .connectors .value ].value = resp
395
- if prof .REM in self ._attr_supported_features :
396
- if self .received_boot_notification is False :
397
- await self .trigger_boot_notification ()
398
- await self .trigger_status_notification ()
399
- await self .become_operative ()
396
+ await self .set_availability ()
400
397
await self .get_configuration (ckey .heartbeat_interval .value )
401
398
await self .configure (ckey .web_socket_ping_interval .value , "60" )
402
399
await self .configure (
@@ -452,6 +449,15 @@ async def handle_data_transfer(call):
452
449
handle_get_diagnostics ,
453
450
GDIAG_SERVICE_DATA_SCHEMA ,
454
451
)
452
+ self .post_connect_success = True
453
+ _LOGGER .debug (f"'{ self .id } ' post connection setup completed successfully" )
454
+
455
+ # nice to have, but not needed for integration to function
456
+ # and can cause issues with some chargers
457
+ if prof .REM in self ._attr_supported_features :
458
+ if self .received_boot_notification is False :
459
+ await self .trigger_boot_notification ()
460
+ await self .trigger_status_notification ()
455
461
except (NotImplementedError ) as e :
456
462
_LOGGER .error ("Configuration of the charger failed: %s" , e )
457
463
@@ -505,11 +511,6 @@ async def trigger_status_notification(self):
505
511
return_value = False
506
512
return return_value
507
513
508
- async def become_operative (self ):
509
- """Become operative."""
510
- resp = await self .set_availability ()
511
- return resp
512
-
513
514
async def clear_profile (self ):
514
515
"""Clear all charging profiles."""
515
516
req = call .ClearChargingProfilePayload ()
@@ -906,7 +907,12 @@ async def reconnect(self, connection: websockets.server.WebSocketServerProtocol)
906
907
self .status = STATE_OK
907
908
self ._connection = connection
908
909
self ._metrics [cstat .reconnects .value ].value += 1
909
- await self .run ([super ().start (), self .monitor_connection ()])
910
+ if self .post_connect_success is True :
911
+ await self .run ([super ().start (), self .monitor_connection ()])
912
+ else :
913
+ await self .run (
914
+ [super ().start (), self .post_connect (), self .monitor_connection ()]
915
+ )
910
916
911
917
async def async_update_device_info (self , boot_info : dict ):
912
918
"""Update device info asynchronuously."""
0 commit comments