diff --git a/matter_server/server/device_controller.py b/matter_server/server/device_controller.py index 662c8c8a..7422a737 100644 --- a/matter_server/server/device_controller.py +++ b/matter_server/server/device_controller.py @@ -228,6 +228,7 @@ async def commission_with_code( # that are a bit unstable. # by retrying, we increase the chances of a successful commisssion while attempts <= MAX_COMMISSION_RETRIES: + attempts += 1 LOGGER.info( "Starting Matter commissioning with code using Node ID %s (attempt %s/%s).", node_id, @@ -247,7 +248,7 @@ async def commission_with_code( f"Commission with code failed for node {node_id}." ) await asyncio.sleep(5) - attempts += 1 + LOGGER.info("Matter commissioning of Node ID %s successful.", node_id) # perform full (first) interview of the device @@ -305,6 +306,7 @@ async def commission_on_network( # that are a bit unstable. # by retrying, we increase the chances of a successful commisssion while attempts <= MAX_COMMISSION_RETRIES: + attempts += 1 if ip_addr is None: # regular CommissionOnNetwork if no IP address provided LOGGER.info( @@ -339,7 +341,6 @@ async def commission_on_network( if not success and attempts >= MAX_COMMISSION_RETRIES: raise NodeCommissionFailed(f"Commissioning failed for node {node_id}.") await asyncio.sleep(5) - attempts += 1 LOGGER.info("Matter commissioning of Node ID %s successful.", node_id)