Skip to content

Commit b1d9bee

Browse files
author
niceboy
committed
Add the support of Aqara Gateway M1S 2022 (above the version of
firmware 4.x)
1 parent 661d618 commit b1d9bee

File tree

6 files changed

+30
-9
lines changed

6 files changed

+30
-9
lines changed

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22
<a href="https://www.buymeacoffee.com/niceboygithub" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>
33

4-
# Aqara Gateway/Hub (G2H, M1S CN, P3 CN, M2 CN, H1 CN, E1 CN, G3 CN, G2H Pro, M2 2022, M2 old EU/Global) integration for Home Assistant
4+
# 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
55

6-
Control Zigbee devices from Home Assistant with **Aqara Gateway (KTBL12LM, ZHWG15LM, ZHWG12LM, ZNSXJ12LM, ZNSXJ12LM, ZNSXJ13LM, ZNSXJ15LM, ZHWG19LM)**.
6+
Control Zigbee devices from Home Assistant with **Aqara Gateway (KTBL12LM, ZHWG15LM, ZHWG12LM, ZNSXJ12LM, ZNSXJ12LM, ZNSXJ13LM, ZNSXJ15LM, ZHWG19LM, ZHWG20LM, ZHWG24LM)**.
77
Gateway support **Zigbee 3**.
88

