Automation with value_template based on 2 entities

I’m trying to finetune a automation i made for automatic start of a Harmony activity. I want to start a specific Harmony activity when i start the YouTube app on my Nvidia Shield TV. It works great when i only have 1 entity state in value_template but i don’t know how to combine 2 entity states. I now use the following code (which doesn’t work) :

- alias: ATV_YouTube
  trigger:
  - platform: template
    value_template: "{{ is_state_attr('media_player.nvidia_shield_tv', 'app_name', 'YouTube') }} & {{ is_state_attr('remote.woonkamer', 'current_activity', 'PowerOff') }}"
  action:
    service: remote.turn_on
    data:    
      entity_id: remote.woonkamer
      activity: "Films Kijken"

Can someone help me with the correct formatting for what i’m trying to achieve.

Could move one of the entity value_templates to the condition: block.

Assuming you want the automation to trigger when both of those attributes have those values:

value_template: "{{ is_state_attr('media_player.nvidia_shield_tv', 'app_name', 'YouTube') and is_state_attr('remote.woonkamer', 'current_activity', 'PowerOff') }}"
1 Like

Thanks ! That was exactly what i was looking for. It works now !

1 Like