Aqara G2H (ZNSXJ12LM
) is a really nice Zigbee hub and indoor camera with official HomeKit support. Of course it runs Linux so people have discovered ways to connect it to Home Assistant which exposes most of your HomeKit devices to Home Assistant over MQTT without impacting the original Apple Home and Aqara app integrations.
Getting Access
Turns out you can put a file named hostname
(without any file extension) in the root of the SD card of the device and it will be executed as a bash script during the boot process. The following contents will set the password for the user root
to password
and set the WITH_TELNET
environment variable to y
which enables the telnetd
service for remote access:
#!/bin/sh
echo "root:password" | chpasswd
export WITH_TELNET="y"
After inserting the SD card and restarting the camera you should be able to connect to it using telnet:
telnet camera-hub-g2h.local
which opens the telnet prompt:
Trying 123.123.123.123...
Connected to camera-hub-g2h.local.
Escape character is '^]'.
Camera-Hub-G2H login: root
Password:
and you now have full root access to the filesystem!
Setup Aqara Gateway
The AqaraGateway project is a set of custom binaries and python scripts that enable access to all the connected Zigbee devices over MQTT while keeping the Aqara app and the HomeKit integration working as before.
It does it in the following way:
- You replace the
mosquitto
MQTT broker binary on the device with a custom one (which appears to be closed source?) which exposes the MQTT service on a public port on your local network and removes the authentication for the MQTT service. - You install the Aqara Gateway Home Assistant integration via HACS (Home Assistant Community Store) which then talks to the device over
telnet
to validate themosquitto
binary, to fetch the available Zigbee devices and to establish an MQTT subscription with the broker on the device. - The Aqara Gateway in your Home Assistant maps the MQTT messages to different devices supported by the gateway such as binary sensors and general sensors similar to Zigbee2MQTT.
Initially the gateway integration wasn’t recognizing my camera but this was resolved in one of the recent updates.
Support for new Aqara Zigbee devices requires updates to the AqaraGateway library and it appears that new issues are being opened on GitHub and they are also addressed.
Conclusions
Aqara hubs that support Aqara Gateway software are the only option on the market with local, no-cloud and open source API which supports HomeKit and Home Assistant integration at the same time. Another alternative is the Zemismart Zigbee Gateway which adds HomeKit support for many of the Tuya Zigbee devices, and can be rooted too.
However, the Zemismart gateway looses the HomeKit support if you replace the Tuya integration with the a ZHA serial gateway supported by Home Assistant because it takes over the UART connection with /dev/ttyS2
which is used by the Tuya zigbee_agent
to talk to the NXP JN5189 Zigbee module.
I tried all this but there is no port opened for the cam to access via telnet. Is this article outdated?
The telnet service is disabled by default. You must create a file named
hostname
with the contents from the article in the root directory of an SD card which you then insert into the camera, and restart it to enable the telnet and reset theroot
password.Hello, I tried to create the hostname file and put it on the hub but I can’t access telenet, does the file is the same on Camera-Hub-G2HPro-E23B ?
Thanks for your help
G2H Pro is a different model which requires a different approach as described in this comment on GitHub.
What does this exactly?
Does it enable camera devices to join the Zigbee2MQTT network? Or just exposes connected zigbee devices in home assistant (if so then how it’s different than default homekit integration in home assistant which already does that?)
The custom mosquitto broker binary exposes most of the HomeKit devices to Home Assistant over MQTT without impacting the original Apple Home and Aqara app integrations.
Hi,
I’m a bit confused.
“Initially the gateway integration wasn’t recognizing my camera but this was resolved in one of the recent updates.”
I was able to add the repository and install the aqara gateway.
I was also able to add the G2H to this service. However, the only thing I can do is ‘sync’…
I don’t see any of the camera options itself (motion sensor, camera feed, …)
Is the purpose of this intergation only to use the G2H as a hub ?
Yes, correct — the integration
. I agree that not having camera exposed in HomeAssistant is confusing and most users are probably looking for this exact feature.Hello,
I’ve this ZNSXJ12LM connected to door sensors and wall switches WXKG02LM controlled by Mi Home App.
I want to install Home Assistant locally to not be dependent from the cloud, but normally the ZigBee hub of the camera don’t works with HA.
Whit this method can I continue to use Mi Home and connect all my ZigBee devices connected to the cameras in HA ? No need a third ZigBee on the house to connect the ZigBee devices ?
Hi, this all works great! Thanks for the posing.
One thing I don’t really get — in this configuration, can the g2h cam be an actual Zigbee hub to connect to other devices (e.g. Sonoff) thru the Home Assistant? Much appreciated.
The HomeKit integration in the Home app or the Aqara app will show only the devices bound to the camera hub. And the camera hub can bind only to any HomeKit or Aqara devices.
Is there any way to jailbreak a Zigbee agent in G2H firmware to connect to 3rd party devices?
Apparently for Aqara G2 (ZNSXJ12LM) chinese version this don’t work.
I reached to open telnet by UART with no problem, and installed the custom Mosquitto but HA don’t let connect it, I’ve always Unknown Error Occurred.
It’s strange same model ZNSXJ12LM but from chinese version don’t connect, it it so different from WorldWide version?