Skip to content

Commit

Permalink
Merge pull request #812 from DaveNeudoerffer/aog_fixes
Browse files Browse the repository at this point in the history
Aog fixes
  • Loading branch information
hplato authored Dec 30, 2020
2 parents f9d5b0f + 8c2015d commit e0745ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 9 additions & 2 deletions lib/AoGSmartHome_Items.pm
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,8 @@ sub add {
# If no device type is provided we default to 'light'
$self->{'uuids'}->{$uuid}->{'type'} = lc($type) || 'light';
$self->{'uuids'}->{$uuid}->{'room'} = $room if $room;
print "Added AOG device:\n " . Dumper( $self->{'uuids'}->{$uuid} )
if $main::Debug{'aog'} > 2;
}

=item C<sync()>
Expand Down Expand Up @@ -451,7 +453,10 @@ EOF
# objects will have to be added here (right now we only check for
# INSTEON and X10 dimmable lights).
my $mh_object = ::get_object_by_name($self->{'uuids'}->{$uuid}->{'realname'});
if ($mh_object->isa('Insteon::DimmableLight')
if( !ref $mh_object ) {
&main::print_log("[AoGSmartHome] '$self->{'uuids'}->{$uuid}->{'realname'} is not found.");
}
elsif ($mh_object->isa('Insteon::DimmableLight')
|| $mh_object->can('state_level') ) {
$response .= <<EOF;
"action.devices.traits.Brightness",
Expand Down Expand Up @@ -728,7 +733,7 @@ sub execute_OnOff {
my $response = ' {
"ids": [';

my $turn_on = $command->{'execution'}->[0]->{'params'}->{'on'} eq "true" ? 1 : 0;
my $turn_on = $command->{'execution'}->[0]->{'params'}->{'on'};

foreach my $device ( @{ $command->{'devices'} } ) {
set_state( $self, $device->{'id'}, $turn_on ? 'on' : 'off' );
Expand Down Expand Up @@ -880,6 +885,8 @@ sub execute {
"commands": [
EOF

$Data::Dumper::Maxdepth = 0;
print "Aog received execute request:\n " . Dumper( $body ) if $main::Debug{'aog'} > 2;
#
# First, send the commands to all the devices specified in the request.
#
Expand Down
5 changes: 4 additions & 1 deletion lib/read_table_A.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1899,12 +1899,15 @@ sub read_table_A {
$sub =~ s%^&%\\&%; # "&my_subroutine" -> "\&my_subroutine"
$sub =~ s%^\\\\&%\\&%; # "\\&my_subroutine" -> "\&my_subroutine"
$sub = "'$sub'" if $sub !~ /&/;
$statesub =~ s%^&%\\&%; # "&my_subroutine" -> "\&my_subroutine"
$statesub =~ s%^\\\\&%\\&%; # "\\&my_subroutine" -> "\&my_subroutine"
$statesub = "'$statesub'" if $statesub !~ /&/;
$realname = "\$$realname" if $realname;
my $other = join ', ', ( map { "'$_'" } @other ); # Quote data
if (!$packages{AoGSmartHome_Items}++ ) { # first time for this object type?
$code .= "use AoGSmartHome_Items;\n";
}
$code .= sprintf "\$%-35s -> add('$realname','$name',$sub,'$on','$off','$statesub',$other);\n", $parent;
$code .= sprintf "\$%-35s -> add('$realname','$name',$sub,'$on','$off',$statesub,$other);\n", $parent;
$object = '';
}
#-------------- End AoGSmartHome Objects ----------------
Expand Down

0 comments on commit e0745ce

Please sign in to comment.