From de0ed6de6c2edab4cedbbc770b40aa11ad202f37 Mon Sep 17 00:00:00 2001 From: justme-1968 Date: Mon, 15 Jun 2015 17:03:04 +0000 Subject: [PATCH] 37_harmony.pm: fix for acces to uninitialized device data git-svn-id: https://svn.fhem.de/fhem/trunk@8751 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/37_harmony.pm | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/fhem/FHEM/37_harmony.pm b/fhem/FHEM/37_harmony.pm index 3cbcdef56..fa6221ba2 100644 --- a/fhem/FHEM/37_harmony.pm +++ b/fhem/FHEM/37_harmony.pm @@ -533,10 +533,12 @@ harmony_Set($$@) return undef if( !defined($hash->{config}) ); my $activities; - foreach my $activity (sort { ($a->{activityOrder}||0) <=> ($b->{activityOrder}||0) } @{$hash->{config}->{activity}}) { - next if( $activity->{id} == -1 ); - $activities .= "," if( $activities ); - $activities .= $activity->{label}; + if( $hash->{config}->{activity} ) { + foreach my $activity (sort { ($a->{activityOrder}||0) <=> ($b->{activityOrder}||0) } @{$hash->{config}->{activity}}) { + next if( $activity->{id} == -1 ); + $activities .= "," if( $activities ); + $activities .= $activity->{label}; + } } if( my $activity = harmony_activityOfId($hash, -1) ) { @@ -552,15 +554,17 @@ harmony_Set($$@) my $hidDevices; my $autocreateDevices; - foreach my $device (sort { $a->{id} <=> $b->{id} } @{$hash->{config}->{device}}) { - if( $device->{IsKeyboardAssociated} ) { - $hidDevices .= "," if( $hidDevices ); - $hidDevices .= harmony_labelOfDevice($hash, $device->{id} ); - } + if( $hash->{config}->{device} ) { + foreach my $device (sort { $a->{id} <=> $b->{id} } @{$hash->{config}->{device}}) { + if( $device->{IsKeyboardAssociated} ) { + $hidDevices .= "," if( $hidDevices ); + $hidDevices .= harmony_labelOfDevice($hash, $device->{id} ); + } - if( !defined($modules{$hash->{TYPE}}{defptr}{$device->{id}}) ) { - $autocreateDevices .= "," if( $autocreateDevices ); - $autocreateDevices .= harmony_labelOfDevice($hash, $device->{id} ); + if( !defined($modules{$hash->{TYPE}}{defptr}{$device->{id}}) ) { + $autocreateDevices .= "," if( $autocreateDevices ); + $autocreateDevices .= harmony_labelOfDevice($hash, $device->{id} ); + } } }