From ebae56f907b6e446408d4739d94e825f6c25d496 Mon Sep 17 00:00:00 2001 From: Alexey Khit Date: Wed, 3 May 2023 17:45:20 +0300 Subject: [PATCH] Update flash zigbee chip procedure --- .../xiaomi_gateway3/core/ezsp.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/custom_components/xiaomi_gateway3/core/ezsp.py b/custom_components/xiaomi_gateway3/core/ezsp.py index 89514235..b259238c 100644 --- a/custom_components/xiaomi_gateway3/core/ezsp.py +++ b/custom_components/xiaomi_gateway3/core/ezsp.py @@ -44,24 +44,22 @@ async def update_zigbee_firmware(hass: HomeAssistant, host: str, custom: bool): await sh.exec( "zigbee_inter_bootloader.sh 1; zigbee_reset.sh 0; zigbee_reset.sh 1; " - "killall openmiio_agent; /data/openmiio_agent --zigbee.tcp=8889 &" + "killall openmiio_agent" ) + await sh.exec("/data/openmiio_agent --zigbee.tcp=8889 &") + await asyncio.sleep(2) - await asyncio.sleep(1) - + # some users have broken firmware, so unknown firmware also OK cur_fw = await read_firmware(host) - if not cur_fw: - _LOGGER.error(f"{host} [FWUP] Can't get current firmware") - return False - - if cur_fw.startswith(tar_fw): + if cur_fw and cur_fw.startswith(tar_fw): _LOGGER.debug(f"{host} [FWUP] No need to update") return True await sh.exec( "zigbee_inter_bootloader.sh 0; zigbee_reset.sh 0; zigbee_reset.sh 1; " - "killall openmiio_agent; /data/openmiio_agent --zigbee.tcp=8889 --zigbee.baud=115200 &" + "killall openmiio_agent" ) + await sh.exec("/data/openmiio_agent --zigbee.tcp=8889 --zigbee.baud=115200 &") await async_process_requirements(hass, DOMAIN, ["xmodem==0.4.6"]) @@ -79,8 +77,10 @@ async def update_zigbee_firmware(hass: HomeAssistant, host: str, custom: bool): await sh.exec( "zigbee_inter_bootloader.sh 1; zigbee_reset.sh 0; zigbee_reset.sh 1; " - "killall openmiio_agent; /data/openmiio_agent --zigbee.tcp=8889 &" + "killall openmiio_agent" ) + await sh.exec("/data/openmiio_agent --zigbee.tcp=8889 &") + await asyncio.sleep(2) cur_fw = await read_firmware(host) return cur_fw and cur_fw.startswith(tar_fw)