Xiaomi gateway sensors not communicate with HA

Ok. If i not list that ip, i got error. ( I mentioned above, please read it )

And i checked the source code ( ? ) this line.
https://raw.githubusercontent.com/lazcad/homeassistant/master/components/xiaomi.py

 data = json.loads(data.decode("ascii"))
                gateway = self.gateways.get(ip_add)
                if gateway is None:
                    _LOGGER.error('Unknown gateway ip %s', ip_add)
                    continue

And now, the debug log is ‘empty’ no error, no warning.
But unfortunately sensor data not arrive

This is the only device that should be under gateways in your config.

Yes, its correct, but if i only list the xiaomi ip, i got error.
And they try to connect the wrong ip:

[xiaomi_gateway] Unknown gateway ip 192.168.1.191

Why ?

Other config is not correct.

Just use this code ONLY

xiaomi_aqara:
   discovery_retry: 10
   gateways:
     - mac: xx
       key: xxx
       host: 192.168.1.135

Replacing the xx’s with the realy values. Don’t put anything in there to do with devices other than the Xiaomi gateway

Ok. I try again.
I will paste the all log here.

Since you only have one Xiaomi gateway you can simplify the config to only use the key: as per the docs. As I mentioned previously, I only use the key. What I hadn’t realised before was that you mistakenly had another non-existent gateway configured which is causing you errors.

xiaomi_aqara:
   discovery_retry: 10
   gateways:
     - key: xxx

I tried everything.

So, i paste the “correct” config:

xiaomi_aqara:
   discovery_retry: 5
   gateways:
     - mac: 04:cf:8c:a9:dd:d1
       key: knehwh3abbiv14qp
       host: 192.168.1.135

And no, the log is:

