# Multiple Network Remotes



## TonyBlunt

I control my system with a "universal remote" iPad running iRule software. It works very well. I would like to give my wife a similar remote, but Tivo only allows one network remote connected to the Tivo.

Is there any chance this will be changed in the future?

If not, could a Mac software guru create a Mac-based program that would receive the commands from two iRule remotes, stack them and retransmit them to the Tivo?


----------



## telemark

That's a reasonable request, but I'd be surprised if they overhaul this API since they don't use it themselves much.

On using an intermediary, do you get to set the IP and Port# of the Tivo, or does it force you to use auto-discovery?

The easiest way to do this is to rewrite the driver on the remote. Is that opensource / viewable anywhere?


----------



## wmcbrine

Some of the remote programs (note: not mine) will open a connection, send a command, and then close the connection again. One of these would allow pseudo-simultaneous use with another instance.

I like how the spec PDF talks as though multiple clients can be connected at once.


----------



## TonyBlunt

telemark said:


> On using an intermediary, do you get to set the IP and Port# of the Tivo, or does it force you to use auto-discovery?
> 
> The easiest way to do this is to rewrite the driver on the remote. Is that opensource / viewable anywhere?


In iRule you set the IP address and port. The iRule software is not opensource.

I would suspect opening and closing the connection after every command would introduce a lag.


----------



## telemark

wmcbrine said:


> I like how the spec PDF talks as though multiple clients can be connected at once.


ha, I'd like it more if they followed their specs.

I'm actually kinda concerned the relevant software engineers are long gone and they're too afraid to touch their old code base.



TonyBlunt said:


> I would suspect opening and closing the connection after every command would introduce a lag.


Maybe, but maybe it won't be enough to notice. I can say every IP remote I've tried is faster than any of my IR remotes.

It's not impossible to write, but intricate. It's like this homework assignment, for CS juniors/seniors. 
(They get a week. I assume a pro could do it in a day)

