Changing Channels using Siri & Home Assistant

If you've got Home Assistant running in your home with an Apple TV added as a media player and the HomeKit integration you can use the RESTful integration (default integration in Home Assistant), Channels API, and Home Assistant Scripts to change channels using Siri via the button on your Apple TV remote, iPhone, Apple Watch, etc.

Below is a snippet from my configuration YAML file in Home Assistant showing the RESTful command structure. Once you have these setup for whatever channels you want to change to via Siri you can then create a Script in Home Assistant and have it run the steps to send the command to the Apple TV api.

You will need to make sure your HomeKit integration is setup with Scripts as part of your Domains to include in the integration setup. If you have this setup correctly when you restart your Home Assistant server these Scripts you will create will show up as switches in the Apple Home app. If you don't get them to show up there then something is incorrect with your HomeKit bridge setup in Home Assistant.

I have my scripts setup so that it always starts the Channels app on my Apple TV, that way even if the Apple TV is in another app on my Apple TV it will still tune to the channel I speak while pressing the Siri button on my remote. My prior hack from a couple of years ago using HomeBridge did not work directly on the Apple TV remote via the Siri button, this setup works from any Apple device w/ Siri enabled, even the remote.

Works pretty sweet for me so far, hopefully I've given enough info here to point anyone interested in the right direction. Just make sure you have the following integrations setup and working in your Home Assistant before you start: Apple TV (must also be paired to your Apple TV), HomeKit (must also be added to the Home app on a Mac, iPhone, or iPad).

Configuration YAML example:
rest_command:
abc:
url: "http://192.168.2.247:57000/api/play/channel/2.1"
method: post
cbs:
url: "http://192.168.2.247:57000/api/play/channel/5.1"
method: post
nbc:
url: "http://192.168.2.247:57000/api/play/channel/4.1"
method: post
fox:
url: "http://192.168.2.247:57000/api/play/channel/17.1"
method: post
pbs:
url: "http://192.168.2.247:57000/api/play/channel/8.1"
method: post

Home Assistant Script Example:
-Name: use whatever phrase you want to use for Siri to activate the script such as "ABC" or "ABC Channel", however you want to speak it. Mode = Single (default)

-Sequence: (Action 1). Action Type = Call service, Service = Media player: Turn on, use the Choose entity button to select your Apple TV (Action 2). Action Type = Play media, Select media player = your Apple TV, select the Channels app using the Pick media button. (Action 3). Action Type = Call service, Service = RESTful Command:abc (whatever you called it in the YAML setup above).

Click SAVE SCRIPT button

Wash, rinse, repeat for each channel you want to create a Script for - just make sure you have entered the necessary RESTful command in your YAML configuration file before creating the Script for a channel!

Awesome!

These might help things be a bit easier or cleaner.

1 Like