[Legacy] Execute server command based on ir?

Topics related to the TouchControl Server software.
Post Reply
User avatar
Dave
Site Admin
Posts: 70
Joined: Mon Dec 01, 2014 12:41 pm
Contact:

[Legacy] Execute server command based on ir?

Post by Dave » Sun Dec 20, 2015 10:25 pm

Original post by: alitchy

I plan on getting an Xbox one with Kinect.
the Kinect can send ir codes to control my appletv based on voice. My current setup via your great app, allows me to press a button and pause the movie AND turn on the room lights. Play button then plays and turns off the lights. I keep track of states via variables and it works out great. I would like to trigger the pause/play commands via IR sent from the Kinect. What I don't know is if/how to execute a command from touch app seeing the IR from Kinect. Is triggering a buttons actions via IR possible?
Thanks


October 29, 2015 at 6:35 AM Edit Delete Flag Quote & Reply

Midnight
Limited Member
Posts: 78
alitchy,

There is no direct way of doing this because an iPad/iPhone does not support an IR receiver.

If you are familiar with Raspberry Pi, while not a finished project, here is an interesting approach. Once the IR commands are decoded, the Raspberry Pi can issue IP commands to TouchControl. Note that there is a basic flaw to this aproach -- TouchControl must be running at the instant the IR command is received. A more advanced approach would build a command queue in the Raspberry Pi. Periodically, the Raspberry Pi would broadcast a message: "hey, I've got commands". Once Touch Control receives this message, it can request the commands, then empty the Queue.

An even more grotesque approach would be to find a used CTL101 processor feeding a GlobalCaché unit.

While I could not find any references during a quick search. I'm sure that there are, or soon will be, some "hooks" in the Xbox that will allow the Xbox to issue IP and/or IR commands to 3rd party devices. Again, you will encounter issues if TouchControl is not running at the instant these commands are sent.
October 30, 2015 at 5:27 AM Edit Delete Flag Quote & Reply

Dave Arnold
Site Owner
Posts: 681
Hi alitchy. It's actually sort-of possible, if you have a USB-UIRT dongle. Please see this page. I added the USB-UIRT Broadcast feature back in version 7.1 for another user who wanted to do something similar. TC Server can "listen" for IR signals received via the USB-UIRT and re-broadcast those IR codes back out onto your network via UDP, where TouchControl running on your iOS device can listen for them using a Feedback Listener button. You can then execute other buttons based on the "signals" your device receives. Take a look and see if this is something like what you are wanting. Note that the TC Server/USB-UIRT solution referenced in the link also has accounted for the issue raised by Midnight in the above post about Raspberry Pi, in that TC Server keeps a queue of IR commands received, and you can send a command to TC Server to force it to re-broadcast the commands you may have missed while the device was off, sleeping, etc.
October 30, 2015 at 9:25 AM Edit Delete Flag Quote & Reply

alitchy
Limited Member
Posts: 14
Thank you both for replying and giving me some alternatives. I am alreadying leveraging usb-uirt to control my theater, and I have an old iphone 4, and a 5c with a broken screen. I could stick one of those two on a charger, tell them to never sleep and try Dave's suggestion.
Although the forthcoming kinect can control basic functionality, it can't do things like macros, assign variables, check states, etc. TouchControl looks like it will once again be the glue that holds my theater together and gives it the real automation I am looking for.
looks like I have some experimenting to do this weekend! I will let you know how it turns out.
October 30, 2015 at 8:42 PM Edit Delete Flag Quote & Reply

alitchy
Limited Member
Posts: 14
Well you knew I would be back with questions :) Creating the feedbac button, the interface, etc seems pretty straight forward. But can you provide some guidance on how to "process" the IR code via a script? I figure I can capture the exact IR code being sent by learning the IR code in a button and the cutting and pasting that when appropriate. But I am at a loss for how to have the feedback button "listen" for that exact code and then do something.
I would think it would be something like IF THE FEEDBACK IS THIS IR CODE, THEN EXECUTE THIS PORTION OF THE SCRIPT. But I am at a loss at how to do this. Any help would be greatly appreciated.
Thanks
October 31, 2015 at 9:17 AM Edit Delete Flag Quote & Reply

Dave Arnold
Site Owner
Posts: 681
Yes that's exactly right. Something like this:

if (_feedback == 'someircode1') {
return '[#]myButton1'; // [#] executes the named button
} else if (_feedback == 'someircode2') {
return '[#]myButton2';
}....etc...

Once you capture all of the IR signals you are interested in, you could create a library of named IR codes to use in your script. Just add script to a script library in TC Server like this:

var kinectCodeOn = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx';
var kinectCodeOff = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyy';
var kinectCodeBack = 'zzzzzzzzzzzzzzzzzzzzzzzzzzzz';
...etc...

Then use:

if (_feedback == kinectCodeOn) {
....do your thing...

You could get fincier with switch statements, etc., but the above code should be pretty easy to get up and going to start with.
October 31, 2015 at 4:03 PM Edit Delete Flag Quote & Reply

alitchy
Limited Member
Posts: 14
Thanks Dave. Happy Halloween!
October 31, 2015 at 5:11 PM Edit Delete Flag Quote & Reply

Midnight
Limited Member
Posts: 78
I have never used USB-UIRT. How repeatable are the received IR codes? I ask because successive reads could vary slightly. I notice this as I attempt to learn codes. It's not a major issue while learning because the controlled devices can tolerate a little bumbling around, however a strict compare operation will fail. When learning, I pass the codes through a sanitizer such as IrScrutinizer to form theoretically perfect codes

'xxxxxxxxxxxxxxxxxxxxxxxxxxxt' or 'xxxxxxxxxxxxxxxxxxxxxxxxxxxu' might be fine for controlling something, but frustrate a compare operation.
November 1, 2015 at 6:59 AM Edit Delete Flag Quote & Reply

Dave Arnold
Site Owner
Posts: 681
Agreed. I believe the other user that I worked with on this feature did a "fuzzy" compare. That is I believe there were a certain string of characters that he could rely on to always be unique and contained in the signals he was interested in. In that case you'd want to do something like this:

if (_feedback.indexOf('xxxxsome unique stringxxxxx') >= 0) { // or use == 0 if you know the IR code should alwasy start with the string
....do your thing...
} else ....etc...

Post Reply