Added configurable volume step and fixed replaced volume commands#71
Conversation
…abled will replace volume up/down and mute commands
…upported (all profiles actually)
zehnm
left a comment
There was a problem hiding this comment.
Profile changes and volume commands are not required and need to be reverted. This was already implemented in the device profiles.
See:
- Issue #72
- profile features (present in all profiles), e.g.:
{
"...": "",
"features": [
"...",
"volume_up_down",
"mute_toggle",
"..." ]
}MEDIA_PLAYER_COMMANDSin profiles.py
media_player.Commands.VOLUME_UP.value: "VOLUME_UP",
media_player.Commands.VOLUME_DOWN.value: "VOLUME_DOWN",
media_player.Commands.MUTE_TOGGLE.value: "VOLUME_MUTE",
send_media_player_commandmethod in AndroidTv passes through the Android TV keycodes
Using Google Cast for volume control needs to be an option since it doesn't always work.
|
Hi Markus, 1/ Volume commands were duplicated in media_player.Features.VOLUME,
media_player.Features.VOLUME_UP_DOWN,
media_player.Features.MUTE_TOGGLE,I just cleaned those 3 duplicate lines. 2/ To prevent volume commands to be replaced when chromecast is disabled, I just added this condition in if android_tv.device_config.use_chromecast:
# If chromecast disabled, default mapping will be used
if cmd_id == media_player.Commands.VOLUME_UP:
return await android_tv.volume_up()
if cmd_id == media_player.Commands.VOLUME_DOWN:
return await android_tv.volume_down()
if cmd_id == media_player.Commands.MUTE_TOGGLE:
return await android_tv.volume_mute_toggle()
if cmd_id == media_player.Commands.VOLUME:
return await android_tv.volume_set(params.get("volume"))
if cmd_id == media_player.Commands.SEEK:
return await android_tv.media_seek(params.get("media_position", 0))Maybe there is a cleaner way to handle 2 sets of volume commands :
But to keep using standard volume buttons while enabling chromecast, I added 3 simple commands in all profiles : "KEY_VOLUME_UP",
"KEY_VOLUME_DOWN",
"KEY_VOLUME_MUTE"
...
"KEY_VOLUME_UP": {
"keycode": "VOLUME_UP"
},
"KEY_VOLUME_DOWN": {
"keycode": "VOLUME_DOWN"
},
"KEY_VOLUME_MUTE": {
"keycode": "VOLUME_MUTE"
}So what you suggest (sorry I prefer to write everything to be sure to understand) :
|
No problem:
What exactly do you mean? The Feel free to only add your new volume step feature and I'll fix the rest. |
This check is now replaced by a test condition on the new option android_tv.send_media_player_command(cmd_id)I have added a new option in the setup flow (for init/reconfigure) and mapped it in the driver to trigger chromecast volume commands when the option is enabled. And I reverted changes on profile files |
zehnm
left a comment
There was a problem hiding this comment.
Almost there!
After those changes it looks ready to merge.
Then I'll add the missing language texts and start cleaning up a few things, like de-duplicating the same setting options in the setup flow (as in the Denon AVR integration) and using better response codes in case of Chromecast failures.
|
Done |
zehnm
left a comment
There was a problem hiding this comment.
Thanks for the PR.
Verified with Shield TV, hooked up to AVR with HDMI:
- Normal volume control works again
- Chromecast volume control also works
It doesn't seem to make a difference if set to 5% or 10%. It either changes the volume by +/- 2.5 or 3. Likely one of the many Chromecast / HDMI CEC quirks...
Fixes #72
Hi Markus,
I just added a configurable volume step for Android TV, like in Denon or some other integrations.
I updated the config flow and the model
Also I have fixed 2 problems :
Thanks