Change Channels using Homebridge & Siri

In between taking down the Christmas tree and decorations this afternoon I decided to play around with my Homebridge setup and see if I could figure out how to get a plugin to change the channels via Siri voice command using the Channels API.

After much trial and error I have a setup that seems to be working, although as of yet I can't do this via Siri on the AppleTV itself. So far I have only been able to get it to work via iPhone and Apple Watch. I have only added a few channels to the setup but I can invoke Siri on my watch and say "ABC" or "ESPN" and it changes the Channels app to the right station.

This was done using a Homebridge plugin named HTTP Switch which can be found at the link below, you will need to have Homebridge up and running or install it prior to installing this plugin. Do some searching on Google on how to set this up if you've never done it before as I am not going to try and explain that here.

https://github.com/Supereg/homebridge-http-switch

If you get Homebridge & HTTP Switch all installed without issue you can use the config.json file below as a basis for re-creating this yourself. You can change the "name" just below the "bridge" section to whatever you like, the "username" can be anything you want but is formatted like a MAC address and can only use A-F and 0-9, letters must be in CAPS. You can change the "port" and "pin" if you like, just make sure the "pin" is formatted the same.

The only other thing you would need to change is the IP address of your AppleTV that is running Channels and the channel number to match your setup. Just remember this won't work unless you already have the AppleTV on and currently have the Channels app open.

Good luck, and enjoy.

{
"bridge": {
"name": "Channels",
"username": "xx:xx:xx:xx:xx:xx",
"port": 51826,
"pin": "031-01-001"
},
"accessories": [{
"accessory": "HTTP-SWITCH",
"name": "ESPN",
"switchType": "stateless",
"onUrl": {
"url": "http://192.168.1.15:57000/api/play/channel/1205",
"method": "POST"
}
},
{
"accessory": "HTTP-SWITCH",
"name": "ABC",
"switchType": "stateless",
"onUrl": {
"url": "http://192.168.1.15:57000/api/play/channel/1002",
"method": "POST"
}
},
{
"accessory": "HTTP-SWITCH",
"name": "NBC",
"switchType": "stateless",
"onUrl": {
"url": "http://192.168.1.15:57000/api/play/channel/1004",
"method": "POST"
}
},
{
"accessory": "HTTP-SWITCH",
"name": "CBS",
"switchType": "stateless",
"onUrl": {
"url": "http://192.168.1.15:57000/api/play/channel/1005",
"method": "POST"
}
},
{
"accessory": "HTTP-SWITCH",
"name": "FOX",
"switchType": "stateless",
"onUrl": {
"url": "http://192.168.1.15:57000/api/play/channel/1017",
"method": "POST"
}
},
{
"accessory": "HTTP-SWITCH",
"name": "PBS",
"switchType": "stateless",
"onUrl": {
"url": "http://192.168.1.15:57000/api/play/channel/1008",
"method": "POST"
}
},
{
"accessory": "HTTP-SWITCH",
"name": "HGTV",
"switchType": "stateless",
"onUrl": {
"url": "http://192.168.1.15:57000/api/play/channel/1492",
"method": "POST"
}
},
{
"accessory": "HTTP-SWITCH",
"name": "PREVIOUS",
"switchType": "stateless",
"onUrl": {
"url": "http://192.168.1.15:57000/api/previous_channel",
"method": "POST"
}
}
]
}

1 Like

So.....

After playing with this some more the voice part of this doesn't work so great all the time, with some channels like "HGTV" seems to be fine but with "ESPN" Siri is confused and doesn't know what to do or starts the ESPN radio app on my phone.

This does however work to setup buttons within the Home app to change channels directly without going thru the guide but that use case scenario is limited for me. Not sure this totally meets what I set out to do, but getting closer.

After further investigation and testing it seems if the command to Siri starts with "switch" then this works pretty well, even with ESPN. Additionally if you start the command to Siri with “switch” then you can use Siri via the AppleTV remote to switch channels using this method.

If I say "switch ESPN on" then the setup I outlined in the config.json file works pretty well. Will have to add other channels to see if any others create a problem but for now the keyword here seems to be "switch" based on the info found below.

