Playing Around With Python and My TV

I recently noticed that my Sharp AQUOS TV had a section in the owner's manual describing "IP Control." Now you might think that this would be something about DRM, but it actually describes commands you can send the TV via TCP/IP in order to remote control it. Nifty!

The manual seems to suggest using telnet to do this, but I've found that it doesn't work. But sending the commands via Python does work.

So let's get to some basic code!

import socket

# Change these to match your TV's configuration
tv_ip = ""
user = "user"
password = "pass"

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

s.connect((tv_ip, 10002))

# Log in to the TV
s.send(user + "\r" + password + "\r")
# Receive the prompts (will be "Login:\r\nPassword:")

# At this point, we can send commands.

What commands can we send? Well, it turns out quite a few, along with every button on the remote control. But let's start by just muting the TV:

s.send("MUTE1   \r")

The command should mute the TV and then receive an OK status response from the TV. To unmute it, use the same command with 2 instead of 1. Or use 0 to toggle.


Possibly more useful is changing the input. This is neat because you can change to any input instantly, without going through the input menu.

s.send("IAVD1   \r")

That changes to HDMI1 on most TVs. (This may differ depending on model, on the ones I've seen, 1-4 are HDMI 1-4, 5 is component, 6 and 7 are Video 1 and 2, and 8 is PC. The numbers correspond directly to the numbers on the input menu.)

I'm not going to list all the commands (they're in the owner's manual), but there's quite a bit you can do with the TV using this.

So, now what? My plan now is to use CherryPy to write a web interface to control my TV.