Add google Home command to triggering entity_if of a template sensor

building on the radio setup in Chromecast Radio with station and player selection by @Bob_NL, I’ve expanded a bit and have wakeup and sleep radios. to cut it short, I have a few sensors like below, that use templates with nested templates…

      wakeup_radio_state:
        friendly_name: Wakeup radio state
        entity_id:
          - sensor.wakeup_radio
          - sensor.wakeup_radio_state
          - sensor.wakeup_radio_volume
          - input_select.radio_station_wakeup
          - input_select.wakeup_radio
          - timer.increase_volume_delay
        value_template: >
          {{states(states('sensor.wakeup_radio'))}}
        icon_template: >
          {% set state = states('sensor.wakeup_radio_state') %}
          {% if state == 'playing' %} mdi:play
          {% elif state == 'stopped' %} mdi:stop
          {% elif state == 'paused' %} mdi:pause
          {% elif state == 'off' %} mdi:power-off
          {% else %} mdi:play-pause
          {% endif %}

and

      wakeup_radio_volume:
        friendly_name: Wakeup radio volume
        entity_id:
          - input_boolean.wakeup_radio
          - input_boolean.snooze
          - input_select.radio_station_wakeup
          - input_select.wakeup_radio
          - sensor.wakeup_radio
          - sensor.wakeup_radio_state
          - sensor.wakeup_radio_volume
          - timer.increase_volume_delay
        value_template: >
          {{state_attr(states('sensor.wakeup_radio'),'volume_level')|float|round(2) }}

use the state of:

      wakeup_radio:
        friendly_name: Wakeup radio
        value_template: >
          {% set state = states('input_select.wakeup_radio') %}
          {% if state in ['Woonkamer','Hobbykamer','Hall', 'Master bedroom'] %} media_player.googlehome_{{(state)|lower|replace(' ','_')}}
          {% elif state == 'Gym' %} media_player.chromecastaudio_gym
          {% else %} group.broadcast
          {% endif %}

the state sensor needs the many entity_ids to change state accordingly, and I have it working as it should now finally, thanks to @lolouk44 who taught me the nesting was possible in the first place…

I now have a new challenge: When I say ‘hey Google, stop’ to my playing media_player it won’t change the state of the above sensors… Now how could I add that to the triggering entity_id’s of the sensor? Or isn’t this possible.

1 Like