Hi all,
First I need to describe what I want to achieve;
I have a Yamaha receiver and I’ve made buttons for the different sources (AV1, AV2 etc). As long as I use HA to control the receiver, it all works. The challenge rises when the ladies in the household choose to use the remote. Then I want to update the buttons in HA.
Example (image tells it all I hope):
If I press ‘Apple TV’ it turns on and change the source to AV2. The button updates.
But, if anyone use the remote, I need HA to check at all times ‘what is the current source in use and update the corresponded button with status’. If somebody press AV2 on the remote, I want ‘Apple TV’ button to be turned on.
I was planning to use an automation for this, and up to the trigger part it is easy
I use input_bolean’s to control on/off combined with switches for the buttons.
entity_id: input_boolean.yamaha_chromecast_on_off
entity_id: input_boolean.yamaha_appletv_on_off
entity_id: input_boolean.yamaha_btaudio_on_off
The rule should be:
IF source == AV2 THEN turn_on input_boolean.yamaha_appletv_on_off and turn_off input_boolean.yamaha_chromecast_on_off AND input_boolean.yamaha_btaudio_on_off
IF source == AV3 THEN turn_on input_boolean.yamaha_chromecast_on_off and turn_off input_boolean.yamaha_btaudio_on_off AND input_boolean.yamaha_appletv_on_off
IF source == AV4 THEN turn_on input_boolean.yamaha_btaudio_on_off and turn_off input_boolean.yamaha_chromecast_on_off AND input_boolean.yamaha_appletv_on_off
This worked in template editor to check what is concidered TRUE:
- platform: template
value_template: "{{ (state_attr('media_player.yamaha', 'source')) == 'AV2' }}"
- platform: template
value_template: "{{ (state_attr('media_player.yamaha', 'source')) == 'AV3' }}"
- platform: template
value_template: "{{ (state_attr('media_player.yamaha', 'source')) == 'AV4' }}"
So automation should start with:
- alias: Yamaha Status sjekk
trigger:
- platform: template
value_template: "{{ (state_attr('media_player.yamaha', 'source')) == 'AV2' }}"
- platform: template
value_template: "{{ (state_attr('media_player.yamaha', 'source')) == 'AV3' }}"
- platform: template
value_template: "{{ (state_attr('media_player.yamaha', 'source')) == 'AV4' }}"
From here I’m quite stuck
Is this possible to resolve within a single automation, perhaps using service_template
and data_template
??