Hi there,
After playing a bit with Xiaomi Gateway v3 I think that I am ready to make a new binding to ease my life with configuration all the sensors.
Lots of info about the topic can be found here for Home Assistant: GitHub - AlexxIT/XiaomiGateway3: Control Zigbee, BLE and Mesh devices from Home Assistant with Xiaomi Gateway 3 (ZNDMWG03LM) on original firmware
In a nutshell - gateway talks to devices and all communication goes through an internal MQTT queue. It is possible to allow an external connection to that MQTT.
Preparation:
After some magic, gateway allows external MQTT connection.
Problem:
As all communication go through a single topic, itâs quite difficult to maintain different devices in OpenHab.
Message example:
{
"cmd": "heartbeat",
"id": 2000000231,
"time": 1613984512654,
"rssi": -60,
"params": [
{
"did": "lumi.158d00028",
"time": 1613984512654,
"res_list": [
{
"res_name": "8.0.2008",
"value": 3155
},
{
"res_name": "8.0.2006",
"value": 30
},
{
"res_name": "8.0.2011",
"value": 4
}... and so on
For example, each door sensor can have many channels and lots of copy-paste like this:
Type string : TestSensorState [ stateTopic="zigbee/send",
transformationPattern="REGEX:(.*158d00028.*)â©JSONPATH:$.params[?(@.res_name=='3.1.85')].value" ]
Type string : TestSensorVoltage [ stateTopic="zigbee/send",
transformationPattern="REGEX:(.*158d00028.*)â©JSONPATH:$.params[0].res_list[?(@.res_name=='8.0.2008')].value" ]
Type string : TestSensorBattery [ stateTopic="zigbee/send",
transformationPattern="REGEX:(.*158d00028.*)â©JSONPATH:$.params[0].res_list[?(@.res_name=='8.0.2001')].value" ]
Type string : TestSensorPreState [ stateTopic="zigbee/send",
transformationPattern="REGEX:(.*158d00028.*)â©JSONPATH:$.params[0].res_list[?(@.res_name=='8.0.2011')].value" ]
Type string : TestSensorCurrentState [ stateTopic="zigbee/send",
transformationPattern="REGEX:(.*158d00028.*)â©JSONPATH:$.params[0].res_list[?(@.res_name=='8.0.2010')].value" ]
Type string : TestSensorChipTemp [ stateTopic="zigbee/send",
transformationPattern="REGEX:(.*158d00028.*)â©JSONPATH:$.params[0].res_list[?(@.res_name=='8.0.2006')].value" ]
Solution:
A binding that have different things with different channels depending on an actual thing.
A bridgeâs setting is a connection to the device (ip address).
For later: bridge thing will be able to configure the device: enable telnet it device reboots and enable mqtt. As for now I am using mio:basic thing connection with âEnable telnetâ switch. Also there is a bash script that enables telnet.
A door sensor thing with a couple of channels: battery status, sensor status. Also a setting for now - device ID (until automatic discovery is implemented).
How it will work:
An internal object (MqttBrokerConnection) will connect to the gateway. Upon receiving a new message it will parse it and update a specific thing.
Can someone please comment on my thoughts about the binding? As this is my first binding I would like to confirm that itâs needed, itâs not easy to make this without a binding and the architecture is fine.
Thank you