JeffLIrion / python-androidtv

Communicate with an Android TV or Fire TV device via ADB over a network.
MIT License
170 stars 59 forks source link

Retry power command on error #330

Closed matejdro closed 1 year ago

matejdro commented 1 year ago

On Nvidia Shield, power service can sometimes reply with "Failed to write while dumping service". When this happens, power state will be output as None, even when device is turned on. This can cause Home Assistant to randomly switch playing -> standby -> playing momentarily.

As a workaround, this PR attempts to detect the error and re-send the command when it happens.

matejdro commented 1 year ago

Any tips on where to add extra tests to improve code coverage?

JeffLIrion commented 1 year ago

I'd put it here: https://github.com/JeffLIrion/python-androidtv/blob/428e835ee14ff7f0f274513a2d386c9cc22ab6b5/tests/test_basetv_async.py#L407

Also, please make the same changes in the non-async code.