Automating my TV with NFC and Tasker

Listening to podcasts has always been a favourite pastime of mine, and whenever I get the chance to play them over a loudspeaker, my current solution of using a Chromecast alongside the PocketCasts app on my phone works surprisingly well.

However, it comes with a major drawback, keeping the screen on all the time just for audio feels like a waste.

Thankfully, to combat this, my TV does have a “picture off” eco setting, but as with most television user interfaces, this is buried under a pile of menu options only navigable via the remote. Every time I put the podcasts on, I make myself go through this cumbersome procedure to turn the screen off.

There is no shortcut either, if you want to access the eco settings, Sony makes sure you have to work for it.

To alleviate this minor but ever present inconvenience, I somehow stumbled across this page detailing the fact that most modern Sony televisions run a HTTP server that, given a valid request, you can emulate the functions of your remote.

With this in mind, I set off on a small journey to script up my “picture off” woes and remove the burden of endless trips down the horror that plagues most television user interfaces.

Trouble is, I wanted this to work all the time. I didn't want anything to get in the way of me pressing play on the podcasts and turning the screen off. Opening my laptop, finding and running my script wasn't going to cut it.

So I moved everything into a small webserver in Go to execute whenever a GET request arrived at the “eco” endpoint.

func main() {
http.HandleFunc(“/eco”, sendPictureOffCommands())
log.Fatal(http.ListenAndServe(fmt.Sprintf(“:%s”, 1234), nil))
}

This was then deployed to my Raspberry Pi in a Docker container and has been running ever since. To execute it, all I needed to do was fire up a browser on my laptop or phone and hit that address. Even quicker with a bookmark or shortcut.

However, this wasn't enough. I hated the idea of littering my homescreen with bookmarks and having to leave my lovely podcasts application just to do this, so I started to think of ways of making this process smoother.

NFC to the rescue

Apple’s recent announcement of NFC payments triggered an idea, what if I just tapped my phone on an NFC tag to run my script? I often stood in the same place when turning on my TV anyway, so tapping the phone on the way back to wherever I was coming from didn't seem like that much of a hassle.

Trigger app launches the tasker task “TV Picture Off” when an NFC tag is tapped

With that in mind, I ordered some NFC tags and set up a task in Tasker that sends a request to the webserver running on my Pi, then tied this up with the Trigger application to run that task when an NFC tag is tapped.

Now my “streamlined” routine just consists of, turning on my TV, selecting a desired podcast, pressing play, turning around and tapping my phone on the tag nearby, no need to wait. Power is saved (a bit).

Conclusions

While it’s not perfect, and possibly over-engineered, it works for me. I’m amazed how much you can do with Tasker and I'm already thinking of other uses for my spare NFC tags, but for this use case, automating away something that annoyed me constantly was a real treat.

Show your support

Clapping shows how much you appreciated Daniel Harper’s story.