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.
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.