merdok / homebridge-miot

Homebridge plugin for devices supporting the Xiaomi miot protocol
MIT License
388 stars 61 forks source link

retry on error code -30001 and -9999 #358

Closed 0x5e closed 1 year ago

0x5e commented 1 year ago

Fixes #355 Accroding to https://github.com/rytilahti/python-miio/blob/aa2718853455c40b5b8c2a1883019d8cb7a683b4/miio/miioprotocol.py#L272 and https://github.com/rytilahti/python-miio/pull/1363 Some error code is recoverable.

Reproduced and fixed on mesh device 090615.switch.mesw2 with gateway xiaomi.wifispeaker.lx06, using:

miot send $GATEWAY_IP --token $GATEWAY_TOKEN --debug set_properties "[{\"did\":\"$DEVICE_ID\",\"value\":false,\"siid\":2,\"piid\":1}]" \
&& miot send $GATEWAY_IP --token $GATEWAY_TOKEN --debug set_properties "[{\"did\":\"$DEVICE_ID\",\"value\":false,\"siid\":2,\"piid\":1}]" \
&& miot send $GATEWAY_IP --token $GATEWAY_TOKEN --debug set_properties "[{\"did\":\"$DEVICE_ID\",\"value\":false,\"siid\":2,\"piid\":1}]" \
&& miot send $GATEWAY_IP --token $GATEWAY_TOKEN --debug set_properties "[{\"did\":\"$DEVICE_ID\",\"value\":false,\"siid\":2,\"piid\":1}]"

Default retries 1 is enough for processing error code -9999 in my test.

merdok commented 1 year ago

Thanks! That looks good! I think that i will also increase the retries to two for the miot CLI.