From 13e2b36a0c2603777402aa49f76af49b9e60d75a Mon Sep 17 00:00:00 2001 From: impressionyang Date: Thu, 16 Apr 2026 15:35:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=81=E8=AE=B8=E5=9C=A8=20scanning?= =?UTF-8?q?=20=E7=8A=B6=E6=80=81=E9=87=8D=E6=96=B0=E5=BC=80=E5=A7=8B?= =?UTF-8?q?=E6=89=AB=E6=8F=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复重复点击扫描按钮时的错误,现在会重置扫描状态而不是报错 --- custom_components/sigmesh_gateway/provisioning.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/custom_components/sigmesh_gateway/provisioning.py b/custom_components/sigmesh_gateway/provisioning.py index 0804cf9..056cce4 100644 --- a/custom_components/sigmesh_gateway/provisioning.py +++ b/custom_components/sigmesh_gateway/provisioning.py @@ -130,6 +130,13 @@ class ProvisioningManager: async def start_scanning(self) -> None: """开始扫描设备.""" + # 如果已经在扫描中,先重置状态(允许用户重新启动扫描) + if self._state == ProvState.SCANNING: + _LOGGER.info("扫描已在进行中,重置扫描状态...") + self._devices = {} + self._scan_result = [] + return + if self._state not in [ProvState.IDLE, ProvState.PROV_COMPLETED, ProvState.PROV_FAILED]: _LOGGER.warning("无法开始扫描,当前状态:%s", self._state.value) return