2019-12-02 09:33:37 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-12-02 09:33:37 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for shelly which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [homeassistant.components.xiaomi_aqara] Expecting 1 gateways
2019-12-02 09:33:41 INFO (SyncWorker_6) [homeassistant.components.xiaomi_aqara] Discovering Xiaomi Gateways (Try 1)
2019-12-02 09:33:41 INFO (SyncWorker_6) [xiaomi_gateway] Xiaomi Gateway 04cf8ca9ddd1 configured at IP 192.168.1.135:9898
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd >> b'{"cmd":"read","sid":"04cf8ca9ddd1"}'
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'gateway', 'sid': '4cf8ca9ddd1', 'short_id': 0, 'data': '{"rgb":0,"illumination":1074,"proto_version":"1.1.2"}'}
2019-12-02 09:33:41 INFO (SyncWorker_6) [xiaomi_gateway] Discovering Xiaomi Devices
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd >> b'{"cmd" : "get_id_list"}'
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd resp << {'cmd': 'get_id_list_ack', 'sid': '04cf8ca9ddd1', 'token': 'HBIIgou3P2gITJnw', 'data': '["158d0002c6c1aa","158d0002892c5c","158d0002892d1d","158d0002c5f3ff","158d0002c5f4d7","158d0002018b7a","158d000395b2e0"]'}
2019-12-02 09:33:41 INFO (SyncWorker_6) [xiaomi_gateway] Found 8 devices
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] Discovery attempt 1/4
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd >> b'{"cmd":"read","sid":"158d0002c6c1aa"}'
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'switch', 'sid': '158d0002c6c1aa', 'short_id': 65170, 'data': '{"voltage":3022}'}
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] Registering device 158d0002c6c1aa, switch as: binary_sensor
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] Discovery attempt 1/4
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd >> b'{"cmd":"read","sid":"158d0002892c5c"}'
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'motion', 'sid': '158d0002892c5c', 'short_id': 61330, 'data': '{"voltage":3015}'}
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] Registering device 158d0002892c5c, motion as: binary_sensor
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] Discovery attempt 1/4
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd >> b'{"cmd":"read","sid":"158d0002892d1d"}'
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'motion', 'sid': '158d0002892d1d', 'short_id': 42517, 'data': '{"voltage":3005}'}
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] Registering device 158d0002892d1d, motion as: binary_sensor
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] Discovery attempt 1/4
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd >> b'{"cmd":"read","sid":"158d0002c5f3ff"}'
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'magnet', 'sid': '158d0002c5f3ff', 'short_id': 33422, 'data': '{"voltage":2975,"status":"close"}'}
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] Registering device 158d0002c5f3ff, magnet as: binary_sensor
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] Discovery attempt 1/4
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd >> b'{"cmd":"read","sid":"158d0002c5f4d7"}'
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'magnet', 'sid': '158d0002c5f4d7', 'short_id': 58988, 'data': '{"voltage":2975,"status":"close"}'}
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] Registering device 158d0002c5f4d7, magnet as: binary_sensor
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] Discovery attempt 1/4
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd >> b'{"cmd":"read","sid":"158d0002018b7a"}'
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d0002018b7a', 'short_id': 28118, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1900","load_power":"0.00"}'}
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] Registering device 158d0002018b7a, plug as: switch
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] Discovery attempt 1/4
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd >> b'{"cmd":"read","sid":"158d000395b2e0"}'
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'motion', 'sid': '158d000395b2e0', 'short_id': 43030, 'data': '{"voltage":3005}'}
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] Registering device 158d000395b2e0, motion as: binary_sensor
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] Discovery attempt 1/4
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd >> b'{"cmd":"read","sid":"04cf8ca9ddd1"}'
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'gateway', 'sid': '4cf8ca9ddd1', 'short_id': 0, 'data': '{"rgb":0,"illumination":1074,"proto_version":"1.1.2"}'}
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] Registering device 04cf8ca9ddd1, gateway as: sensor
2019-12-02 09:33:41 DEBUG (SyncWorker_6) [xiaomi_gateway] Registering device 04cf8ca9ddd1, gateway as: light
2019-12-02 09:33:42 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.updater
2019-12-02 09:33:42 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.yeelight
2019-12-02 09:33:42 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.yeelight
2019-12-02 09:33:42 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.yeelight
2019-12-02 09:33:46 INFO (SyncWorker_6) [xiaomi_gateway] Gateway discovery finished in 5 seconds
2019-12-02 09:33:46 INFO (SyncWorker_6) [xiaomi_gateway] Creating Multicast Socket
2019-12-02 09:33:46 DEBUG (SyncWorker_6) [homeassistant.components.xiaomi_aqara] Gateways discovered. Listening for broadcasts
2019-12-02 09:33:46 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.xiaomi_aqara
2019-12-02 09:33:53 WARNING (MainThread) [homeassistant.setup] Setup of default_config is taking over 10 seconds.
2019-12-02 09:33:56 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:34:06 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:34:16 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:34:17 DEBUG (SyncWorker_5) [homeassistant.components.xiaomi_aqara.switch] Update data from hub: Plug_158d0002018b7a
2019-12-02 09:34:17 DEBUG (SyncWorker_5) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002018b7a"}'
2019-12-02 09:34:17 DEBUG (SyncWorker_5) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d0002018b7a', 'short_id': 28118, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1900","load_power":"0.00"}'}
2019-12-02 09:34:17 DEBUG (SyncWorker_5) [xiaomi_gateway] read_ack << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d0002018b7a', 'short_id': 28118, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1900","load_power":"0.00"}'}
2019-12-02 09:34:17 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Plug_158d0002018b7a: off>: {'voltage': 3600, 'status': 'off', 'inuse': '0', 'power_consumed': '1900', 'load_power': '0.00'}
2019-12-02 09:34:26 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:34:36 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:34:46 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:34:48 DEBUG (SyncWorker_5) [homeassistant.components.xiaomi_aqara.switch] Update data from hub: Plug_158d0002018b7a
2019-12-02 09:34:48 DEBUG (SyncWorker_5) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002018b7a"}'
2019-12-02 09:34:48 DEBUG (SyncWorker_5) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d0002018b7a', 'short_id': 28118, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1900","load_power":"0.00"}'}
2019-12-02 09:34:48 DEBUG (SyncWorker_5) [xiaomi_gateway] read_ack << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d0002018b7a', 'short_id': 28118, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1900","load_power":"0.00"}'}
2019-12-02 09:34:48 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Plug_158d0002018b7a: off>: {'voltage': 3600, 'status': 'off', 'inuse': '0', 'power_consumed': '1900', 'load_power': '0.00'}
2019-12-02 09:34:56 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:35:06 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:35:16 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:35:18 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:35:19 DEBUG (SyncWorker_2) [homeassistant.components.xiaomi_aqara.switch] Update data from hub: Plug_158d0002018b7a
2019-12-02 09:35:19 DEBUG (SyncWorker_2) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002018b7a"}'
2019-12-02 09:35:19 DEBUG (SyncWorker_2) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d0002018b7a', 'short_id': 28118, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1900","load_power":"0.00"}'}
2019-12-02 09:35:19 DEBUG (SyncWorker_2) [xiaomi_gateway] read_ack << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d0002018b7a', 'short_id': 28118, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1900","load_power":"0.00"}'}
2019-12-02 09:35:19 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Plug_158d0002018b7a: off>: {'voltage': 3600, 'status': 'off', 'inuse': '0', 'power_consumed': '1900', 'load_power': '0.00'}
2019-12-02 09:35:26 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:35:36 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:35:46 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:35:50 DEBUG (SyncWorker_3) [homeassistant.components.xiaomi_aqara.switch] Update data from hub: Plug_158d0002018b7a
2019-12-02 09:35:50 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002018b7a"}'
2019-12-02 09:35:50 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d0002018b7a', 'short_id': 28118, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1900","load_power":"0.00"}'}
2019-12-02 09:35:50 DEBUG (SyncWorker_3) [xiaomi_gateway] read_ack << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d0002018b7a', 'short_id': 28118, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1900","load_power":"0.00"}'}
2019-12-02 09:35:50 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Plug_158d0002018b7a: off>: {'voltage': 3600, 'status': 'off', 'inuse': '0', 'power_consumed': '1900', 'load_power': '0.00'}
2019-12-02 09:35:56 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:36:06 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:36:15 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:36:21 DEBUG (SyncWorker_4) [homeassistant.components.xiaomi_aqara.switch] Update data from hub: Plug_158d0002018b7a
2019-12-02 09:36:21 DEBUG (SyncWorker_4) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002018b7a"}'
2019-12-02 09:36:21 DEBUG (SyncWorker_4) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d0002018b7a', 'short_id': 28118, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1900","load_power":"0.00"}'}
2019-12-02 09:36:21 DEBUG (SyncWorker_4) [xiaomi_gateway] read_ack << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d0002018b7a', 'short_id': 28118, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1900","load_power":"0.00"}'}
2019-12-02 09:36:21 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Plug_158d0002018b7a: off>: {'voltage': 3600, 'status': 'off', 'inuse': '0', 'power_consumed': '1900', 'load_power': '0.00'}
2019-12-02 09:36:25 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:36:35 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:36:45 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:36:52 DEBUG (SyncWorker_8) [homeassistant.components.xiaomi_aqara.switch] Update data from hub: Plug_158d0002018b7a
2019-12-02 09:36:52 DEBUG (SyncWorker_8) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002018b7a"}'
2019-12-02 09:36:52 DEBUG (SyncWorker_8) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d0002018b7a', 'short_id': 28118, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1900","load_power":"0.00"}'}
2019-12-02 09:36:52 DEBUG (SyncWorker_8) [xiaomi_gateway] read_ack << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d0002018b7a', 'short_id': 28118, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1900","load_power":"0.00"}'}
2019-12-02 09:36:52 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Plug_158d0002018b7a: off>: {'voltage': 3600, 'status': 'off', 'inuse': '0', 'power_consumed': '1900', 'load_power': '0.00'}
2019-12-02 09:36:55 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:37:05 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:37:08 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:37:15 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:37:23 DEBUG (SyncWorker_6) [homeassistant.components.xiaomi_aqara.switch] Update data from hub: Plug_158d0002018b7a
2019-12-02 09:37:23 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002018b7a"}'
2019-12-02 09:37:23 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d0002018b7a', 'short_id': 28118, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1900","load_power":"0.00"}'}
2019-12-02 09:37:23 DEBUG (SyncWorker_6) [xiaomi_gateway] read_ack << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d0002018b7a', 'short_id': 28118, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1900","load_power":"0.00"}'}
2019-12-02 09:37:23 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Plug_158d0002018b7a: off>: {'voltage': 3600, 'status': 'off', 'inuse': '0', 'power_consumed': '1900', 'load_power': '0.00'}
2019-12-02 09:37:25 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:37:35 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:37:45 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:37:51 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:37:54 DEBUG (SyncWorker_2) [homeassistant.components.xiaomi_aqara.switch] Update data from hub: Plug_158d0002018b7a
2019-12-02 09:37:54 DEBUG (SyncWorker_2) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002018b7a"}'
2019-12-02 09:37:54 DEBUG (SyncWorker_2) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d0002018b7a', 'short_id': 28118, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1900","load_power":"0.00"}'}
2019-12-02 09:37:54 DEBUG (SyncWorker_2) [xiaomi_gateway] read_ack << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d0002018b7a', 'short_id': 28118, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1900","load_power":"0.00"}'}
2019-12-02 09:37:54 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Plug_158d0002018b7a: off>: {'voltage': 3600, 'status': 'off', 'inuse': '0', 'power_consumed': '1900', 'load_power': '0.00'}
2019-12-02 09:37:55 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:38:05 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:38:15 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:38:25 DEBUG (SyncWorker_1) [homeassistant.components.xiaomi_aqara.switch] Update data from hub: Plug_158d0002018b7a
2019-12-02 09:38:25 DEBUG (SyncWorker_1) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002018b7a"}'
2019-12-02 09:38:25 DEBUG (SyncWorker_1) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d0002018b7a', 'short_id': 28118, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1900","load_power":"0.00"}'}
2019-12-02 09:38:25 DEBUG (SyncWorker_1) [xiaomi_gateway] read_ack << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d0002018b7a', 'short_id': 28118, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1900","load_power":"0.00"}'}
2019-12-02 09:38:25 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Plug_158d0002018b7a: off>: {'voltage': 3600, 'status': 'off', 'inuse': '0', 'power_consumed': '1900', 'load_power': '0.00'}
2019-12-02 09:38:25 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:38:35 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:38:45 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:38:55 ERROR (Thread-3) [xiaomi_gateway] Unknown gateway ip 192.168.1.191
2019-12-02 09:38:56 DEBUG (SyncWorker_6) [homeassistant.components.xiaomi_aqara.switch] Update data from hub: Plug_158d0002018b7a
2019-12-02 09:38:56 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d0002018b7a"}'
2019-12-02 09:38:56 DEBUG (SyncWorker_6) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d0002018b7a', 'short_id': 28118, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1900","load_power":"0.00"}'}
2019-12-02 09:38:56 DEBUG (SyncWorker_6) [xiaomi_gateway] read_ack << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d0002018b7a', 'short_id': 28118, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1900","load_power":"0.00"}'}
2019-12-02 09:38:56 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Plug_158d0002018b7a: off>: {'voltage': 3600, 'status': 'off', 'inuse': '0', 'power_consumed': '1900', 'load_power': '0.00'}