Could you run this test on your mac, to see if the iRule remote requires bidirectional communications to work. Because this test uses a pipe, the responses from the Tivo won't be sent back to the remote.
nc -l 31339 | nc TIVO_IP 31339
(Point the remote to the mac, and the command line to the Tivo's IP)

Maybe you know the answer already, does the app display channel status?


----------



## wmcbrine

It has amused me to write this program for you.  Actually, this is going to come in handy for me, too... I should've done it long ago, if only I'd thought of it.

This is a barebones version... unzip it, open a Terminal window, and type "python rproxy.py _your.tivo.ip_". Then point your remote apps at the computer's IP. If you're not comfortable with that, I'll probably post a GUIfied version later, with autodetection, etc. Anyway, it works as-is.


----------



## telemark

Wow, impressive. I was only contemplating a one-way version. 

It does look fun, simple problem statement, non-obvious complexity, but compact implementation.

In Python, it does come out more elegant (because of light threads). Good choice there.

Very cool.


----------



## wmcbrine

Updated version -- still no autoconfig or GUI, but I wanted to post this cleaned-up and documented version first.

- Verbose mode, logs to the console
- Host/port options
- Queue.Queue instead of a list (thanks telemark)


----------



## Fofer

Nice! This is great work, wmcbrine! :up:

TonyBlunt, whaddaya think?


----------



## JohnS-MI

Must be an iPad thing. I have two Android tablets, both with a Tivo remote app present. Both work fine. I have not tried using both simultaneously, sending competing commands. Both had to be loaded with the Tivo's MAK.

I only have one Tivo so I can't test, but it looks like the Android app could switch between multiple Tivos, too.


----------



## wmcbrine

No, it's not an iPad thing. It's not about having remote apps installed on two different systems, it's about having them actually open and connected to the same TiVo at once.

Also, the problem described here applies to the older, port 31339 "Crestron" protocol, as used by most third-party remote control apps. It may or may not apply to the newer system used by TiVo's own Android and iOS apps (and by KMTTG); I haven't tested that.


----------



## Bigg

TiVo has no incentive to add this "feature", since it's designed for Crestron or Control 4, where the control system would manage various controllers, and then relay one set of commands via IP to the TiVo.


----------



## wmcbrine

This version adds announcements via Zeroconf, for remote apps that scan the network for available TiVos. It also shows the address and port in verbose mode, and is slightly reorganized.

The name used for the announcements is "Proxy(tivoname)", where "tivoname" in turn is derived from a Zeroconf scan. (If that fails, the IP address is used.) This format is recognized by my Network Remote v0.29 or later, and used to remove the original TiVo from its connection list (since it's "busy"). Older versions of Network Remote lack this feature, and are limited to port 31339 (like real TiVos, but unlike rproxy), but are otherwise compatible, and will recognize rproxy's announcements and connect to it.


----------



## wmcbrine

Now with its own proper home:

http://wmcbrine.com/tivo/#rproxy

This version adds autodetection and selection of TiVos, as a command-line option -- use -i for interactive mode. It also fixes some crashes with Network Remote 0.29.


----------



## telemark

wmcbrine said:


> Now with its own proper home:
> 
> http://wmcbrine.com/tivo/#rproxy
> 
> This version adds autodetection and selection of TiVos, as a command-line option -- use -i for interactive mode. It also fixes some crashes with Network Remote 0.29.


I'm trying to start this from scripts.

Can we make autodetection mode, non-interactive. (I only use one tivo so it's always #1).

Something like this might make it universal:
-f "Living Room"


----------



## wmcbrine

You probably ought to give the TiVo a static IP in that situation. But, sure, I could do that...


----------



## TonyBlunt

I just checked back into this thread - WOW

That is exactly what I want, now I have an iPad, an iPhone, and an Android tablet that can all control the system - together.

Just one more thing (there always is) - would be nice if this could be started at system reboot.....

...and for less techy types, like myself, where do you put the .py files to avoid having to include the directory path in the command? ie my command at present is:-
python ~/Desktop/rproxy-0.4/rproxy.py -i

Many thanks


----------



## wmcbrine

http://wmcbrine.com/tivo/#rproxy

Version 0.5 allows you to specify the TiVo by name (i.e. the display name, like you'd see in the "My Shows" list or via -l) or TiVo Service Number, as well as by IP. (Similar to telemark's suggestion, but no option flag is needed.) Also, there's a new option "-f", to simply scan and connect to the first TiVo found. Also, specifying the port to connect to on the command line hadn't actually been working.


----------



## telemark

> ..and for less techy types, like myself, where do you put the .py files to avoid having to include the directory path in the command?


For the options, Run:
echo $PATH

/usr/local/bin/
is a pretty standard choice.

You might also want to set the permissions, with:
chmod +x /usr/local/bin/*.py

then you don't have type python, just:
rproxy.py


----------



## TonyBlunt

TonyBlunt said:


> I just checked back into this thread - WOW
> 
> Just one more thing (there always is) - would be nice if this could be started at system reboot.....


A simple app, Lingon, simplifies this for the non-techy. All issues resolved.

Thanks again.


----------



## eelton

Thanks, wmcbrine. This is fantastic. The app works great for me, allowing me to control the TiVo from two different tablets running iRule.


----------



## TonyBlunt

One issue, whenever the Tivo is restarted I have to reboot the Mac as well for the remotes to take effect, is there an easier way to maintain connection?


----------



## telemark

I'll chime in some talking points...

It's possible to put a retry that would attempt to connect after a Tivo restart, assuming its IP didn't change.

A couple examples makes it debatable if this is the best way to handle it.

What if the Tivo wasn't restarted but was switched off? Shouldn't the proxy exit instead of hanging around? Then how to tell the difference?

Even if the Tivo's coming back, is it fair to the connected clients to accept commands that won't be sent out.

Haven't fully thought it through, but I'm guessing it would be cleaner to exit whenever a Tivo goes missing. Then either external or internal controls should restart it (if desired) to a state of waiting around for a good broadcast. 

And disclaimer: my opinion doesn't matter, while wmcbrine's does.


----------



## telemark

This is the smallest patch I could find against 0.5, that will cause rproxy to exit when it gets a network error back from the Tivo.

If you set Lingon to "Always", rproxy should exit when the Tivo is back up, and Lingon will restart it.

Turning off the Tivo for an extended time might eventually cause undesirable behavior on the Mac, as described earlier but really depends on how Lingon is written.


Code:


# diff ~/rproxy0.5/rproxy.py /usr/local/bin/rproxy.py 
282,283c282,283
<     thread.start_new_thread(status_update, (tivo, listeners, target, verbose))
<     serve(queue, listeners, host_port)
---
>     thread.start_new_thread(serve, (queue, listeners, host_port))
>     status_update(tivo, listeners, target, verbose)

Edited: a second patch that reintroduced KeyboardInterrupt detection


----------



## wmcbrine

TonyBlunt said:


> One issue, whenever the Tivo is restarted I have to reboot the Mac as well for the remotes to take effect, is there an easier way to maintain connection?





telemark said:


> Haven't fully thought it through, but I'm guessing it would be cleaner to exit whenever a Tivo goes missing.


These both make sense to me, so, that's what I've done now. 

http://wmcbrine.com/tivo/#rproxy

Reconnecting is the default, similar to how it works in Network Remote. This doesn't (yet) work if the TiVo changes IP. To instead get telemark's behavior -- exit on disconnect -- specify "-x" when starting.

This version also reports more info in verbose mode, and -- unless you specify the server port to use -- it will automatically try the next nine ports if 31339 is already bound. This makes it a little easier to proxy multiple TiVos from the same machine.


----------



## tyd450

test post


----------



## Jacksteraz

Do you think this program would run on a Raspberry pi or an NAS, for those of us that don't leave our computers on all the time?


----------



## telemark

Yes, as long as they have python available, which if they're running linux should be available.


----------



## jonstrasser

Hi
I'm a total newbie at TiVO but have been an irule user since it's inception.
Do I just run this program on my mac, then point the rule IP to my mac's ip? also, what port do I use?


----------



## wmcbrine

jonstrasser said:


> Do I just run this program on my mac, then point the rule IP to my mac's ip?


Yes.



> _also, what port do I use?_


31339 is the default.


----------



## wmcbrine

Version 0.7 of rproxy is out now. This just adds support for Python 3.x.


----------

