Cannod add Xiaomi Gateway

Others (MiLight, Hue, Toon etc...)

Moderator: leecollings

Post Reply
mattPiratt
Posts: 7
Joined: Wednesday 12 December 2018 6:40
Target OS: OS X
Domoticz version:
Contact:

Cannod add Xiaomi Gateway

Post by mattPiratt »

Hello to this wonderful community.

I am using Domoticz + 2 Xiaomi Gateway v2 (x2) for many months now and I am very satisfied.
Currently I am in a need to add 3rd gateway, but completly no luck with with getting it into Domoticz->Setup->Devices->Not used
You know, there should be "Alarm Clock", "Dorbell", "MP3" devices there after adding Gateway into "Domoticz->Setup->Hardware"

I am loosing my mind and almost giving up. Unable to continue by myself. Please lovely community, help me get this through.

Facts, maybe not all related but all I know
* have tried with clean instance of Domoricz, with no configs, no prev Xiaomi gateways, only new one. Pure clean instalation @ V4.10602
* was using tutorial from https://www.domoticz.com/wiki/Xiaomi_Ga ... e_gateways
* my router is connected to 16p switch (not managed) and NAS (where Domoticz lives) is connected to switch with 2 LANs (link aggregation) and my WiFi comes from AccessPoint "Unifi AC Lite" also connected to Switch (1 cable with POE). This means all devices are in same network class.
* Using router: EdgeRouter X , firmware v1.10.9 (newest).
** There is no "IGMP Proxy" config on a router because Domoticz(Synology) is connected to switch over LAN, and Xiaomi Gateways via AccessPoints (Wifi 2,4GHz) on same network. So UDP Broadcasting should work correctly.
** there is Link Aggregation on NAS, but Synology solves this right by giving me one LAN interface on Synology~Docker machine (where Domoticz works):
```
ovs_bond0 Link encap:Ethernet HWaddr 00:11:32:8E:2B:6D
inet addr:192.168.1.146 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: (..navermind..) Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:105258250 errors:0 dropped:0 overruns:0 frame:0
TX packets:49223200 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:463710874212 (431.8 GiB) TX bytes:229642597134 (213.8 GiB)
```
* Using Domoticz V4.10602. Compiled it myself from develop branch today, because this one had "multiple gateways" support.
** (in past, this enabled me to add 1st and 2nd gateway, no problem)
** Domoticz is on Synology NAS: a Docker container/Linux that is using "Host Network", meaning, Domoticz-machine is visible in same main network and Gateways, or router/switch
* I'm really bad with networks (probably)

Please come with any suggestions. Maybe this setup is uncommon, but at the end of a day, its just LAN, domoticz and Xiaomi gateway.

Help me ObiOneCommunity, You're my only Hope.
mattPiratt
Posts: 7
Joined: Wednesday 12 December 2018 6:40
Target OS: OS X
Domoticz version:
Contact:

Re: Cannod add Xiaomi Gateway

Post by mattPiratt »

Okay, I reply to myself.

I have 3 xiaomi gateways. Until now 2 are working ok, new one, the 3rd one does not (cannot add it to devices in Domoticz)

The setup from above is current, and I can confirm, there is no problem in the setup. Problem is with new Xiaomi Gateway v2 ("lumi.gateway.v3")

How do I know?
I have disabled current Docker container with Domoticz, and started fresh new one with Domoticz V4.10602.
Then I have added into "Hardware" one of my old Xiaomi Gateways (bough it last year).
All went well, and I have all devices I expect instantly!
2019-04-10 17:51:47.139 Status: XiaomiGateway (ID=2): Delaying worker startup...
2019-04-10 17:51:52.139 Status: XiaomiGateway (ID=2): Selected as main Gateway
2019-04-10 17:51:52.139 Status: XiaomiGateway (ID=2): Worker started...
2019-04-10 17:51:52.140 Status: XiaomiGateway (ID=2): Using 192.168.1.146 for local IP address.
2019-04-10 17:51:52.254 Status: XiaomiGateway: RGB Gateway Detected
2019-04-10 17:51:52.254 Status: XiaomiGateway: New Gateway Found (eb1d1392/Xiaomi RGB Gateway (192.168.1.157))
2019-04-10 17:51:52.256 Status: XiaomiGateway: New Xiaomi Gateway Alarm Ringtone Found (7c49eb1d1392)
2019-04-10 17:51:52.257 Status: XiaomiGateway: New Xiaomi Gateway Alarm Clock Found (7c49eb1d1392)
2019-04-10 17:51:52.259 Status: XiaomiGateway: New Xiaomi Gateway Doorbell Found (7c49eb1d1392)
2019-04-10 17:51:52.261 Status: XiaomiGateway: New Xiaomi Gateway MP3 Found (7c49eb1d1392)
2019-04-10 17:51:52.263 Status: XiaomiGateway: New Xiaomi Gateway Volume Found (7c49eb1d1392)
2019-04-10 17:51:52.769 Status: XiaomiGateway: New Xiaomi Smart Plug Found (158d00025864ca)
2019-04-10 17:51:52.870 Status: XiaomiGateway: New Xiaomi Smart Plug Found (158d0001e51e00)
2019-04-10 17:51:52.873 Status: XiaomiGateway: New Xiaomi Wireless Switch Found (158d0001f42107)
2019-04-10 17:51:59.988 Status: XiaomiGateway: New Xiaomi Motion Sensor Found (158d00027a3ca1)
2019-04-10 17:52:10.882 Status: XiaomiGateway: New Xiaomi Motion Sensor Found (158d000271c29f)
Then I remove this one, and try again with the new Xiaomi Gateway. Nothing happens. It does not work!
2019-04-10 17:53:55.010 Status: XiaomiGateway (ID=2): stopped
2019-04-10 17:56:52.611 Status: XiaomiGateway (ID=2): Delaying worker startup...
2019-04-10 17:56:57.612 Status: XiaomiGateway (ID=2): Selected as main Gateway
2019-04-10 17:56:57.612 Status: XiaomiGateway (ID=2): Worker started...
2019-04-10 17:56:57.612 Status: XiaomiGateway (ID=2): Using 192.168.1.146 for local IP address.
....and the log stops there.

