Change Channels using Homebridge & Siri


#1

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"
}
}
]
}


#2

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.


#3

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


#4

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.


#5

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.


#6

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?


#7

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.