LinHES Forums
http://forums.linhes.org/

Quick access to the OSD - X10 integration
http://forums.linhes.org/viewtopic.php?f=17&t=4136
Page 1 of 1

Author:  wififun [ Mon Apr 11, 2005 12:05 pm ]
Post subject:  Quick access to the OSD - X10 integration

I have been playing again with some Home Automation things, and working on integrating some basic things with my Myth box. Since I use a mac for the automation control (you can't beat AppleScript and Indigo.) One thing I do now, is when someone is coming up the walk way to the front door, I have an apple script that basically ssh's into the myth box and then sends:
Code:
mythtvosd --template=alert --alert_text="Someone is at the front door."

This works, but takes a little more time then I would like. Pauses are needed for the connection, and password to be sent, and sometime ssh takes a few seconds to make a connection (myth gets weird every now and then.)

I am looking for a quicker way to do this. Is there a way to send a message straight to the port, or something that does not require a full log in, wait, send password, wait, send command.

Author:  Xsecrets [ Mon Apr 11, 2005 5:30 pm ]
Post subject: 

I don't know that there is any quicker way than what you are doing. I just saw something over on the asterisk wiki about mythtv integration with asterisk, but I think it was using mythosd just like you are, but It might be worth a look.

Author:  wififun [ Mon Apr 11, 2005 11:02 pm ]
Post subject: 

I will have to check that out. I am working on an asterisk pbx next anyway, so this may be good. Thanks for the tip.

Author:  nigelpearson [ Tue Apr 12, 2005 5:37 am ]
Post subject: 

wififun, I just built you a Max OS X binary of mythtvosd. Download it from here:
http://www.users.bigpond.com/pear_computers

You can run it exactly the same way as the one you are ssh'ing. It should save a few seconds (ssh negotiations can take a while, particularly over wireless networks)

Author:  khrusher [ Tue Apr 12, 2005 7:39 am ]
Post subject: 

Does your MAC environment provide command line http access similar to wget? you may be able to script a telnet session to the apache port.

You could use the apache server and some PHP to execute your commands. I'm not a PHP coder but have written lots of shell script based CGI.

you could have a script say x10.php that accepted parms for different event which is called from the MAC

From the MAC
Code:
wget http://mythweb.local.domain:<port>/x10.php?event=FrontDoor


On the mythbox in PHP syntax

Code:
x10.php

if event = 'FrontDoor" then
   mythtvosd --template=alert --alert_text="Someone is at the front door."
elseif event = 'BackDoor" then
   mythtvosd --template=alert --alert_text="Someone is at the back door."
elseif
   ...
end if


Of course, with cgi enabled, this could be wrtten in sh, ksh, perl, anything.

While this is not as secure as ssh, you can use htaccess schemes to limit access to this script to trusted machines.

Author:  wififun [ Tue Apr 12, 2005 8:30 am ]
Post subject: 

Wow, those are both great ideas.

nigelpearson, thank for compiling mythtvosd. At about 12:20 this morning, I had the idea of compiling this, mythnotify, and a few other things I saw on different groups. I spent a while trying to get it to work. I could not get it to compile. Running your compiled version returned
Code:
mythtvosd can't open library: /usr/local/lib/libfreetype.6.dylib  (No such file or directory, errno = 2)
Trace/BPT trap

This evening I will spend some time tracking down and likely compiling libs to get this working. Thanks for the help. UPDATE: Good old Fink. I think I am on to the answer now. I will report back. UPDATE 2: well, I set up on a different clean 10.3.8 mac and followed the myth compile steps here http://www.mythtv.info/moin.cgi/MythOnMacOsx At the end, rather than doing the whole of myth I just did the mythtvosd. This all worked well. I wish I new how to statically build this, so these libs would not be needed. I had to edit main.cpp since it seams that the ip is bound to 255.255.255.255. I changed this to the ip of my mythbox. My c is so rusty, I don't remember where to begin to try and make the --bcastaddr switch actually work. It does not seem to function. As soon as I get home where I can see the OSD I will know if all this worked.

khrusher - I am also going to implement this idea. This looks great. Very in secure, but then this box is pretty isolated from the outside. Looks like fun, and may solve some other ideas I have had as well. Very cool.

Author:  Xsecrets [ Tue Apr 12, 2005 4:42 pm ]
Post subject: 

you do realize that 255.255.255.255 is the broadcast address, which I believe is what mythosd uses, so you really probably didn't need to change that.

Author:  nigelpearson [ Wed Apr 13, 2005 6:16 am ]
Post subject: 

wififun wrote:
Running your compiled version returned
Code:
mythtvosd can't open library: /usr/local/lib/libfreetype.6.dylib  (No such file or directory, errno = 2)
Trace/BPT trap


Do'h. Sorry about that. I did it in a hurry last night, and didn't even think about dependant libraries. It shouldn't need freetype, but it does need libqt, which is a little bit large and wastefull.

The PHP idea is good.

The best way would be to find a Perl hacker to make a script to do the equivalent of mythtvosd. But I ain't volunteering for that :-)

Author:  wififun [ Wed Apr 13, 2005 9:53 am ]
Post subject: 

to build and run it, it did require freetype, mysql client libs, qt, lame, etc... No biggie once I got it all figured out. And yea, it did not click that 255.255.255.255 was the broadcast address. Once compiled and libs in place, it works great. It takes less than 1 second now to get the trigger from Indigo to the display on the myth box. Nice, shaved 5 seconds off the response time. I know enough perl that I may be able to hack this together. I really would like to ditch the libs and convoluted process of getting it running. Thanks for the help, it works great.

Author:  khrusher [ Tue Apr 19, 2005 1:32 pm ]
Post subject: 

simple, no error checking ....
Code:
mythtv@mythtv:/var/www $ cat x10.php
<?
if (isset($_GET['event'])) {

    switch ($_GET['event']) {
    case "FrontDoor":
       echo "FrontDoor\n";
       $cmdline=escapeshellcmd(" mythtvosd --template=alert --alert_text=\"Someone is at the front door.\" ");
       break;
    case "Backdoor":
       echo "Backdoor\n";
       $cmdline=escapeshellcmd(" mythtvosd --template=alert --alert_text=\"Someone is at the back door.\" ");
       break;
    case "Garage":
       echo "Garage\n";
       $cmdline=escapeshellcmd(" mythtvosd --template=alert --alert_text=\"Someone is in the garage.\" ");
       break;
    }
    system($cmdline, $retval);
}
else
{
   echo "No Event";
}

    exit;
?>


to call, sent http to server, substitute your IP and port

Code:
http://68.163.156.159:8080/x10.php?event=FrontDoor

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/