Automatically Stop Channels when your TV turns off with Home Assistant

api
home-assistant
home-automation

#1

Now that the Channels component has shipped inside Home Assistant, you can get started with awesome automations that include Channels.

One of the most obvious ones you might want to create is to auto stop playback of Channels when your TV is turned off. With Channels feeling so much like the TV we’ve been used to for so many years, I think we all have seen that other people in the house don’t think to stop playback before turning off the TV.

With this simple automation you can not only preserve a tuner, but save some bandwidth around your home network too.

One prerequisite is that you need to already have a way to detect the ON/OFF state of your TV inside Home Assistant. This might mean via a Harmony Hub, or a smart TV.

Ok, let’s get on with it.

automation:
  - alias: Stop Channels
    trigger:
      platform: state
      entity_id: media_player.living_room_tv
      to: 'off'
    action:
      - service: media_player.media_stop
        data:
          entity_id: media_player.living_room_channels

It’s as simple as that. When your Living Room TV changes to an off state, it will attempt to stop your Living Room Channels media player. :tada:

You might be wondering what happens if Channels isn’t running. As you know, if you run Channels on an Apple TV the Channels API is only available when the app is actually running. Welp, nothing happens. It’s fine. The Channels Home Assistant component attempts to stop it and just fails gracefully. So if it’s running, it’ll stop playback, if not, no big deal.

I hope this shows how cool the Channels API can be and help you do things that aren’t normally possible. Home automation lets you do the things products weren’t designed to do, or just plain can’t do.


Clean up Home Assistant automations for multiple Channels apps in your house
#2

I think I lost the plot. What is Home Assistant? Is that like Google Home?


#3

:see_no_evil: I should have linked it.

Home Assistant is a software home automation hub that has over 1000 integrations. It’s very easy to set it up and you add the devices in your home using configuration files. It’s easy to get started and is very very powerful.

Once you get a few of your devices inside Home Assistant you can start creating automations for all of them. It lets you let them all talk to each other.


#4

thanks for this! I just set this up using my the Harmony component state. I also added a condition for channels to be playing to not fire off a needless api call whenever the off command is sent.


#5

I dont get it to work as of now. No idea why.
I want to turn off channels playback when I turn off my power switch.
I replaced your TV with my switch.tv, but my “Wohnzimmer_Channels” does not seem to get triggered to shut down.

I need to put this into the automations.yaml, right?


#6

If you have any other helpful tricks with Home Assistant and Channels, please share