https://github.com/nfarina/homebridge/wiki/Siri-commands

Nice one, this is also possible without needing to use Homebridge, using the official Shortcuts app on iOS 12.

You can use the "Get Contents of URL" action to trigger the API calls. Here's an example: https://www.icloud.com/shortcuts/66f2fb41debf45ff9a291ac186ef2c2a

By using the Shortcuts app you can assign your own Siri Shortcut to each one, which might be more reliable than using the Homekit names.

1 Like

Yep, I tried that method as well before I got the homebridge setup working. That method is definitely easier to implement if you don’t already have homebridge setup for sure but I don’t recall that working with Siri on the AppleTV remote like this method does. I could be wrong.

Always good to have options.

1 Like

Oh, cool, I never thought about trying HomeKit commands on the AppleTV Siri, so does that work? As I read your original post as it only working on iPhone and Apple Watch Siri?

Yes, with this setup in Homebridge you can use the Siri button on the AppmeTV remote to change channels.

I found that the word “switch” is a keyword in Homekit, so I can change to a channel on the AppleTV remote by holding the Siri button and saying “switch on ESPN”. You just have to have whatever channels you want to use this for setup in the homebridge config.json file.

1 Like

This is very cool. I just set up homebridge this week, so I'll give this a try soon. A couple of (probably dumb) questions...

  1. What would happen if you named your channels with the word "watch"? So if it was "Watch ABC" rather than "ABC". I wonder if you could then just tell Siri to "Watch ABC" and it would work?
  2. I guess this really only works well for one Apple TV. If you had more than one, you would probably have to say something like "Switch (or watch) Family Room ABC"?
  3. Is the DVR accessible through the API? It would be awesome if you could pull that up with voice commands. Otherwise it is generally several steps to get to it.

The Siri Shortcuts we have published do just that. And you can have Siri use any voice command you want. The shortcuts are also prepared to handle more than one device. After triggering one, it will ask which tv you want it to happen on

I will definitely have to check that out! But Siri shortcuts only work on the iPhone, not the Apple Watch, right? I'm really trying to be as lazy as possible here. It's too difficult to get up to get the remote. And it is also too difficult to pull my phone out of my pocket. :slight_smile:

They work on your watch as long as they don’t require user input, like if you had to pick the tv as described above.

Where do I get to the Siri Shortcuts that are published for Channels? Can’t find them on my Siri settings section or the app!

You can get them here: https://getchannels.com/api/#siri-shortcuts

They’re not in the iOS app because they don’t actually happen in or for the iOS app. They’re for interacting with the Apple TV app and use the Channels API.

1 Like

So this is weird. I downloaded the commercial skip Siri shortcut. I changed the IP address to my Apple TV. When I run the test in the shortcut, it works. But when I tell Siri to skip the commercials, I get this... IMG_9E4E4ECA1276-1

Whoa. Something is up with that. I’ll take a look at it tonight.

1 Like

Hi @maddox - Just wondering if you ever had a chance to look into this? I can't get any of the shortcuts to work correctly. I double and triple verified the IP address of my Apple TV. When I try Pause Channels, Siri response with "It's Paused" but nothing actually happens. And as shown in my screen shot above, it tries to open Music when I try to skip commercials.

Ahhh... I figured it out. You have to do more than just add the shortcut. You also have to edit it and add it to Siri! It's working now!

Yeah, when you add the Shortcuts, you'll be walked through adding your devices. You need to add their names and ip addresses so it knows how to talk to them.

If you only add 1, it'll just work. If you add more than 1, it will prompt you to pick a device you'd like to do the action on.

For what it's worth, one of the Shortcuts had weird extra actions in it. I'm not sure which one it was. But I've reposted all of them. So if you were seeing weird stuff before, just delete them in your Shortcuts app and add them again from our website.

Just remember to follow the instructions when you add the shortcut and set your variables :slight_smile:

@tplowman5 - Do you think it is possible to use your Channels bridge to trigger a homekit scene? For example, I would like to start the "Movie Night" scene when I watch a DVR'ed episode of The Walking Dead.