From 1e9d37774549de552615c147d802588619c3ac39 Mon Sep 17 00:00:00 2001 From: Lieven Hollevoet Date: Mon, 18 Mar 2013 20:42:44 +0100 Subject: [PATCH 1/2] Adding support for X10 basic commands over xPL This pull request is based on an email that was sent on the list. The original developer is Roger Simon. I only did basic testing on this code (as in: I added an item in my mht file and saw it showed up in the web interface and it didn't crash misterhouse). I think this code is missing default on/off states for X10Basic items? --- lib/read_table_A.pl | 13 +++++++ lib/xPL_X10Basic.pm | 83 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 lib/xPL_X10Basic.pm diff --git a/lib/read_table_A.pl b/lib/read_table_A.pl index f86834765..6c5b4365b 100644 --- a/lib/read_table_A.pl +++ b/lib/read_table_A.pl @@ -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 diff --git a/lib/xPL_X10Basic.pm b/lib/xPL_X10Basic.pm new file mode 100644 index 000000000..14f4905ac --- /dev/null +++ b/lib/xPL_X10Basic.pm @@ -0,0 +1,83 @@ +=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, object_name, group_name + + e.g. + XPL_X10BASIC, hollie-x10gate.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 + +Credits: + Gregg Liming for the idea that we should not rely on the heartbeat messages to get the + status of the Squeezebox. + +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +=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; From 02c80a8424a67dc6230d9b1d046527bc818eebe2 Mon Sep 17 00:00:00 2001 From: Lieven Hollevoet Date: Mon, 18 Mar 2013 20:56:52 +0100 Subject: [PATCH 2/2] Verified X10Basic messages are generated. Confirmed that with the proposed syntax in the mht file the following message is generated when $device->send_on() is called: [xpl-cmnd/x10.basic: mhouse-mh.misterhouse -> hollie-x10gate.downstairs - on uplight] --- lib/xPL_X10Basic.pm | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/xPL_X10Basic.pm b/lib/xPL_X10Basic.pm index 14f4905ac..b8ff38cec 100644 --- a/lib/xPL_X10Basic.pm +++ b/lib/xPL_X10Basic.pm @@ -13,10 +13,10 @@ Usage: In your items.mht, add the squeezebox devices like this: - XPL_X10BASIC, xpl_device_id, object_name, group_name + XPL_X10BASIC, xpl_device_id:instance, object_name, group_name e.g. - XPL_X10BASIC, hollie-x10gate.uplight, uplight, Lights + XPL_X10BASIC, hollie-x10gate.downstairs:uplight, uplight, Lights License: This free software is licensed under the terms of the GNU public license. @@ -24,10 +24,6 @@ License: Authors: Roger Simon, added to git by Lieven Hollevoet based on a mail on the mailing list -Credits: - Gregg Liming for the idea that we should not rely on the heartbeat messages to get the - status of the Squeezebox. - @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ =cut