{"action":"created","issue":{"url":"https://api.github.com/repos/home-assistant/home-assistant/issues/16407","repository_url":"https://api.github.com/repos/home-assistant/home-assistant","labels_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/16407/labels{/name}","comments_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/16407/comments","events_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/16407/events","html_url":"https://github.com/home-assistant/home-assistant/issues/16407","id":356659354,"node_id":"MDU6SXNzdWUzNTY2NTkzNTQ=","number":16407,"title":"Xiaomi Gateway not discovered and port 9898 4321 closed","user":{"login":"hoedha12","id":42829231,"node_id":"MDQ6VXNlcjQyODI5MjMx","avatar_url":"https://avatars0.githubusercontent.com/u/42829231?v=4","gravatar_id":"","url":"https://api.github.com/users/hoedha12","html_url":"https://github.com/hoedha12","followers_url":"https://api.github.com/users/hoedha12/followers","following_url":"https://api.github.com/users/hoedha12/following{/other_user}","gists_url":"https://api.github.com/users/hoedha12/gists{/gist_id}","starred_url":"https://api.github.com/users/hoedha12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoedha12/subscriptions","organizations_url":"https://api.github.com/users/hoedha12/orgs","repos_url":"https://api.github.com/users/hoedha12/repos","events_url":"https://api.github.com/users/hoedha12/events{/privacy}","received_events_url":"https://api.github.com/users/hoedha12/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-09-04T05:38:07Z","updated_at":"2019-01-02T06:38:20Z","closed_at":"2018-10-08T07:11:45Z","author_association":"NONE","body":"<!-- READ THIS FIRST:\r\n- If you need additional help with this template please refer to https://www.home-assistant.io/help/reporting_issues/\r\n- Make sure you are running the latest version of Home Assistant before reporting an issue: https://github.com/home-assistant/home-assistant/releases\r\n- Do not report issues for components if you are using custom components: files in <config-dir>/custom_components\r\n- This is for bugs only. Feature and enhancement requests should go in our community forum: https://community.home-assistant.io/c/feature-requests\r\n- Provide as many details as possible. Paste logs, configuration sample and code into the backticks. Do not delete any text from this template!\r\n-->\r\n\r\n**Home Assistant release with the issue:**\r\n<!--\r\n- Frontend -> Developer tools -> Info\r\n- Or use this command: hass --version\r\n-->\r\n0.77.2\r\n\r\n**Last working Home Assistant release (if known):**\r\nNot known.\r\n\r\n**Operating environment (Hass.io/Docker/Windows/etc.):**\r\n<!--\r\nPlease provide details about your environment.\r\n-->\r\nHass.io running on Ubuntu Desktop 18.04.1 LTS in Lenovo m93p machine (i5 CPU)\r\n\r\n**Component/platform:**\r\n<!--\r\nPlease add the link to the documentation at https://www.home-assistant.io/components/ of the component/platform in question.\r\n-->\r\nxiaomi_aqara\r\n\r\n**Description of problem:**\r\nCannot get hassio to discover my gateway automatically. When I specified the gateway IP, hassio returned error of cannot communicating with my gateway. I've followed all the steps in the docs page, and also the troubleshooting steps there to no avail. In addition, I have : \r\n1. Tried 3 different routers : Tenda AC6 wireless router (which I confirm with their customer service as multicast-capable); Huawei HG8245A modem-wireless router from my ISP; and D-LINK L7-N-R2000 wireless router.\r\n2. Tried in hass.io and homeasssistant in docker\r\n3. Tried in VMware installation under Win10\r\n4. Tried switching from wi-fi to ethernet cable\r\n\r\nThe gateway and sensors all are working fine in Mi Home app. Mi Home app is in latest version. Once I got the gateway, I've updated the gateway to the latest firmware of **1.4.1_157.0143** before adding sensors. \r\n\r\n**Problem-relevant `configuration.yaml` entries and (fill out even if it seems unimportant):**\r\n```\r\nxiaomi_aqara:\r\n  gateways:\r\n    - mac: 7811dcb37d__\r\n      key: hh9wckv6rwyd3b__\r\n      host: 192.168.0.108\r\n\r\nlogger:\r\n  default: warn\r\n  logs:\r\n    homeassistant.components.xiaomi_aqara: debug\r\n    homeassistant.components.sensor.xiaomi_aqara: debug\r\n    homeassistant.components.switch.xiaomi_aqara: debug\r\n    homeassistant.components.binary_sensor: debug\r\n    xiaomi_gateway: debug\r\n```\r\nI've tried empyting the mac, gave it semicolon, remove 'host',etc, still get the same error. Here is the debug log : \r\n```\r\n2018-09-04 05:19:50 DEBUG (SyncWorker_12) [homeassistant.components.xiaomi_aqara] Expecting 1 gateways\r\n2018-09-04 05:19:50 INFO (SyncWorker_12) [homeassistant.components.xiaomi_aqara] Discovering Xiaomi Gateways (Try 1)\r\n2018-09-04 05:19:50 INFO (SyncWorker_12) [xiaomi_gateway] Xiaomi Gateway 7811dcb37d98 configured at IP 192.168.0.108:9898\r\n2018-09-04 05:19:50 DEBUG (SyncWorker_12) [xiaomi_gateway] _send_cmd >> b'{\"cmd\":\"read\",\"sid\":\"7811dcb37d98\"}'\r\n2018-09-04 05:20:00 WARNING (MainThread) [homeassistant.setup] Setup of xiaomi_aqara is taking over 10 seconds.\r\n2018-09-04 05:20:00 ERROR (SyncWorker_12) [xiaomi_gateway] Cannot connect to Gateway\r\n2018-09-04 05:20:00 ERROR (SyncWorker_12) [xiaomi_gateway] No data in response from hub None\r\n2018-09-04 05:20:00 INFO (SyncWorker_12) [xiaomi_gateway] Discovering Xiaomi Devices\r\n2018-09-04 05:20:00 DEBUG (SyncWorker_12) [xiaomi_gateway] _send_cmd >> b'{\"cmd\" : \"get_id_list\"}'\r\n2018-09-04 05:20:10 ERROR (SyncWorker_12) [xiaomi_gateway] Cannot connect to Gateway\r\n2018-09-04 05:20:10 INFO (SyncWorker_12) [xiaomi_gateway] Discovering Xiaomi Devices\r\n2018-09-04 05:20:10 DEBUG (SyncWorker_12) [xiaomi_gateway] _send_cmd >> b'{\"cmd\" : \"get_id_list\"}'\r\n2018-09-04 05:20:20 ERROR (SyncWorker_12) [xiaomi_gateway] Cannot connect to Gateway\r\n2018-09-04 05:20:20 INFO (SyncWorker_12) [xiaomi_gateway] Discovering Xiaomi Devices\r\n2018-09-04 05:20:20 DEBUG (SyncWorker_12) [xiaomi_gateway] _send_cmd >> b'{\"cmd\" : \"get_id_list\"}'\r\n2018-09-04 05:20:30 ERROR (SyncWorker_12) [xiaomi_gateway] Cannot connect to Gateway\r\n2018-09-04 05:20:30 INFO (SyncWorker_12) [xiaomi_gateway] Discovering Xiaomi Devices\r\n2018-09-04 05:20:30 DEBUG (SyncWorker_12) [xiaomi_gateway] _send_cmd >> b'{\"cmd\" : \"get_id_list\"}'\r\n2018-09-04 05:20:40 ERROR (SyncWorker_12) [xiaomi_gateway] Cannot connect to Gateway\r\n2018-09-04 05:20:40 INFO (SyncWorker_12) [xiaomi_gateway] Discovering Xiaomi Devices\r\n2018-09-04 05:20:40 DEBUG (SyncWorker_12) [xiaomi_gateway] _send_cmd >> b'{\"cmd\" : \"get_id_list\"}'\r\n2018-09-04 05:20:50 ERROR (SyncWorker_12) [xiaomi_gateway] Cannot connect to Gateway\r\n2018-09-04 05:20:55 INFO (SyncWorker_12) [xiaomi_gateway] Gateway discovery finished in 5 seconds\r\n2018-09-04 05:20:55 INFO (SyncWorker_12) [xiaomi_gateway] Creating Multicast Socket\r\n2018-09-04 05:20:55 DEBUG (SyncWorker_12) [homeassistant.components.xiaomi_aqara] Gateways discovered. Listening for broadcasts\r\n2018-09-04 05:20:55 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.xiaomi_aqara\r\n```\r\nHere is the nmap scan of port 9898 and 4321 of gateway IP : \r\n```\r\nroot@hoedha-m93p:/# nmap -sU 192.168.0.108 -p 9898,4321\r\n\r\nStarting Nmap 7.60 ( https://nmap.org ) at 2018-09-04 12:26 WIB\r\nNmap scan report for 192.168.0.108\r\nHost is up (0.12s latency).\r\n\r\nPORT     STATE  SERVICE\r\n4321/udp closed rwhois\r\n9898/udp closed monkeycom\r\nMAC Address: 78:11:DC:B3:7D:98 (Xiaomi Electronics,co.)\r\n\r\nNmap done: 1 IP address (1 host up) scanned in 13.77 seconds\r\nroot@hoedha-m93p:/# nmap -sU 192.168.0.108 -p 9898,4321\r\n\r\nStarting Nmap 7.60 ( https://nmap.org ) at 2018-09-04 12:27 WIB\r\nNmap scan report for 192.168.0.108\r\nHost is up (0.16s latency).\r\n\r\nPORT     STATE  SERVICE\r\n4321/udp closed rwhois\r\n9898/udp closed monkeycom\r\nMAC Address: 78:11:DC:B3:7D:98 (Xiaomi Electronics,co.)\r\n\r\nNmap done: 1 IP address (1 host up) scanned in 13.96 seconds\r\nroot@hoedha-m93p:/# nmap -sU 192.168.0.108 -p 9898,4321\r\n\r\nStarting Nmap 7.60 ( https://nmap.org ) at 2018-09-04 12:29 WIB\r\nNmap scan report for 192.168.0.108\r\nHost is up (0.0024s latency).\r\n\r\nPORT     STATE  SERVICE\r\n4321/udp closed rwhois\r\n9898/udp closed monkeycom\r\nMAC Address: 78:11:DC:B3:7D:98 (Xiaomi Electronics,co.)\r\n\r\nNmap done: 1 IP address (1 host up) scanned in 13.56 seconds\r\n```\r\n\r\nAnd here is the tcpdump at the restart of hassio : \r\n```\r\nroot@hoedha-m93p:/# tcpdump -A -i eno1  udp port 4321 or udp port 9898\r\ntcpdump: verbose output suppressed, use -v or -vv for full protocol decode\r\nlistening on eno1, link-type EN10MB (Ethernet), capture size 262144 bytes\r\n12:33:26.302007 IP hoedha-m93p.60529 > 192.168.0.108.9898: UDP, length 35\r\nE..?q.@.@.Gw...e...l.q&..+.^{\"cmd\":\"read\",\"sid\":\"7811dcb37d98\"}\r\n12:33:36.317824 IP hoedha-m93p.60529 > 192.168.0.108.9898: UDP, length 23\r\nE..3s.@.@.D....e...l.q&....R{\"cmd\" : \"get_id_list\"}\r\n12:33:46.330963 IP hoedha-m93p.60529 > 192.168.0.108.9898: UDP, length 23\r\nE..3v.@.@.B....e...l.q&....R{\"cmd\" : \"get_id_list\"}\r\n12:33:56.344100 IP hoedha-m93p.60529 > 192.168.0.108.9898: UDP, length 23\r\nE..3y.@.@.>....e...l.q&....R{\"cmd\" : \"get_id_list\"}\r\n12:34:06.357121 IP hoedha-m93p.60529 > 192.168.0.108.9898: UDP, length 23\r\nE..3. @.@.6x...e...l.q&....R{\"cmd\" : \"get_id_list\"}\r\n12:34:16.370379 IP hoedha-m93p.60529 > 192.168.0.108.9898: UDP, length 23\r\nE..3..@.@.1....e...l.q&....R{\"cmd\" : \"get_id_list\"}\r\n12:34:26.382218 IP hoedha-m93p.53878 > 224.0.0.50.4321: UDP, length 15\r\nE..+..@...>....e...2.v.....h{\"cmd\":\"whois\"}\r\n^C\r\n7 packets captured\r\n7 packets received by filter\r\n0 packets dropped by kernel\r\n```\r\n\r\n**Traceback (if applicable):**\r\n```\r\n\r\n```\r\n\r\n**Additional information:**\r\n"},"comment":{"url":"https://api.github.com/repos/home-assistant/home-assistant/issues/comments/450794763","html_url":"https://github.com/home-assistant/home-assistant/issues/16407#issuecomment-450794763","issue_url":"https://api.github.com/repos/home-assistant/home-assistant/issues/16407","id":450794763,"node_id":"MDEyOklzc3VlQ29tbWVudDQ1MDc5NDc2Mw==","user":{"login":"Haraguroicha","id":1715541,"node_id":"MDQ6VXNlcjE3MTU1NDE=","avatar_url":"https://avatars0.githubusercontent.com/u/1715541?v=4","gravatar_id":"","url":"https://api.github.com/users/Haraguroicha","html_url":"https://github.com/Haraguroicha","followers_url":"https://api.github.com/users/Haraguroicha/followers","following_url":"https://api.github.com/users/Haraguroicha/following{/other_user}","gists_url":"https://api.github.com/users/Haraguroicha/gists{/gist_id}","starred_url":"https://api.github.com/users/Haraguroicha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Haraguroicha/subscriptions","organizations_url":"https://api.github.com/users/Haraguroicha/orgs","repos_url":"https://api.github.com/users/Haraguroicha/repos","events_url":"https://api.github.com/users/Haraguroicha/events{/privacy}","received_events_url":"https://api.github.com/users/Haraguroicha/received_events","type":"User","site_admin":false},"created_at":"2019-01-02T06:38:20Z","updated_at":"2019-01-02T06:38:20Z","author_association":"NONE","body":"I think the issue still exists, because there have the new model of mi-gateway[1] which doesn't open 9898 and 4321 port for receive UDP packets, and only the device mac address match following prefix are okay to communicate[2] with home-assistant through 9898 and 4321 port\r\n\r\n1. `28:6c:07`\r\n2. `34:CE:00`\r\n3. `28:6C:07`\r\n\r\nand other wise mac address out of this list will not got any response\r\n\r\nReferences:\r\n1. [How to check the model][1]\r\n2. [How to check the mac address is match?][2]\r\n\r\n[1]: https://community.openhab.org/t/openhab2-xiaomi-mi-gateway-does-not-respond/52963/77\r\n[2]: https://community.openhab.org/t/openhab2-xiaomi-mi-gateway-does-not-respond/52963/82"}}
{"actor":{"display_login":"Haraguroicha"}}