I have a Denon AVR and I would like to have dropdown list cards to change the source and sound mode, exactly like you see when you click on the device, except that I want these to be shown directly on the main page without having to click the device. Ideally, I would also like to use “friendly names” for the sound modes, e.g. Multichannel Stereo instead of MCH STEREO. I’d appreciate any tips on how to accomplish this.
I started by creating dropdown list helpers for source and sound mode and added them to an Entities card, so now it looks good but it’s not functional.
I could create 2 separate automatons for each dropdown. One that triggers on the state of the helper, and the other that triggers on the AVR sound mode change. Is this the right way to go? It feels overly complicated, and I’m also not sure how to avoid an endless loop.
I learned a little about templating and I came up with the following 3 automations to make this work. The first 2 automations change the AVR state in response to the changed state of input_select. The third one updates the input_select to show the correct value in case the AVR is changed by the IR remote.
I haven’t yet figured out how to use friendly names.
- id: '1668888197337'
alias: Denon AVR - change sound mode
description: in response to input_select
trigger:
- platform: state
entity_id: input_select.denon_avr_sound_modes
action:
- service: media_player.select_sound_mode
data:
sound_mode: '{{ trigger.to_state.state }}'
target:
entity_id: media_player.denon_avr_s750h
mode: single
- id: '1668891256897'
alias: Denon AVR - change source
description: in response to input_select
trigger:
- platform: state
entity_id:
- input_select.denon_avr_sources
condition: []
action:
- service: media_player.select_source
data:
source: '{{ trigger.to_state.state }}'
target:
entity_id: media_player.denon_avr_s750h
mode: single
- id: '1668891405700'
alias: Denon AVR - respond to changed state
trigger:
- platform: state
entity_id:
- media_player.denon_avr_s750h
action:
- service: input_select.select_option
data:
option: '{{trigger.to_state.attributes.source}}'
target:
entity_id: input_select.denon_avr_sources
- service: input_select.select_option
data:
option: '{{trigger.to_state.attributes.sound_mode}}'
target:
entity_id: input_select.denon_avr_sound_modes
mode: single
I’m using friendly names by configuring the friendly names in the input_select and transforming them in the automation. For example like this where TV and Chromecast are the friendly names:
alias: Denon input
description: ""
trigger:
- platform: state
entity_id:
- input_select.denon_input
condition: []
action:
- service: media_player.select_source
data:
source: >
{{'MEDIA PLAYER' if is_state('input_select.denon_input', 'Chromecast')}}
{{'CBL/SAT' if is_state('input_select.denon_input', 'TV')}}
target:
entity_id: media_player.denon_avr_x4000
mode: single
Thanks a lot for these automations. My problem is that my Marantz SR6010 sends an input-request without content and the third automations tries to respond the (log)result looks like this:
I wasn’t sure about this but I already thought this. Do you have a solution? - how can I check if the string is empty and just execute the script if it isn’t?
Semantically, yes. Practically, if the value of source is guaranteed to always be a string, then no there shouldn’t be any difference.
If it were not always a string behavior could differ. If for example none was returned rather than an empty string, then the first and last expression would evaluate as true (which you would not want), while the second would fail with an error as you cannot get a length of none.
thank you so much - I recognized that it would be much elegant to check whether the content of the variable is part of input select options. Is there a way to check this?
Look in the traces for the automation for clues to what is going on, and/or in the logs.
If you need more help, provide whatever your screenshot is supposed to show in English. Not many here who can be arsed to try and feed a screenshot into Google translate I would wager…
Thanks for your reply, next time I’ll try to send the screenshot in English. I tried to get some more information by looking at the trace of the automations named in the log. But I have no idea why the receiver is shutting down. I just user the automation “MediaInput-Wohnzimmer” to set the input select of the receiver and the rest is done by the automation of llamafilm Elliott Balsley. I can’t find any power-off-command. Is there a way to get all information home assistant logs (log, traces…) in a document so that I can search in there? Or does anybody know if the receiver logs incoming commands? - Maybe the receiver is broken?