Conclusion. There is something fishy going on with the new one. Need to find out what.
mattPiratt
Posts: 7
Joined: Wednesday 12 December 2018 6:40
Target OS: OS X
Domoticz version:
Contact:

Re: Cannod add Xiaomi Gateway

Post by mattPiratt »

Quick note in the topic:
- seams on OpenHAB forums they discovered whats the problem: https://community.openhab.org/t/solved- ... /52963/188. Going to check this out soon
- this forums are dying. My assumption while I see problems like this are not discussed here by anyone else, but me and one more person: https://www.domoticz.com/forum/viewtopi ... 22#p210645
mattPiratt
Posts: 7
Joined: Wednesday 12 December 2018 6:40
Target OS: OS X
Domoticz version:
Contact:

Re: Cannod add Xiaomi Gateway

Post by mattPiratt »

Okay, problem solved. It was true. I had some new version on Chineese Xiaomi Gateway V2 with blocked port 9898.

So I started from this place:
$ docker run --rm -v "$(pwd)":/data uzyexe/nmap -sU -p9898,4321 192.168.1.159

Starting Nmap 7.60 ( https://nmap.org ) at 2019-04-11 18:11 GMT
Nmap scan report for 192.168.1.159
Host is up (0.015s latency).

PORT STATE SERVICE
4321/udp closed rwhois
9898/udp closed monkeycom

Nmap done: 1 IP address (1 host up) scanned in 0.71 seconds
And after completing steps from https://community.openhab.org/t/solved- ... /52963/171 I managed to open it again, and now:
$ docker run --rm -v "$(pwd)":/data uzyexe/nmap -sU -p9898,4321 192.168.1.159

Starting Nmap 7.60 ( https://nmap.org ) at 2019-04-11 18:14 GMT
Nmap scan report for 192.168.1.159
Host is up (0.018s latency).

PORT STATE SERVICE
4321/udp open|filtered rwhois
9898/udp open monkeycom

Nmap done: 1 IP address (1 host up) scanned in 1.84 seconds
Then went to Domoticz Hardware, added new gateway as usual, and everything worked like a charm.

Greetings.
B.
denkh
Posts: 1
Joined: Friday 19 April 2019 8:04
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Cannod add Xiaomi Gateway

Post by denkh »

If your gateway’s MAC address starts with 04:CF:8C, there is a good chance that the required port 9898 is closed on your gateway (you can check it with the Nmap utility, using the command sudo nmap - sU {gateway_ip} -p 9898). To fix that issue, you need to do these steps:
1 Find a specific screw bit (like a fork) to open the gateway case.
2 Find a USB-UART cable/module and connect it to your computer.
3 Solder 3 wires - RX, TX and GND like Image.
4 Turn on the gateway (220V).
5 Open a serial terminal application (e.g. PuTTY) and connect to the serial port assigned to the USB-UART module (baudrate: 115200).
6 Wait until the gateway is booted up, connect the RX, TX and GND wires to the UART module (don’t connect the Vcc (power) wire!).
7 You will see all the messages from the gateway.
8 Send the command psm-set network.open_pf 3 (the command has to end with a CR newline character).
9 Check your settings executing the command psm-get network.open_pf to be sure it’s OK.
10 Restart the gateway.

https://www.home-assistant.io/components/xiaomi_aqara
extreemnew
Posts: 1
Joined: Monday 17 December 2018 3:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Cannod add Xiaomi Gateway

Post by extreemnew »

Works just fine for me.
You need to use the serial option of te program Putty...
jeroenb42
Posts: 12
Joined: Wednesday 09 May 2018 10:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Cannod add Xiaomi Gateway

Post by jeroenb42 »

Thanks for the explanation. I bought the v2 hub (after finding out the v3 Aqara does not work with Domoticz). Port 9898 was closed on it so I soldered as described, got in the gateway and was able to
psm-set network.open_pf 3

I verified with
psm-get network.open_pf

and I got the answer 3.
Unfortunately after unplugging and waiting and plugging it back in, port 9898 was still closed. I am on firmware 1.4.1_176.0220. Don't know if that makes a difference.
What am I missing? (btw I have another v2 hub, older which did not need soldering, which works fine in Domoticz)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests