{"id":14985248,"url":"https://github.com/niceboygithub/aqaragateway","last_synced_at":"2025-05-15T10:03:11.527Z","repository":{"id":37610948,"uuid":"331597657","full_name":"niceboygithub/AqaraGateway","owner":"niceboygithub","description":"Aqara Gateway/Hub integration for Home Assistant","archived":false,"fork":false,"pushed_at":"2025-05-02T06:27:30.000Z","size":461,"stargazers_count":579,"open_issues_count":87,"forks_count":68,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-05-15T10:02:53.332Z","etag":null,"topics":["aqara","home-assistant","homeassistant","xiaomi","zigbee","zigbee-gateway"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/niceboygithub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-01-21T10:49:49.000Z","updated_at":"2025-05-13T15:40:51.000Z","dependencies_parsed_at":"2023-12-29T07:23:23.907Z","dependency_job_id":"450a9408-979c-4cbe-a295-c86926c1d258","html_url":"https://github.com/niceboygithub/AqaraGateway","commit_stats":{"total_commits":256,"total_committers":24,"mean_commits":"10.666666666666666","dds":0.2890625,"last_synced_commit":"2986a488adceb027d615f171e16fa9ea66eb1d99"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niceboygithub%2FAqaraGateway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niceboygithub%2FAqaraGateway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niceboygithub%2FAqaraGateway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niceboygithub%2FAqaraGateway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/niceboygithub","download_url":"https://codeload.github.com/niceboygithub/AqaraGateway/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254319716,"owners_count":22051072,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aqara","home-assistant","homeassistant","xiaomi","zigbee","zigbee-gateway"],"created_at":"2024-09-24T14:10:34.347Z","updated_at":"2025-05-15T10:03:04.152Z","avatar_url":"https://github.com/niceboygithub.png","language":"Python","funding_links":["https://www.buymeacoffee.com/niceboygithub"],"categories":[],"sub_categories":[],"readme":"\n\u003ca href=\"https://www.buymeacoffee.com/niceboygithub\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/default-orange.png\" alt=\"Buy Me A Coffee\" height=\"41\" width=\"174\"\u003e\u003c/a\u003e\n\n# Aqara Gateway/Hub (G2H, M1S CN, P3 CN, M2 CN, H1 CN, E1 CN, G3 CN, G2H Pro, M2 2022, M2 old EU/Global, M1S 2022, M3) integration for Home Assistant\n\nControl Zigbee devices from Home Assistant with **Aqara Gateway (KTBL12LM, ZHWG15LM, ZHWG12LM, ZNSXJ12LM, ZNSXJ12LM, ZNSXJ13LM, ZNSXJ15LM, ZHWG19LM, ZHWG20LM, ZHWG24LM)**.\nGateway support **Zigbee 3**.\n\nThis integration was based on the development of [@AlexxIT](https://github.com/AlexxIT/XiaomiGateway3/), Thanks Alex.\n\n**ATTENTION**: The component **only works on modified firmware (M2) or the gateway which was enabled telnet.**\n\n**ATTENTION2**: The Lumi company (Aqara manufacturer) started disable the post_init script. If you still want to use this component, please do not update to latest firmware of the gateway/hub. If you already updated to latest firmware and telnet is not working, you need switch to Mi Home mode and enable telnet by soft_hack method. Then flash modified firmware.\n\nFor Gateway M2 and Switch H1 Hub, to flash modified firmware to M2, please use [AqaraGateway.exe](https://github.com/niceboygithub/AqaraM1SM2fw/raw/main/tools/aqaragateway.exe) to flash customize firmware. Need to open the case of gateway and wired out the UART of [M2](https://github.com/niceboygithub/AqaraM1SM2fw/raw/main/images/M2/m2_uart.png) or [H1](https://github.com/niceboygithub/AqaraM1SM2fw/raw/main/images/H1/h1_uart.png).\n\nFor Gateway M1S CN, AirCondition P3 CN, Hub E1 CN, Gateway M1S 2022 CN, please switch to **Mi Home mode**, and [get the token](https://github.com/piotrmachowski/xiaomi-cloud-tokens-extractor).\n\n## Installation\n\nyou can install component with [HACS](https://hacs.xyz),  custom repo: HACS \u003e Integrations \u003e 3 dots (upper top corner) \u003e Custom repositories \u003e URL: `niceboygithub/AqaraGateway` \u003e Category: Integration\n\nOr Download and copy `custom_components/aqara_gateway` folder to `custom_components` folder in your HomeAssistant config folder\n\n\n## Configuration\n\n1. [⚙️ Configuration](https://my.home-assistant.io/redirect/config) \u003e [🧩 Integrations](https://my.home-assistant.io/redirect/integrations) \u003e [➕ Add Integration](https://my.home-assistant.io/redirect/config_flow_start?domain=aqara_gateway) \u003e 🔍 Search `Aqara Gateway`\n\nOr click (HA v2021.3.0+): [![add](https://my.home-assistant.io/badges/config_flow_start.svg)](https://my.home-assistant.io/redirect/config_flow_start?domain=aqara_gateway)\n1. If the integration didn't show up in the list please REFRESH the page\n2. If the integration is still not in the list, you need to clear the browser cache.\n3. Enter Gateway IP address.\n4. If you applied a password of telnet in gateway, please enter the password. Otherwise, ignore this field.\n5. Enter the xiaomi token of gateway if it is the first time to add integration. Otherwise, ignore this field.\n6. Click Send button, then wait this integration is configured completely.\n7. Done\n\n\n[More detail instructions](https://gist.github.com/InsaneWookie/1221cd6267745ea3c16f6a2a83ba3a44) from [@InsaneWookie](https://gist.github.com/InsaneWookie)\n\n\n## Manually Enable Telnet\n**ATTENTION**: There is a good news to enable telnet manually. The magic is \"5 clicks, pause, 2 clicks, pause, 2 clicks, pause, 2 clicks, pause, 2 clicks, pause, 2 clicks, pause, 2 clicks, pause\" from [here](https://github.com/AlexxIT/XiaomiGateway3/issues/1057#issuecomment-1543550411).\nThe Lumi removed the method \"set_ip_info\" in the new version of M1S \"Mi version 4.0.3_0012, Aqara version 3.5.2_0010.0636\" and other hubs also. If you were already upgrade to this verison, the only way to enabled customed firwmware by [AqaraGateway.exe](https://github.com/niceboygithub/AqaraM1SM2fw/raw/main/tools/aqaragateway.exe) or use [gw_global_tool](https://github.com/niceboygithub/AqaraM1SM2fw/tree/main/tools#gateway-global-tool) to clean password and flash customed firmware.\n\nYou can use [custom open telnet command](https://gist.github.com/zvldz/1bd6b21539f84339c218f9427e022709) way 2 or way 3 to enable telnet in *Mija Home mode*, then flash modification firmwares to [M1S](https://github.com/niceboygithub/AqaraM1SM2fw/tree/main/modified/M1S), [P3](https://github.com/niceboygithub/AqaraM1SM2fw/tree/main/modified/P3), [E1](https://github.com/niceboygithub/AqaraCameraHubfw/tree/main/modified/E1),  if you want use them in Aqara Home. No need to open the case of gateway.\n\nAfter telnet to gateway via putty, there are two methods (Flash or Not) to enable telnet and public mqtt.\n\n## Not Flash modified firmware method (NOT for G2H, E1 hub, G3, G2H Pro, M2 2022, M3)\n\n```shell\nmkdir /data/bin\ncd /data/bin\nwget -O /data/bin/curl \"http://master.dl.sourceforge.net/project/mgl03/bin/curl?viasf=1\"; chmod +x /data/bin/curl\n/data/bin/curl -s -k -L -o /data/bin/mosquitto https://raw.githubusercontent.com/niceboygithub/AqaraM1SM2fw/main/binutils/mosquitto; chmod a+x /data/bin/mosquitto\n\nmkdir /data/scripts\ncd /data/scripts\n/data/bin/curl -s -k -L -o /data/scripts/post_init.sh https://raw.githubusercontent.com/niceboygithub/AqaraM1SM2fw/main/binutils/post_init.sh\nchmod +x /data/scripts/post_init.sh\n```\nThen restart gateway by reboot command.\n\n## Not Flash modified firmware method (for G2H)\n\n```shell\nmkdir /data/bin\ncd /data/bin\nwget -O /tmp/curl \"http://master.dl.sourceforge.net/project/aqarahub/binutils/curl?viasf=1\"; chmod +x /tmp/curl\n/tmp/curl -s -k -L -o /data/bin/mosquitto https://raw.githubusercontent.com/niceboygithub/AqaraCameraHubfw/main/binutils/mosquitto; chmod a+x /data/bin/mosquitto\n\n```\n\n## Not Flash modified firmware method (for G2H Pro)\n\n```shell\nmkdir /data/bin\ncd /data/bin\nwget -O /tmp/curl \"http://master.dl.sourceforge.net/project/aqarahub/binutils/curl?viasf=1\"; chmod +x /tmp/curl\n/tmp/curl -s -k -L -o /data/bin/mosquitto https://raw.githubusercontent.com/niceboygithub/AqaraCameraHubfw/main/binutils/mosquitto_g2hpro; chmod a+x /data/bin/mosquitto\n\nmkdir /data/scripts\ncd /data/scripts\necho -e \"#!/bin/sh\\n\\nfw_manager.sh -r\\nfw_manager.sh -t -k\" \u003e /data/scripts/post_init.sh\nchmod +x /data/scripts/post_init.sh\nchattr +i /data/scripts; chattr +i /data/scripts/post_init.sh\n\n```\n\n## Not Flash modified firmware method (for E1 hub, G3, M2 2022, M3)\n\n```shell\nmkdir /data/bin\ncd /data/bin\nwget -O /tmp/curl \"http://master.dl.sourceforge.net/project/aqarahub/binutils/curl?viasf=1\"; chmod +x /tmp/curl\n/tmp/curl -s -k -L -o /data/bin/mosquitto https://raw.githubusercontent.com/niceboygithub/AqaraCameraHubfw/main/binutils/mosquitto_e1; chmod a+x /data/bin/mosquitto\n\nmkdir /data/scripts\ncd /data/scripts\necho -e \"#!/bin/sh\\n\\nfw_manager.sh -r\\nfw_manager.sh -t -k\" \u003e /data/scripts/post_init.sh\nchmod +x /data/scripts/post_init.sh\nchattr +i /data/scripts; chattr +i /data/scripts/post_init.sh\n\n```\n\n## Flash M1S modified firmware method\n```shell\ncd /tmp \u0026\u0026 wget -O /tmp/curl \"http://master.dl.sourceforge.net/project/mgl03/bin/curl?viasf=1\" \u0026\u0026 chmod a+x /tmp/curl\n/tmp/curl -s -k -L -o /tmp/m1s_update.sh https://raw.githubusercontent.com/niceboygithub/AqaraM1SM2fw/main/modified/M1S/m1s_update.sh\nchmod a+x /tmp/m1s_update.sh \u0026\u0026 /tmp/m1s_update.sh\n```\nIf there is no any error generated, then restart gateway by reboot command.\n\n## Flash M2 modified firmware method\n```shell\ncd /tmp \u0026\u0026 wget -O /tmp/curl \"http://master.dl.sourceforge.net/project/mgl03/bin/curl?viasf=1\" \u0026\u0026 chmod a+x /tmp/curl\n/tmp/curl -s -k -L -o /tmp/m2_update.sh https://raw.githubusercontent.com/niceboygithub/AqaraM1SM2fw/main/modified/M2/m2_update.sh\nchmod a+x /tmp/m2_update.sh \u0026\u0026 /tmp/m2_update.sh\n```\nIf there is no any error generated, then restart gateway by reboot command.\n\n## Flash P3 modified firmware method\n```shell\ncd /tmp \u0026\u0026 wget -O /tmp/curl \"http://master.dl.sourceforge.net/project/mgl03/bin/curl?viasf=1\" \u0026\u0026 chmod a+x /tmp/curl\n/tmp/curl -s -k -L -o /tmp/p3_update.sh https://raw.githubusercontent.com/niceboygithub/AqaraM1SM2fw/main/modified/P3/p3_update.sh\nchmod a+x /tmp/p3_update.sh \u0026\u0026 /tmp/p3_update.sh\n```\nIf there is no any error generated, then restart gateway by reboot command.\n\n## Flash H1 modified firmware method\n```shell\ncd /tmp \u0026\u0026 wget -O /tmp/curl \"http://master.dl.sourceforge.net/project/mgl03/bin/curl?viasf=1\" \u0026\u0026 chmod a+x /tmp/curl\n/tmp/curl -s -k -L -o /tmp/h1_update.sh https://raw.githubusercontent.com/niceboygithub/AqaraM1SM2fw/main/modified/H1/h1_update.sh\nchmod a+x /tmp/h1_update.sh \u0026\u0026 /tmp/h1_update.sh\n```\nIf there is no any error generated, then restart gateway by reboot command.\n\n## Not Flash E1 modified firmware method\n\nSuggest to use another expert's method, pleae move to [his github](https://github.com/zvldz/aqcn02_fw/tree/main/update) to see hot to do it.  He provides a way that avoid any risk on flashing firmwares.\n\nIf there is no any error generated, then restart gateway by reboot command.\n\n*Note: It updates firmware only if the checksum of the downloaded file is correct.*\n\n## For M2 old EU/Global\nUse [this tool](https://github.com/niceboygithub/AqaraM1SM2fw/tree/main/tools#gateway-global-tool) to clean telnet login password. The firmware before the version 4.0.4 was enabled telnetd as default. After clear the login password, you can this integration now.\n\n```\nchmod a+w /data/scripts/post_init.sh\necho -e \"#!/bin/sh\\n\\nfw_manager.sh -r \\nfw_manager.sh -t -k\" \u003e /data/scripts/post_init.sh\nchattr +i /data/scripts; chattr +i /data/scripts/post_init.sh\n```\n\n## For G2H\nThere is a way to [enable telnetd](https://github.com/niceboygithub/AqaraCameraHubfw/blob/main/binutils/README.md#aqara-camera-hub-g2g2h-znsxj12lm-related-binutils).\n\n## For G3, G2H Pro\nThere is a way to [enable telnetd](https://github.com/Wh1terat/aQRootG3) from #Wh1terat. After enabled telnet, you need use putty to telnet \u003cip of your G3\u003e. Then enter the following commands.\n\n```\nchmod a+w /data/scripts/post_init.sh\necho -e \"#!/bin/sh\\n\\nasetprop sys.camera_ptz_moving true\\nfw_manager.sh -r\\nfw_manager.sh -t -k\" \u003e /data/scripts/post_init.sh\nchattr +i /data/scripts; chattr +i /data/scripts/post_init.sh\n```\n\nDue to [Lumi closed the exploit](https://github.com/Wh1terat/aQRootG3#warningwarning-warning) and removed post_init.sh feature after version 3.4.1. It won't support after the version 3.3.9 of G3 firmware. If you want to enable telnet of G3, you need to downgrade the firmware to the version 3.3.4. The method to downgrade is as the following steps.\n\n```\n1. Get 'rootfs.bin' of firmware version 3.3.4. (use 7z to extract the firmware bin)\n2. Copy 'rootfs.bin' to sdcard which is using FAT32 format.\n3. Power Off G3.\n4. Insert the sdcard to G3.\n5. Press the front button of G3.\n6. Power on G3.\n7. Wait three seconds and release the button.\n8. If the LED is turned to RED, it starts to flash 'rootfs.bin'.\n```\n\n**Important:** Aqara may force your G3 to upgrade to latest without your permission. To lock firmware update, please use below commands to lock by telnet.\n```\nmkdir -p /data/ota_dir\ntouch /data/ota_dir/lumi_fw.tar\nchattr +i /data/ota_dir;chattr +i /data/ota_dir/lumi_fw.tar\n```\n\n*Flash G3 customized firmware*\n\nUSING AT YOUR OWN RISK.\nGo to this [link](https://github.com/niceboygithub/AqaraCameraHubfw/tree/main/modified/G3) and follow the intrusion after enabled telnet.\n\n\n## For M1S 2022\nOnly support the firmware version above 4.x and flashed the modified firmware. You need to use UART to clear the password of root and flash modified firmware.\n\n## How to check this component is working properly.\nGo to Configuration-\u003eInfo-\u003esystem_health\n\u003cimg src=\"https://raw.githubusercontent.com/niceboygithub/AqaraGateway/master/system_health.png\"\u003e\n\n\n### Aqara Presence Detector FP1\n\nMovements sensor\n```\nIn the left and right monitoring mode, only report 2, 3, 4, 5, 6, 7;\nIn the non-directional monitoring mode, only report 0, 1, 6, 7;\n0: enter\n1: leave\n2: left in\n3: right out\n4: right in\n5: left out\n6: approaching\n7: far away\n```\n\n**Attention:** The component is under active development.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniceboygithub%2Faqaragateway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fniceboygithub%2Faqaragateway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniceboygithub%2Faqaragateway/lists"}