Skip to content

Latest commit

 

History

History
141 lines (108 loc) · 8.44 KB

README.md

File metadata and controls

141 lines (108 loc) · 8.44 KB

Aqara Gateway/Hub (G2H, M1S CN, P3 CN, M2 CN, H1 CN, E1 CN) integration for Home Assistant

Control Zigbee devices from Home Assistant with Aqara Gateway (KTBL12LM, ZHWG15LM, ZHWG12LM, ZNSXJ12LM, ZNSXJ12LM). Gateway support Zigbee 3.

This integration was based on the development of @AlexxIT, Thanks Alex.

ATTENTION: The component only works on modified firmware (M2) or the gateway which was enabled telnet.

For Gateway M2, to flash modified firmware to M2, please use AqaraGateway.exe to flash customize firmware. Need to open the case of gateway and wired out the UART.

For Gateway M1S CN, AirCondition P3 CN, Smart Hub H1 CN, Hub E1 CN, please switch to Mi Home mode, and get the token.

Installation

you can install component with HACS, custom repo: HACS > Integrations > 3 dots (upper top corner) > Custom repositories > URL: niceboygithub/AqaraGateway > Category: Integration

Or Download and copy custom_components/aqara_gateway folder to custom_components folder in your HomeAssistant config folder

Configuration

  1. ⚙️ Configuration > 🧩 Integrations > ➕ Add Integration > 🔍 Search Aqara Gateway

    Or click (HA v2021.3.0+): add

    1. If the integration didn't show up in the list please REFRESH the page
    2. If the integration is still not in the list, you need to clear the browser cache.
  2. Enter Gateway IP address.

  3. If you applied a password of telnet in gateway, please enter the password. Otherwise, ignore this field.

  4. Enter the xiaomi token of gateway if it is the first time to add integration. Otherwise, ignore this field.

  5. Click Send button, then wait this integration is configured completely.

  6. Done

More detail instructions from @InsaneWookie

Manually Enable Telnet

You can use custom open telnet command way 2 or way 3 to enable telnet in Mija Home mode, then flash modification firmwares to M1S , P3 , E1 , if you want use them in Aqara Home. No need to open the case of gateway.

After telnet to gateway via putty, there are two methods (Flash or Not) to enable telnet and public mqtt.

Not Flash Custom firmware method

mkdir /data/bin
cd /data/bin
wget -O /data/bin/curl "http://master.dl.sourceforge.net/project/mgl03/bin/curl?viasf=1"
chmod +x /data/bin/curl
/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

mkdir /data/scripts
cd /data/scripts
/data/bin/curl -s -k -L -o /data/scripts/post_init.sh https://raw.githubusercontent.com/niceboygithub/AqaraM1SM2fw/main/binutils/post_init.sh
chmod +x /data/scripts/post_init.sh

Then restart gateway by reboot command.

Flash M1S Custom firmware method

cd /tmp
wget -O /tmp/curl "http://master.dl.sourceforge.net/project/mgl03/bin/curl?viasf=1"
chmod a+x /tmp/curl
/tmp/curl -s -k -L -o /tmp/linux.bin https://raw.githubusercontent.com/niceboygithub/AqaraM1SM2fw/main/original/M1S/3.2.8_0009.0526//linux_3.2.8_0009.0526.bin
fw_update /tmp/linux.bin
/tmp/curl -s -k -L -o /tmp/rootfs.bin https://raw.githubusercontent.com/niceboygithub/AqaraM1SM2fw/main/modified/M1S/3.2.8_0009.0526/rootfs_3.2.8_0009.0526_modified.bin
fw_update /tmp/rootfs.bin
/tmp/curl -s -k -L -o /tmp/ControlBridge.bin https://raw.githubusercontent.com/niceboygithub/AqaraM1SM2fw/main/original/M1S/3.2.8_0009.0526/ControlBridge.bin
[ "$(md5sum /tmp/ControlBridge.bin)" = "799ecb705ce22049566a0d772c93c2b2  /tmp/ControlBridge.bin" ] && zigbee_msnger zgb_ota /tmp/ControlBridge.bin

If there is no any error generated, then restart gateway by reboot command.

Flash M2 Custom firmware method

