xiaomi_fan icon indicating copy to clipboard operation
xiaomi_fan copied to clipboard

[miio.miioprotocol] Got error when receiving: timed out

Open ptc opened this issue 4 years ago • 10 comments

After setting everything up, I get the following error on HA restart:

[miio.miioprotocol] Got error when receiving: timed out

I retrieved a token using miio tool. Connected the fan to WiFi afterwards using mihome app. Any hints?

ptc avatar May 15 '20 14:05 ptc

I have the same problem too using the same steps.

Is it because I have updated to the latest firmware?

myfirstfrost avatar Jun 02 '20 08:06 myfirstfrost

I am on running on the same issue. Getting the token using miio discover worked, but it does not work in HA.

I am currently trying get more debug messages.

Any news on that? Did you get it working?

ichmachnixichgucknur avatar Jun 04 '20 14:06 ichmachnixichgucknur

This is what I get when enabling debug level:

2020-06-04 16:52:34 DEBUG (SyncWorker_19) [miio.protocol] Unable to decrypt, returning raw bytes: b''
2020-06-04 16:52:34 DEBUG (SyncWorker_19) [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\x06\xf5\xad\xac\x00\x00"\x83' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = b'\x06\xf5\xad\xac' (total 4)
            ts = 1970-01-01 02:27:15
        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)
2020-06-04 16:52:34 DEBUG (SyncWorker_19) [miio.miioprotocol] Discovered 06f5adac with ts: 1970-01-01 02:27:15, token: b'ffffffffffffffffffffffffffffffff'
2020-06-04 16:52:34 DEBUG (SyncWorker_19) [miio.miioprotocol] 192.168.178.38:54321 >>: {'id': 3040, 'method': 'get_prop', 'params': ['angle']}
2020-06-04 16:52:39 ERROR (SyncWorker_19) [miio.miioprotocol] Got error when receiving: timed out
2020-06-04 16:52:39 INFO (MainThread) [custom_components.xiaomi_miio_fan.fan] Got exception while fetching the state: No response from the device , _retry=10```

ichmachnixichgucknur avatar Jun 04 '20 14:06 ichmachnixichgucknur

Unable to decrypt means the token is incorrect.

I also tried miio discover (via fans own WiFi) and that returns a token. But: after the fan is configured to your own WiFi, the token changes. Since miio discover doesn’t return a code after WiFi client configuration, I found recovering a (new) token from a phone backup works OK.

mpepping avatar Jun 26 '20 18:06 mpepping

@mpepping i cant even connect it to Mi Home on Android. I use China mainland as region but it never finds the fan? Any ideas? I tried setting wifi info manually with miio configure then it will connect to my WiFi but i cannot access it with cli tools like miio. Token is unknown: ` INFO Discovering devices. Press Ctrl+C to stop.

Device ID: ID Model info: Unknown Address: 192.168.0.205 Token: ??? Support: Unknown `

BenjaminFaal avatar Jun 26 '20 19:06 BenjaminFaal

The Token: ??? line means that the fan is connected to your wifi. It won't expose a token, which is wise because otherwise anyone on your network can potentially read the token.

I used these steps to recover the token from a phone backup: https://python-miio.readthedocs.io/en/latest/discovery.html#tokens-from-backups

Changing regions to China should not be necessary. Just add the Fan in Mihome via the ➕ sign.

Hope this helps.

mpepping avatar Jun 26 '20 19:06 mpepping

@mpepping i understand that part but my Android phone cant seem to find the fan. What are recommended settings?

BenjaminFaal avatar Jun 26 '20 19:06 BenjaminFaal

I used an iPhone. It shows an 'add new device' button in the app. Do you have Bluetooth enabled? Think that's used to initially 'find' the Fan.

mpepping avatar Jun 26 '20 19:06 mpepping

Yes with bluetooth enabled and i also tried on other devices.

BenjaminFaal avatar Jun 26 '20 19:06 BenjaminFaal

Don’t know man. Press and hold both buttons on the fan until beep for factory defaults and retry? Maybe reinstall the app as wel.

mpepping avatar Jun 26 '20 19:06 mpepping