Closed dilruacs closed 5 years ago
The submitted PR contained the error checking mentioned in part 1 of the solution.
I did not implement part 2 yet. Apparently the stored json contains a placeholder for the commands
array, but the json is stored at a point in time where the array isn't populated yet.
I am still pondering on the right place in the code to make sure this is populated.
The right point would be something after send_authentication
I'm going to solve this issue together with the v4 implementation because I'm going to refactor quite some things anyway
This issue is a bit annoying, as it causes a problem for every first buttonpress after the start of home assistant.
If the device happens to be turned on, the first "play" command will fail too, because the commands
array isn't populated.
I propose populating the array in the register()
function at the end, if registration_result == AuthenicationResult.SUCCESS
, so the SonyDevice
object is complete right from the start and can be stored as a whole directly
Fixed in #16
Turning on the device is done with
SonyDevice.power(true)
:The function
send_command
tries to fetch a list of available commands from the device:When the device is powered off (in this case a BDP-S3200), this will fail because the call to
/getRemoteCommandList
is denied:This will cause the
commands
array to remain empty, in turn causing aKeyError: 'Power'
if a power on is tried throughsend_command("Power")
Once the device has been turned on and the
commands
array is populated, the problem is solved.Following solutions are available:
update_commands()
did not return a populated array (should be checked in all circumstances, there could be other causes we didn't think of yet)