Skipping Live Commercials with the API & Home Assistant! (And without comskip!)

Just wanted to say THANK YOU for the API! While watching the World Series tonight (Go Astros!), I found myself wishing there was a way to mute, not only the audio during commercials, but the video as well...

And then, I had a great idea: what if I could use the API to pause playback during the commercial breaks, skip forward after a preset length of time & auto-resume playback?

Well, with Home Assistant & the Channels API, I did just that! To have a physical remote, I repurposed a Zigbee Hue dimmer switch (with support for up to 8 different commands!) & assigned one of the buttons to an automation which does the following:

  1. /api/toggle_mute to mute audio
  2. /api/toggle_pause to pause playback
  3. "Wait for time to pass" (set for 3 minutes)
  4. /api/seek/175 (Most ad breaks are around 3 to 3 1/2 minutes, so I found 175 seconds is a nice sweet spot most of the time)
  5. "Wait for time to pass" (set for 250ms, just to allow for any network hiccups!)
  6. /api/toggle_pause to resume playback
  7. /api/toggle_mute to unmute audio

And done! I don't even have to see or think about the ads! Occasionally, the ad breaks run short or long, so two of the buttons on my remote are configured to issue /api/seek/15 & /api/seek/-10 commands, so I can jump around if needed. But for the most part, I've been timing it right & it will automatically resume playback just as the inning is starting! (For the record, this all seems to work best if you keep playback 15-30 seconds behind the live broadcast to allow for a buffer... but the tradeoff is so worth it to me!).

FYI, CURL commands need to be preconfigured in configuration.yaml under a shell_command section. Here's a couple of examples:

livingroomtogglepause: /usr/bin/curl -X POST 'ipaddresshere:57000/api/toggle_pause'
livingroomforwardlongskip: /usr/bin/curl -X POST 'ipaddresshere:57000/api/seek/175'

etc, etc... Then, call your CURL command in a Home Assistant automation with Call Service -> Shell command: commandname

FYI, I'm doing this on Apple TV. Make sure you give your device a static IP! And actually... my Zigbee remote is set to issue commands to multiple Apple TVs at once! It's a pretty good way to keep playback on multiple TVs (mostly!) in sync.

(And Devs, if you happen to see this... :sweat_smile: I acknowledge it might not be possible because... "Apple", but... I use my iPad as a portable TV a LOT & this is exactly the kind of use case I have for wanting the API on my iPad & iPhone... Having a physical, custom remote for Channels (that can even control multiple devices at once) is INCREDIBLE!!)

6 Likes

I love posts like this, thanks for sharing the ideas and inspiration!

Love this :heart:

Check out the Channels component to add it and control your Channels clients directly without the curl commands.

1 Like

Thanks! Actually, I do have the Channels component configured, but I thought it only offers a subset of the API? I have other automations configured to tune to a specific channel, jump to a navigation section, channel up/down, etc... Hence: curl commands. (Unless there's something I'm missing? :sweat_smile:)

Plus, I guess I'm geeky enough that I enjoy being able to control Channels from Terminal... :laughing: Actually, I'm hoping for Stream Deck deal over the holidays. Having a more advanced remote, with channel logos & lots of buttons, would be a dream come true! (So glad macOS Shortcuts lets you run shell scripts! The Channels API really is incredibly useful... :wink:)

Ahh, that's true. I thought it had mute in there. We need to update it, but the problem is that it's built using an old style and they won't accept an update unless we practically re-write it, which isn't something we have time for. If you know anyone that's willing to help, for a bounty, we'd be happy to work with someone on it.

Ah, I wish I knew someone to recommend... I'm just glad I've managed to get it working like this! It took some trial and error, so I was hoping to spare others the trouble. :wink:

And how did I miss toggle_mute?! That's fantastic! Thanks for mentioning that. I just tried it & it works perfectly, so that simplifies things even more. Reading through the API list again is giving me new ideas...

Please do share pics and details if / when that comes to fruition. Sounds like a super cool project! What a great idea :slight_smile:

We should all be watching tv like Mission Control operators!