Skip to content

Commit

Permalink
Merge pull request #130 from hollie/add_xpl_x10_support
Browse files Browse the repository at this point in the history
Add xPL x10 basic support (input from Roger on mailing list)
  • Loading branch information
hollie committed Apr 14, 2013
2 parents 9868d21 + 02c80a8 commit 1c5e62c
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/read_table_A.pl
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,19 @@ sub read_table_A {
$code .= "use xPL_Items;\n";
}
}
elsif($type eq "XPL_X10BASIC") {
($address, $name, $grouplist, @other) = @item_info;
$other = join ', ', (map {"'$_'"} @other); # Quote data
if($other){
$object = "xPL_X10Basic('$address',$other)";
}
else{
$object = "xPL_X10Basic('$address')";
}
if( ! $packages{xPL_X10Basic}++ ) { # first time for this objecttype?
$code .= "use xPL_X10Basic;\n";
}
}
elsif($type eq "XPL_IRRIGATEWAY") {
($address, $name, $grouplist, @other) = @item_info;
$other = join ', ', (map {"'$_'"} @other); # Quote data
Expand Down
79 changes: 79 additions & 0 deletions lib/xPL_X10Basic.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
=begin comment
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
xPL_X10Basic.pm - basic support for X10 messages over xPL
$Date$
$Revision$
Info:
This module allows to support X10 basic messages over xPL.
Usage:
In your items.mht, add the squeezebox devices like this:
XPL_X10BASIC, xpl_device_id:instance, object_name, group_name
e.g.
XPL_X10BASIC, hollie-x10gate.downstairs:uplight, uplight, Lights
License:
This free software is licensed under the terms of the GNU public license.
Authors:
Roger Simon, added to git by Lieven Hollevoet based on a mail on the mailing list
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
=cut

use strict;

package xPL_X10Basic;
use base qw(xPL_Item);

sub new {
my ($class, $p_source, $p_type, $p_statekey) = @_;
my ($source,$deviceid) = $p_source =~ /(\S+):(\S+)/;
$source = $p_source unless $source;
my $self = $class->SUPER::new($source);
$$self{type} = $p_type if $p_type;
my $statekey = $p_statekey;
$statekey = 'command';
$self->SUPER::class_name('x10.basic');
$$self{state_monitor} = "x10.basic : $statekey";
$self->SUPER::device_monitor("device=$deviceid") if defined
$deviceid;
return $self;
}


sub send_on {
my ($self) = @_;
$self->SUPER::send_cmnd('x10.basic' => { 'device' => '$deviceid',
'command' => 'on' });
}

sub send_off {
my ($self) = @_;
$self->SUPER::send_cmnd('x10.basic' => { 'device' => '$deviceid',
'command' => 'off' });
}



sub rts10_on {
my ($self) = @_;
$self->SUPER::send_cmnd('x10.basic' => { 'device' => '$deviceid',
'command' => 'on' , 'protocol' => 'rts10' });
}


sub rts10_off {
my ($self) = @_;
$self->SUPER::send_cmnd('x10.basic' => { 'device' => '$deviceid',
'command' => 'off' , 'protocol' => 'rts10' });
}


1;

0 comments on commit 1c5e62c

Please sign in to comment.