Well I don’t understand why it is logging an IP address of 192.168.1.191 The start of that log is fine, it sees the correct gateway at .135 and the devices paired with it. Where in you code (anywhere) is it getting the .191 from?

No.

My FULL config.yaml :

default_config:

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

# Example configuration.yaml entry
zone:
  - name: Home
    latitude: 47.5378879
    longitude: 19.2692841
    radius: 250
    icon: mdi:home
    
  - name: Work
    latitude: 47.518845
    longitude: 19.111152
    radius: 250
    icon: mdi:worker

xiaomi_aqara:
   discovery_retry: 5
   gateways:
       key: knehwh3abbiv14qp

weather:
  - platform: darksky
    api_key: !secretKey
    mode: daily

media_player:
  - platform: samsungtv
    host: 192.168.1.168
  
shelly:
  discovery: true  #add all devices (default)
  sensors:
    - all #show all sensors
  devices:  #configure devices
    - id: "E008fc"
      name: Nappali
    - id: "E008cf"
      name: Háló

yeelight:
  devices:
    192.168.1.106:
      name: Kitchen led.1
      transition: 1000
      model: strip1
      use_music_mode: False #(defaults to False)
      save_on_change: False #(defaults to True)
      
    192.168.1.207:
      name: Kitchen led.2
      transition: 1000
      model: strip1
      use_music_mode: False #(defaults to False)
      save_on_change: False #(defaults to True)
      
    192.168.1.188:
      name: Bed side lamp
      transition: 1000
      model: strip1
      use_music_mode: False #(defaults to False)
      save_on_change: False #(defaults to True)
      
