rytilahti / python-miio

Python library & console tool for controlling Xiaomi smart appliances
https://python-miio.readthedocs.io
GNU General Public License v3.0
3.62k stars 547 forks source link

Gateway not responding #680

Open vers4ce opened 4 years ago

vers4ce commented 4 years ago

I am querying my gateway with miiocli -d gateway --ip [ip] --token [token] info

My result is as follows

INFO:miio.cli:Debug mode active DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b'' DEBUG:miio.miioprotocol:Got a response: Container: data = Container: data = b'' (total 0) value = b'' (total 0) offset1 = 32 offset2 = 32 length = 0 header = Container: data = b'!1\x00 \x00\x00\x00\x00\x0f\xc2\xfe\xc8^\x9d\xb3\xb8' (total 16) value = Container: length = 32 unknown = 0 device_id = unhexlify('0fc2fec8') ts = 2020-04-20 14:37:44 offset1 = 0 offset2 = 16 length = 16 checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16) DEBUG:miio.miioprotocol:Discovered 0fc2fec8 with ts: 2020-04-20 14:37:44, token: b'ffffffffffffffffffffffffffffffff' DEBUG:miio.miioprotocol:10.8.1.206:54321 >>: {'id': 1, 'method': 'miIO.info', 'params': []} DEBUG:miio.miioprotocol:Retrying with incremented id, retries left: 200000 DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b'' DEBUG:miio.miioprotocol:Got a response: Container: data = Container: data = b'' (total 0) value = b'' (total 0) offset1 = 32 offset2 = 32 length = 0 header = Container:\ data = b'!1\x00 \x00\x00\x00\x00\x0f\xc2\xfe\xc8^\x9d\xb3\xb9' (total 16) value = Container: length = 32 unknown = 0 device_id = unhexlify('0fc2fec8') ts = 2020-04-20 14:37:45 offset1 = 0 offset2 = 16 length = 16 checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)

and so on, up to the point I manually open the app on my phone in which case I get an answer:

DEBUG:miio.miioprotocol:Discovered 0fc2fec8 with ts: 2020-04-20 14:47:30, token: b'ffffffffffffffffffffffffffffffff' DEBUG:miio.miioprotocol:10.8.1.206:54321 >>: {'id': 6162, 'method': 'miIO.info', 'params': []} DEBUG:miio.miioprotocol:Retrying with incremented id, retries left: 199642 DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b'' DEBUG:miio.miioprotocol:Got a response: Container: data = Container: data = b'' (total 0) value = b'' (total 0) offset1 = 32 offset2 = 32 length = 0 header = Container: data = b'!1\x00 \x00\x00\x00\x00\x0f\xc2\xfe\xc8^\x9d\xb6\x03' (total 16) value = Container: length = 32 unknown = 0 device_id = unhexlify('0fc2fec8') ts = 2020-04-20 14:47:31 offset1 = 0 offset2 = 16 length = 16 checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16) DEBUG:miio.miioprotocol:Discovered 0fc2fec8 with ts: 2020-04-20 14:47:31, token: b'ffffffffffffffffffffffffffffffff' DEBUG:miio.miioprotocol:10.8.1.206:54321 >>: {'id': 6263, 'method': 'miIO.info', 'params': []} DEBUG:miio.miioprotocol:10.8.1.206:54321 (ts: 2020-04-20 14:47:31, id: 6263) << {'partner_id': '', 'id': 6263, 'code': 0, 'message': 'ok', 'result': {'hw_ver': 'Linux', 'fw_ver': '3.4.6_132', 'ap': {'ssid': '[ssid]', 'bssid': '[bssid]'}, 'netif': {'localIp': '[ip]', 'mask': '255.255.255.0', 'gw': '[gw]'}, 'model': 'lumi.gateway.mieu01', 'mac': '[mac]', 'token': '[token]', 'life': 201844}} Model: lumi.gateway.mieu01 Hardware version: Linux Firmware version: 3.4.6_132 Network: {'localIp': '[ip]', 'mask': '255.255.255.0', 'gw': '[gw]'} AP: {'ssid': '[ssid]', 'bssid': '[bssid]'}

I used the 5.4.45 method to discover the token but it doesn't seem to be able to communicate unless there is some extra step taken when I open the app on Android

vers4ce commented 4 years ago

Changing lazy_discover in gateway.py to false completely fixed this in one of my gateways, but not my second one. Will update.

rytilahti commented 4 years ago

The gateway support is very raw, I did test some of the commands years ago, and @starkillerOG implemented GatewayAlarm which is likely the only properly tested interface. Feel free to open PRs if you are interested in better support, I'm not personally using the device so... See #470 and #633 for some background infos and discussions on that.

starkillerOG commented 4 years ago

@vers4ce did you get both of your gateways working? HomeAssistant now supports the gateway and work is beeing done to also support subdevices.

I see you have a diffrent gateway model than I know: lumi.gateway.mieu01 does that actully work with the xioami_miio implementation? If so I will add it to the zeroconf discovery