My previous TV was controlled by Indigo using iRed and IRtrans modules. But my new TV has an RS232 interface and my dealer gave me the specifications to control the TV.
First challenge was to connect the RS232 interface from the TV in the living room to the Indigo mini in another room.
Because iRed has support for the Global Caché modules, I bought a GC-100 module.
But iRed support for RS232 is still limited and can only send data to the TV. Getting a response back or getting TV initiated data into the Mac is not possible right now. The iTest program from Martijn Rijnbeek is capable of doing all the things I need, but unfortunately is not scriptable, so I can't integrate that with Indigo.
That's when I decided it was time to start learning Python and write my own interface. With the help from Jay and Perry The Cynic I managed to get Indigo connected to my TV.
Communicating with the GC-100 module is easy. See this example script I wrote for dnomode:
- Code: Select all
# Echo GC100 Example
import socket
indigo.server.log("Send string to TV")
HOST = "<ip address GC-100>" # The remote host
PORT = "4999" # The same port as used by the server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, int(PORT)))
s.send('\xDF\x80p\xF8\x02\x00\x006' + chr(13))
data = s.recv(512)
dataVariable = indigo.variables["TVData"]
dataVariable.value = data
dataVariable.replaceOnServer()
s.close()
Of course my script is a bit bigger than that because it has a lot more functionality. More on that later.
So what can I do with my new TV?
- Control lights and appliances in the house using the TV's remote control
- Control the SqueezeBox music player using the TV's remote control
- See the outside temperature
What can I do with my Mac?
- Switch on the SqueezeBox and TV to listen to music
- Control the settings of the TV like channel and volume
- See what TV channel is being watched on TV
What can I do with my iPhone/iPad?
- Switch on the SqueezeBox and TV to listen to music
(The SqueezeBox is connected to the TV to play music. I no longer have a separate amplifier for that.)
But enough words. It's picture time!
This menu is created by the Mac mini and sent to the TV using the RS232 module.
Using the green key on the TV remote I can switch on the "Vloerlamp".
The TV will send this command to the Mac mini and then Indigo will do it's magic to switch the light on.
Next the status on the TV screen is updated so I can see that the light is on.
(Or I can take a look at the light
)
The red key will switch the light off and again the status is updated on the TV screen.
Here's another example where it shows lights and appliances in the garden. But it also shows the outside temperature.
The entire menu structure that I use on the TV is stored into Indigo variables.
Some variables define menu lines, other variables define switchable devices, dimmable lights and even variable values.
This means that I can change the way the menu looks without changing a line of code.
The downside is that it the menu variables are not easy to read.
Here are some examples from the menu on the picture above:
TVM064000 = S;Vijververlichting;Pond
TVM065000 = V;Buitentemperatuur;AWTemperature;°
The variable names TVM064000 and TVM065000 contain information on their position in the entire menu hierarchy. The first position in the value tells what kind of menu line data is stored. "S" stands for a switchable device and it has a display name and an Indigo device name.
The "V" stands for a variable and this one also has a display name, Indigo variable name and an optional suffix for the variable value. In this case the centigrades symbol.
The latest changes I made are sending messages to the TV.
When there is someone at the front door, a messages pops up.
And for those of you who remember my
dryer topic: not only does my wife get an e-mail when the dryer is ready, but now also a message shows up on the TV.
This is another approach on integrating Indigo and other components. The biggest advantage for us is that we now can use the TV remote to control lights and devices in our house. We don't use iOS devices for that.