Mijia Smart Multi-Mode Gateway V3 (ZNDMWG03LM) support

It seems the HASS community got the new gateway integrated.
Hopefully someone could reproduce this with OpenHab2/3 :slight_smile:

I tried to order an old V2 gateway some months ago but I couldn’t get one, seems they are all sold out or do not get produced anymore.
The only online store which offered a V2 gateway (geekbuying) then send me a V3 gateway instead and when I complained told me that they also don’t have any V2 gateways anymore :confused:

Some more information:

Enable Telnet and Root Access on the Gateway:

Then as far as I understand there is apparently an MQTT Broker running on the Gateway V3 with no authentication which you can use to get all sensor updates

And another update, I was able to integrate a Mijia Power Plug through the Mijia Gateway V3 with OpenHAB2 through the MQTT Binding with the help of the HASS forum and looking into the HASS integration files.

Note that Steps #2 and #3 are NOT PERMANENT. They need to be repeated each time the gateway gets restarted.

  1. Setup your Gateway V3 and add devices to it

  2. Enable Telnet on the V3 gateway as described in the HASS Forum, I used miio-cli.php for this step and the hacked Xiaomi Home App to get the token from the Gateway V3.

  3. Login with Telnet on the Gateway (user = admin OR app, no password)
    run the following commands to enable access to the MQTT client on the gateway:

killall mosquitto
mosquitto -d
killall zigbee_gw
exit

after executing the commands you can access the MQTT client on the Gateway from outside.
When I logged in I saw that there is a topic “gw/680AE2FFFED97F2F”.
I assume the number is different for everybody, I can now send MQTT messages to that topic and subtopics

4. OpenHab Setup

You need the MQTT Binding for it
My Gateway IP address is 192.168.0.94
And I got the number 680AE2FFFED97F2F from the previous step by logging in with a MQTT client and saw what topics there are.

By turning the power plug ON and OFF with the MiHome App I got the messages that I need to send to turn it OFF and ON myself with the binding.

Thing:

Bridge mqtt:broker:MQTTBroker [ host="192.168.0.94", clientID="OH2" ]
{
	Thing topic XOutlet {
	Channels:
		Type switch : XOutlet "XOutlet" [ commandTopic="gw/680AE2FFFED97F2F/commands", on="{\"commands\":[{\"commandcli\":\"zcl on-off on\",\"postDelayMs\":0},{\"commandcli\":\"send 0x34b9 1 1\",\"postDelayMs\":0}]}", off="{\"commands\":[{\"commandcli\":\"zcl on-off off\",\"postDelayMs\":0},{\"commandcli\":\"send 0x34b9 1 1\",\"postDelayMs\":0}]}" ]
    }
}

Item:

Switch	XOutlet  "Mijia Outlet"  <powersocket2>	  (Outlets)  ["Switchable"]  { channel="mqtt:topic:MQTTBroker:XOutlet:XOutlet" }

Sitemap:

Switch item=XOutlet
1 Like

The easiest way to do this is with openhab: Install miio binding, enter your cloud details, the gateway will be discovered including the latest tokens.
Accept the thing (indicated as unsupported). It will have a command channel. Send enable_telnet_service to the channel and you can go with step 3.

That worked as well, thanks for the hint!

I am not really an expert with Binding Programing, hopefully someone could take up this task to automate the steps and integrate it in a binding :slight_smile:

Item:

String XGatewayV3_1_CmdSel   "Send Command"
String XGatewayV3_1_Command  "Cmd Channel Gateway V3 #1"  {channel="miio:generic:13D12F70:actions#commands" }

Rule:

rule "RULE: XGatewayV3_1_CmdSel"
when
    Item XGatewayV3_1_CmdSel received command
then
    sendCommand(XGatewayV3_1_Command,XGatewayV3_1_CmdSel.state.toString)
end

Sitemap:

Selection item=XGatewayV3_1_CmdSel mappings=["enable_telnet_service"="Enable Telnet"]

Great minds think alike :joy_cat:
To be honest I was/am slightly afraid it would be confusing for users as we have 2 bindings for the same physical thing. Nevertheless I made pr yesterday for it

2 Likes

I also was confused haha.
Enabling Telnet is only the first step, then someone still needs to login and open the MQTT server. I am not sure how the MiHome binding works with the other gateways, but I assume controlling devices through this gateway V3 is different…

In HASS they check if telnet is enabled and if not automatically enable it and open the MQTT server on the gateways. But from the concept of the Mi IO Binding I think this is the wrong place for such a logic.

If you’ve got enabled REST interface, you can run:
curl -X POST --header “Content-Type: text/plain” --header “Accept: application/json” -d “enable_telnet_service” “http://hostname:8080/rest/items/miio_unsupported_164ECC86_actions_commands

If you don’t know the Item, you can list them by:
curl -X GET --header “Accept: application/json” “http://hostname:8080/rest/items?recursive=false

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.