From: Ron K. <ro...@za...> - 2001-10-06 21:22:21
|
I have expanded the routine a bit so you can also toggle the status of the item by clicking on the icon. sub X10Lamp { my $o; my $objState; my $icon; my ($arg1) = @_; my $onIcon = "/images/lighton.gif"; my $offIcon = "/images/lightoff.gif"; $o = &get_object_by_name($arg1); $objState = $o->state; $icon = "/images/dim.gif"; if ($objState eq 'on') {$icon = "<a href=\"/SET;referer?$arg1=off\"><img src=$onIcon></a>";} if ($objState eq 'off') {$icon = "<a href=\"/SET;referer?$arg1=on\"><img src=$offIcon></a>";} return $icon; To use, include this in your .shtml file: <!--#include code="&X10Lamp('$livingroom_tvlamp')"--> I think with a few more of these routines every web layout is possible. Ron. ----- Original Message ----- From: "Bruce Winter" <br...@mi...> To: "Misterhouse-Users" <mis...@li...> Sent: Saturday, October 06, 2001 10:10 PM Subject: RE: [misterhouse-users] Audrey - Link to some Home Control Panels > > What if the web server is seperated from MH completely? > > ... > > Personally my vote > > would be a CGI interface into the MH http server, or PHP. That way I can > > make my web page anyway I want and would call objects already > > created within MH. > > > > <form NAME="Lights Control" METHOD="GET" > > ACTION="http://<my_misterhouse_web_server/x10_cgi_interface"> > > <input type="control" name="bedroom_reading_lamp"> > > <input type="ON" name="ON" value="ON"> > > <input type="OFF" name="OFF" value="OFF"> > > You can already do this. Here is a simple example that could be served from > any server: > > Turn lamp > <a href="http://localhost:8080/SET;referer?$light1?on">on</a> > <a href="http://localhost:8080/SET;referer?$light1?off">off</a> > > To enable on-the-fly icons to that show current item states, add this > function to your code: > > sub web_icon_state { > my ($item) = @_; > my $obj = &get_object_by_name($item); > my $state = $obj->state; > my $icon = "$main::config_parms{html_dir}/graphics/$state.gif"; > print "db icon=$icon s=$state i=$item\n"; > my $image = file_read $icon; > return $image; > } > > Then add this to your html: > > <img src=http://localhost:8081/sub?web_icon_state('$light1')> > > > > I can fumble my way through Perl scripts but I can't seem to figure any of > > this out and it is quite frustrating. So if my idea is complete > > gibberish, > > I say we all pack up and go to Bruce's for a week and have Bruce > > run MH Boot Camp. > > That sounds like fun :) In lieu of that, I think we can work this through > by doing what we just did: posting questions/ideas/examples. > > Bruce > > > ________________________________________________________ > To unsubscribe from this list, go to: http://sourceforge.net/mail/?group_id=1365 > |