From 202105a11f98b1f5340ad8a1d5a5adbbe7ba4899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B6=B5=E6=9B=A6?= Date: Sat, 6 Jul 2024 16:04:07 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=BD=91=E9=A1=B5?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=8F=B0=E8=AE=BE=E7=BD=AE=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaomusic/xiaomusic.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/xiaomusic/xiaomusic.py b/xiaomusic/xiaomusic.py index 132e63a..c66b84c 100644 --- a/xiaomusic/xiaomusic.py +++ b/xiaomusic/xiaomusic.py @@ -1051,14 +1051,17 @@ class XiaoMusic: async def getalldevices(self, **kwargs): did_list = [] hardware_list = [] - hardware_data = await self.mina_service.device_list() - for h in hardware_data: - did = h.get("miotDID", "") - if did != "": - did_list.append(did) - hardware = h.get("hardware", "") - if h.get("hardware", "") != "": - hardware_list.append(hardware) + try: + hardware_data = await self.mina_service.device_list() + for h in hardware_data: + did = h.get("miotDID", "") + if did != "": + did_list.append(did) + hardware = h.get("hardware", "") + if h.get("hardware", "") != "": + hardware_list.append(hardware) + except Exception as e: + self.log.error(f"Execption {e}") alldevices = { "did_list": did_list, "hardware_list": hardware_list,