life360:
  accounts:
    - username: !secretKey
      password: !secretKey
      
logger:
  default: warn
  logs:
    homeassistant.components.xiaomi_aqara: debug
    homeassistant.components.sensor.xiaomi_aqara: debug
    homeassistant.components.switch.xiaomi_aqara: debug
    homeassistant.components.binary_sensor: debug
    xiaomi_gateway: debug

The xiaomi gateway part is still slightly wrong. You are missing the ‘-’ in front of key (see my post above), but that shouldn’t be causing the .191 from popping up.

Hm.
Now, the config is ( i copied from : https://www.home-assistant.io/integrations/xiaomi_aqara/#one-gateway )

xiaomi_aqara:
  discovery_retry: 5
  gateways:
    - key: knehwh3abbiv14qp

And the log is:

2019-12-02 10:04:13 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for shelly which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-12-02 10:04:13 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-12-02 10:04:17 DEBUG (SyncWorker_8) [homeassistant.components.xiaomi_aqara] Expecting 1 gateways
2019-12-02 10:04:17 INFO (SyncWorker_8) [homeassistant.components.xiaomi_aqara] Discovering Xiaomi Gateways (Try 1)
2019-12-02 10:04:18 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.updater
2019-12-02 10:04:18 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.yeelight
2019-12-02 10:04:18 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.yeelight
2019-12-02 10:04:18 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.yeelight
2019-12-02 10:04:22 INFO (SyncWorker_8) [xiaomi_gateway] Gateway discovery finished in 5 seconds
2019-12-02 10:04:22 INFO (SyncWorker_8) [homeassistant.components.xiaomi_aqara] Discovering Xiaomi Gateways (Try 2)
2019-12-02 10:04:26 WARNING (MainThread) [homeassistant.setup] Setup of xiaomi_aqara is taking over 10 seconds.
2019-12-02 10:04:27 INFO (SyncWorker_8) [xiaomi_gateway] Gateway discovery finished in 5 seconds
2019-12-02 10:04:27 INFO (SyncWorker_8) [homeassistant.components.xiaomi_aqara] Discovering Xiaomi Gateways (Try 3)
2019-12-02 10:04:29 WARNING (MainThread) [homeassistant.setup] Setup of default_config is taking over 10 seconds.
2019-12-02 10:04:32 INFO (SyncWorker_8) [xiaomi_gateway] Gateway discovery finished in 5 seconds
2019-12-02 10:04:32 INFO (SyncWorker_8) [homeassistant.components.xiaomi_aqara] Discovering Xiaomi Gateways (Try 4)
2019-12-02 10:04:37 INFO (SyncWorker_8) [xiaomi_gateway] Gateway discovery finished in 5 seconds
2019-12-02 10:04:37 INFO (SyncWorker_8) [homeassistant.components.xiaomi_aqara] Discovering Xiaomi Gateways (Try 5)
2019-12-02 10:04:42 INFO (SyncWorker_8) [xiaomi_gateway] Gateway discovery finished in 5 seconds
2019-12-02 10:04:42 ERROR (SyncWorker_8) [homeassistant.components.xiaomi_aqara] No gateway discovered
2019-12-02 10:04:42 ERROR (MainThread) [homeassistant.setup] Setup failed for xiaomi_aqara: Integration failed to initialize.

Other error from hassio:
Login attempt or request with invalid authentication from 192.168.1.191

Why?

try changing the discovery_retry to 10. Are you sure that key is correct?

homeassistant:
  auth_providers:
    - type: trusted_networks
      trusted_networks:
        - 192.168.1.0/24

Yes, it is.
I can Turn on/off the gateway light…
Just sensors not provide datas.

I will reset my router.

OHH MY!!!

I found this in home assitant UI:
what

The xiaomi device chrased with Shelly h&t sensor :open_mouth:

The shelly config is:

shelly:
discovery: true #add all devices (default)
sensors:
- all #show all sensors
devices: #configure devices
- id: “E008fc”
name: Nappali
- id: “E008cf”
name: Háló

And the UI i found the ‘wrong’ ip.

Maybe this couse the issue… ?
My shelly devices ip is:
192.168.1.168 and 192.168.1.141 based on the shelly mobile app.

I would be setting a fixed IP adress for the Shelly in you router (if not done already) and reboot everything

Fun, because is fixed. :frowning:
In the shelly mobile app, the IP is : 192…168.1.168
And in the router ui… Same…

How did you solve your problem ? I got this problem too. swich is working but not sensors for doors, motions.

Please read this then ask your question How to help us help you - or How to ask a good question

Hi, I would like to ask if it is compatible with (lumi.gateway.v2). Both 9898 and 4321 ports are close and I am trying to open. The port location for the serial communication is different from the others as seen from the picture. Will it be able to integrate it to Home Assistant. Btw the model is DGNWG01LM and manage to get the key from the app.