Smart Pause Automation for Multiple Media Devices

Hey everyone, I’m trying to set up a ‘smart pause’ button in my smart home setup, and I could really use some help or insights from the community! Here’s the situation: I have a TV with a Kodi Box for live TV, a Roku for streaming services like Netflix and Hulu, and a Chromecast for music and miscellaneous apps. I want a single button press to pause whatever media device I’m currently using.

I’ve been experimenting with input_select to track which device I’m using and then triggering the appropriate pause script. Here’s what I’ve tried so far:

yaml
brendans_bedroom_media_pause:
sequence:
- service: script.turn_on
data:
entity_id:
{% if states.input_select.brendan_bedroom_active_media_player.state == “Roku” %}
script.brendans_roku_play_pause
{%- elif states.input_select.brendan_bedroom_active_media_player.state == “Chromecast” %}
script.brendans_chromecast_play_pause
{%- elif states.input_select.brendan_bedroom_active_media_player.state == “Kodi” %}
script.brendans_kodi_play_pause
{% else %}
script.brendans_roku_play_pause
{% endif %}

I’ve also tried using is_state instead of direct state comparison, but the results haven’t been consistent. The ‘else’ condition doesn’t seem to work as reliably, and sometimes none of the scripts run at all. I’m curious if others have tackled similar automation challenges and what approaches have worked for you.

Has anyone successfully integrated multiple media devices with a single control system? Any tips or alternative methods would be greatly appreciated! I’m really looking forward to getting this automation up and running smoothly. Thanks in advance for your help!