Using your tivo remote to turn off and on multiple devices
==========================================================

On the ozTivo Uploads area are a couple of very useful tools:

 - power_ir_tools
 - trickey

power_ir_tools allows you to send arbitrary Infrared bursts out the IR blaster
all under program control. Its main goal is to be able to turn on your Set top
Box automatically.

trickey is a tool that watches what keys you're pressing on the tivo remote,
and if a certain combination of keys are pressed in quick succession (like the 
Select Play Select backdoors) then you can kick off a script or some program.

I thought it'd be a good idea to combine these two tools so I could turn my 
amp and TV on without trying to find all the relevant remotes (I've been
on the verge of getting a universal remote for ages ... ).

So here's the basic idea; press a special combo of key presses on the tivo 
remote and magically your tv is turned on and switches to the correct video
input, and then turns your AMP on and switches its input as appropriate.
Conversely another key combo turns the tv and amp off.

Whats in this tarball and where it goes
=======================================

send_code.sh should be put into /hack/bin
pioneer.codes and sony.codes are just example files with IR codes in them. Put 
these in /hack/etc

convert_ccf_to_tivo.awk - This "tries" to convert a text dump of a Pronto CCF
file into a simpler format that send_code.sh will understand. I used a tool 
called ccf2efc to convert a Pronto CCF file into plain text. Then I copied the
text file to the tivo (you could do it a lot faster on a PC), and did something
like:

  mawk -f convert_ccf_to_tivo.awk pronto_ccf_dump.txt > transonic.codes

You'll still need to hand edit the output file. On some CCF files, it kinda
just works. On others it requires a lot of hand editing. The idea is to end up
with a text file that consists of lines like:

  Power_on:0 48 1 34 5 6 7 67 57   ....
  Power_off:0 48 44 33 22 1 2 ...

and so on. The text at the start of the line is what send_code.sh uses
to find the right IR code to send. On one CCF file I tried, my awk script produced something like:

  Learned:0 48 1 3 54 6 7 ..
  Learned:0 48 9 12 3 44 88 1 ...

For this one, I needed to go back to the original CCF file dump and scroll through
to find out what each IR code definition corresponded to what. Here's the kinda
thing I saw:

 Mute(00035CEB)
    IR Code: "Learned" 0000 0067 0044 0 ...

So I just edited the text file, changed the 'Learned' to 'Mute' and reran the awk
script. There's quite a bit of trial and error involved here. I'd suggest
just trying to narrow things down to the Power on, off or power cycle IR codes
and play with them.

You might be reading all this thinking; "So when do I have to insert the IR codes
into the tivo MFS database?". You don't have to. Thats only for when you're 
configuring a set top box or other device that the tivo needs to talk to to
change channels. 

Note that the '.codes' file you generate should go into the /hack/etc directory
so that send_codes.sh can find it.

Doesn't thie awk script just do the same thing as that funny spreadsheet and 
web page in the InfraRed Howto notes at Oztivo? Yes it does. I just got sick of 
copying and pasting things and wrote the awk script instead. If you're having 
problems then by all means try converting your pronto CCF codes
with the web page at  http://www.pixoo.net/tivo_ir.php . You'll end up with a 
tcl script, but the numbers specified should match those generated by the awk
script.


on.sh/off.sh are just example scripts to use with trickey

Trickey and power_ir_tools aren't included. Just go to the oztivo upload URL:
http://minnie.tuhs.org/twiki/bin/view/Uploads/WebHome and grab them.

Trickey consists of an executable 'trickey', and an example config file. Copy
'trickey' to /hack/bin and trickey.conf to /hack/etc. Make sure 'trickey'
is executable. The examples in the 
config file are silly, so you should comment them out. Read the readme that comes 
with trickey, as you'll need to put it into your startup sequence somewhere so
it is restarted when you restart the tivo.

The only bit of power ir tools you need is the irlock binary. ftp irlock into
your /hack/bin directory and make sure its executable. irtest is part of the 
oztivo image.

Testing
=======

First try to see if you can send IR codes. Make sure your IR blaster is pointing
at the thing you're trying to turn on and off, then go through the motions of 
converting a CCF file, running it through the awk script, and putting the 
hand edited file into /hack/etc. Lets say its called rankarena.codes. You
can try doing something like:

  send_codes rankarena.codes Power_on

You'll see some 'Microcode 00034' or somesuch message, and hopefully your 
Rank Arena will power on. 

Still stuck? If you type 'irtest -h' you'll get some help. There is a '-d' 
option for irtest that might be handy.


Setting up Trickey
==================

If you can send IR codes on the command line successfully, then make up a
script similar to the on.sh and off.sh scripts, and put them into your 
trickey.conf file. Here's some examples:

 S1S      SELECT,NUM1,SELECT 3    /var/hack/ir/on.sh
 S2S      SELECT,NUM2,SELECT 3    /var/hack/ir/off.sh

With these examples, you press SELECT, ONE, SELECT within 3 seconds and it
will run the on.sh script. If you press SELECT, TWO, SELECT within 3 seconds
it will run the off.sh script.