99
This integration was based on the development of [@AlexxIT](https://github.com/AlexxIT/XiaomiGateway3/), Thanks Alex.
@@ -14,7 +14,7 @@ This integration was based on the development of [@AlexxIT](https://github.com/A
1414

1515
For 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).
1616

17-
For Gateway M1S CN, AirCondition P3 CN, Hub E1 CN, please switch to **Mi Home mode**, and [get the token](https://github.com/piotrmachowski/xiaomi-cloud-tokens-extractor).
17+
For 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).
1818

1919
## Installation
2020

@@ -150,8 +150,8 @@ Use [this tool](https://github.com/niceboygithub/AqaraM1SM2fw/tree/main/tools#ga
150150

151151
```
152152
chmod a+w /data/scripts/post_init.sh
153-
echo -e "#!/bin/sh\n\nfw_manager.sh -t -k" > /data/scripts/post_init.sh
154-
chattr +i post_init.sh
153+
echo -e "#!/bin/sh\n\nfw_manager.sh -r \nfw_manager.sh -t -k" > /data/scripts/post_init.sh
154+
chattr +i /data/scripts; chattr +i /data/scripts/post_init.sh
155155
```
156156

157157
## For G2H
@@ -163,7 +163,7 @@ There is a way to [enable telnetd](https://github.com/Wh1terat/aQRootG3) from #W
163163
```
164164
chmod a+w /data/scripts/post_init.sh
165165
echo -e "#!/bin/sh\n\nasetprop sys.camera_ptz_moving true\nfw_manager.sh -r\nfw_manager.sh -t -k" > /data/scripts/post_init.sh
166-
chattr +i post_init.sh
166+
chattr +i /data/scripts; chattr +i /data/scripts/post_init.sh
167167
```
168168

169169
Due 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.
@@ -183,7 +183,7 @@ Due to [Lumi closed the exploit](https://github.com/Wh1terat/aQRootG3#warningwar
183183
```
184184
mkdir -p /data/ota_dir
185185
touch /data/ota_dir/lumi_fw.tar
186-
chattr +i /data/ota_dir/lumi_fw.tar
186+
chattr +i /data/ota_dir;chattr +i /data/ota_dir/lumi_fw.tar
187187
```
188188

189189
*Flash G3 customized firmware*
@@ -192,6 +192,9 @@ USING AT YOUR OWN RISK.
192192
Go to this [link](https://github.com/niceboygithub/AqaraCameraHubfw/tree/main/modified/G3) and follow the intrusion after enabled telnet.
193193

194194

195+
## For M1S 2022
196+
Only 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.
197+
195198
## How to check this component is working properly.
196199
Go to Configuration->Info->system_health
197200
<img src="https://raw.githubusercontent.com/niceboygithub/AqaraGateway/master/system_health.png">

custom_components/aqara_gateway/alarm_control_panel.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from . import DOMAIN, GatewayGenericDevice
1515
from .core.gateway import Gateway
1616
from .core.utils import Utils
17-
from .core.shell import TelnetShell, TelnetShellE1, TelnetShellM2POE, TelnetShellM3
17+
from .core.shell import TelnetShell, TelnetShellE1, TelnetShellM2POE, TelnetShellM1S22, TelnetShellM3
1818

1919
ALARM_STATES = [STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_AWAY,
2020
STATE_ALARM_ARMED_NIGHT, STATE_ALARM_DISARMED]
@@ -54,6 +54,8 @@ def __init__(
5454
self._shell = TelnetShellE1(gateway.host)
5555
elif "m2 2022" in device_name:
5656
self._shell = TelnetShellM2POE(gateway.host)
57+
elif "m1s 2022" in device_name:
58+
self._shell = TelnetShellM1S22(gateway.host)
5759
elif "m3" in device_name:
5860
self._shell = TelnetShellM3(gateway.host)
5961
else:

custom_components/aqara_gateway/core/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
'h1': "Aqara Smart Hub H1",
4848
'p3': "Aqara AirCondition P3",
4949
'm1s': "Aqara Gateway M1S",
50+
'm1s 2022': "Aqara Gateway M1S 2022",
5051
'e1': "Aqara Hub E1",
5152
'm2': "Aqara Gateway M2",
5253
'm2 2022': "Aqara Gateway M2 2022",

custom_components/aqara_gateway/core/gateway.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
TelnetShellG3,
2222
TelnetShellG2HPro,
2323
TelnetShellM2POE,
24+
TelnetShellM1S22,
2425
TelnetShellM3
2526
)
2627
from .utils import DEVICES, Utils, GLOBAL_PROP
@@ -200,6 +201,9 @@ def _prepare_gateway(self, get_devices: bool = False):
200201
elif "m2 2022" in device_name:
201202
shell = TelnetShellM2POE(self.host,
202203
self.options.get(CONF_PASSWORD, ''))
204+
elif "m1s 2022" in device_name:
205+
shell = TelnetShellM1S22(self.host,
206+
self.options.get(CONF_PASSWORD, ''))
203207
elif "m3" in device_name:
204208
shell = TelnetShellM3(self.host,
205209
self.options.get(CONF_PASSWORD, ''))
@@ -427,6 +431,9 @@ def process_gateway_stats(self, payload: dict = None):
427431
elif "m2 2022" in device_name:
428432
shell = TelnetShellM2POE(self.host,
429433
self.options.get(CONF_PASSWORD, ''))
434+
elif "m1s 2022" in device_name:
435+
shell = TelnetShellM1S22(self.host,
436+
self.options.get(CONF_PASSWORD, ''))
430437
elif "m3" in device_name:
431438
shell = TelnetShellM3(self.host,
432439
self.options.get(CONF_PASSWORD, ''))
@@ -526,6 +533,9 @@ def _process_devices_info(self, prop, value):
526533
elif "m2 2022" in device_name:
527534
shell = TelnetShellM2POE(self.host,
528535
self.options.get(CONF_PASSWORD, ''))
536+
elif "m1s 2022" in device_name:
537+
shell = TelnetShellM1S22(self.host,
538+
self.options.get(CONF_PASSWORD, ''))
529539
elif "m3" in device_name:
530540
shell = TelnetShellM3(self.host,
531541
self.options.get(CONF_PASSWORD, ''))
@@ -896,6 +906,8 @@ def is_aqaragateway(host: str,
896906
shell = TelnetShellG3(host, password)
897907
elif "m2 2022" in device_name.lower():
898908
shell = TelnetShellM2POE(host, password)
909+
elif "m1s 2022" in device_name.lower():
910+
shell = TelnetShellM1S22(host, password)
899911
elif "m3" in device_name.lower():
900912
shell = TelnetShellM3(host, password)
901913
else:

custom_components/aqara_gateway/core/shell.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,11 @@ def login(self):
254254
class TelnetShellG2HPro(TelnetShellG3):
255255
pass
256256

257-
258257
class TelnetShellM2POE(TelnetShellG3):
259258
pass
260259

260+
class TelnetShellM1S22(TelnetShellG3):
261+
pass
262+
261263
class TelnetShellM3(TelnetShellG3):
262264
pass

custom_components/aqara_gateway/core/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
'lumi.camera.gwpgl1': ["Aqara", "Camera Hub G3", "CH-H03"],
4747
'lumi.camera.agl001': ["Aqara", "Camera Hub G2H Pro", "ZNSXJ15LM"],
4848
'lumi.gateway.iragl8': ["Aqara", "Gateway M2 2022", "ZHWG19LM"], # tested
49+
'lumi.gateway.acn004': ["Aqara", "Gateway M1S 2022", "ZHWG20LM"], # tested
4950
'lumi.gateway.acn012': ["Aqara", "Gateway M3", "ZHWG24LM"],
5051
'lumi.gateway.agl004': ["Aqara", "Gateway M3", "HM-G01D"],
5152
'params': [

0 commit comments

Comments
 (0)