cd /tmp
wget -O /tmp/curl "http://master.dl.sourceforge.net/project/mgl03/bin/curl?viasf=1"
chmod a+x /tmp/curl
/tmp/curl -s -k -L -o /tmp/linux.bin https://raw.githubusercontent.com/niceboygithub/AqaraM1SM2fw/main/original/M2/3.2.8_0006.0526/linux_3.2.8_0006.0526.bin
fw_update /tmp/linux.bin
/tmp/curl -s -k -L -o /tmp/rootfs.bin https://raw.githubusercontent.com/niceboygithub/AqaraM1SM2fw/main/modified/M2/3.2.8_0006.0526/rootfs_3.2.8_0006.0526_modified.bin
fw_update /tmp/rootfs.bin
/tmp/curl -s -k -L -o /tmp/ControlBridge.bin https://raw.githubusercontent.com/niceboygithub/AqaraM1SM2fw/main/original/M2/3.2.8_0006.0526/ControlBridge.bin
[ "$(md5sum /tmp/ControlBridge.bin)" = "799ecb705ce22049566a0d772c93c2b2  /tmp/ControlBridge.bin" ] && zigbee_msnger zgb_ota /tmp/ControlBridge.bin

If there is no any error generated, then restart gateway by reboot command.

Flash P3 Custom firmware method

cd /tmp
wget -O /tmp/curl "http://master.dl.sourceforge.net/project/mgl03/bin/curl?viasf=1"
chmod a+x /tmp/curl
/tmp/curl -s -k -L -o /tmp/linux.bin https://raw.githubusercontent.com/niceboygithub/AqaraM1SM2fw/main/original/P3/3.0.7_0007.0515/linux_3.0.7_0007.0515.bin
fw_update /tmp/linux.bin
/tmp/curl -s -k -L -o /tmp/rootfs.bin https://raw.githubusercontent.com/niceboygithub/AqaraM1SM2fw/main/modified/P3/3.0.7_0007.0515/rootfs_3.0.7_0007.0515_modified.bin
fw_update /tmp/rootfs.bin

If there is no any error generated, then restart gateway by reboot command.

Flash H1 Custom firmware method

cd /tmp
wget -O /tmp/curl "http://master.dl.sourceforge.net/project/mgl03/bin/curl?viasf=1"
chmod a+x /tmp/curl
/tmp/curl -s -k -L -o /tmp/linux.bin https://raw.githubusercontent.com/niceboygithub/AqaraM1SM2fw/main/original/H1/3.0.8_0001.0512/linux_3.0.8_0001.0512.bin
fw_update /tmp/linux.bin
/tmp/curl -s -k -L -o /tmp/rootfs.bin https://raw.githubusercontent.com/niceboygithub/AqaraM1SM2fw/main/modified/H1/3.0.8_0001.0512/rootfs_3.0.8_0001.0512_modified.bin
fw_update /tmp/rootfs.bin

If there is no any error generated, then restart gateway by reboot command.

Flash E1 Custom firmware method

cd /tmp
wget -O /tmp/curl "http://master.dl.sourceforge.net/project/aqarahub/binutils/curl?viasf=1"
chmod a+x /tmp/curl
/tmp/curl -s -k -L -o /tmp/coor.bin https://raw.githubusercontent.com/niceboygithub/AqaraCameraHubfw/main/original/E1/3.1.3_0066/Network-Co-Processor.ota
[ "$(md5sum /tmp/coor.bin)" = "59b527769c2ecb2b840967f97b88eaa3  /tmp/coor.bin" ] && zigbee_msnger zgb_ota /tmp/coor.bin
/tmp/curl -s -k -L -o /tmp/kernel https://raw.githubusercontent.com/niceboygithub/AqaraCameraHubfw/main/original/E1/3.1.3_0066/kernel_3.1.3_0066
[ "$(md5sum /tmp/kernel)" = "c5fb24da4d0ba28181a1c0c7f71e5497  /tmp/kernel" ] && fw_update.sh /tmp/kernel
/tmp/curl -s -k -L -o /tmp/rootfs.sqfs https://raw.githubusercontent.com/niceboygithub/AqaraCameraHubfw/main/modified/E1/3.1.3_0066/rootfs_3.1.3_0066_modified.sqfs
[ "$(md5sum /tmp/rootfs.sqfs)" = "2a8c23fa8e0f742269f0eb1dc13bbc7c  /tmp/rootfs.sqfs" ] && fw_update.sh /tmp/rootfs.sqfs

If there is no any error generated, then restart gateway by reboot command.

Note: It updates firmware only if the checksum of the downloaded file is correct.

For G2H

There is a way to enable telnetd.

How to check this component is working properly.

Go to Configuration->Info->system_health

Attention: The component is under active development.

Buy Me A Coffee