2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-26 16:19:32 +00:00

37_harmony.pm: better error handling, some cleanups, DEVICE level on and off commands

git-svn-id: https://svn.fhem.de/fhem/trunk@6829 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme-1968 2014-10-28 17:10:24 +00:00
parent 7351a49413
commit 89e511f643

View File

@ -250,7 +250,10 @@ harmony_Set($$@)
return "no hub found for device $name ($hash->{id})" if( !$hash->{hub} );
}
if( $cmd ne "?" ) {
if( $cmd ne "?" && !$param ) {
$cmd = "PowerOn" if( $cmd eq "on" );
$cmd = "PowerOff" if( $cmd eq "off" );
my $device = harmony_deviceOfId( $defs{$hash->{hub}}, $hash->{id} );
if( harmony_actionOfCommand( $device, $cmd ) ) {
$param = $cmd;
@ -733,7 +736,7 @@ harmony_updateActivity($$;$)
readingsSingleUpdate( $hash, "currentActivity", "$modifier$activity", 1 );
$activity =~ s/ /./g;
readingsSingleUpdate( $hash, "activity", $activity, 1 ) if( !$modifier );
readingsSingleUpdate( $hash, "activity", $activity, 1 ) if( !$modifier && $activity ne ReadingsVal($hash->{NAME},"activity", "" ) );
delete $hash->{hidDevice} if( $id == -1 );
}
@ -820,6 +823,11 @@ harmony_Read($)
}
my $error = $decoded->{errorCode};
if( $error && $error != 200 ) {
Log3 $name, 2, "$name: error ($error): $decoded->{errorString}";
}
if( ($tag eq "iq" && $content =~ m/statedigest\?get'/)
|| ($tag eq "message" && $content =~ m/type="connect.stateDigest\?notify"/) ) {
Log3 $name, 4, "$name: notify: $cdata";
@ -851,16 +859,9 @@ harmony_Read($)
}
}
} elsif( $tag eq "message" ) {
if( $content =~ m/type="harmony.engine\?startActivityFinished"/ ) {
my $id = 0;
my $error = 0;
if( $cdata =~ m/activityId=([\d\-]*).*errorCode=(\d*).*errorString=(\w)*/ ) {
$id = $1;
$error = $2;
}
harmony_updateActivity($hash, $id);
harmony_updateActivity($hash, $decoded->{activityId}) if( defined($decoded->{activityId}) );
} else {
Log3 $name, 2, "$name: unknown message: $content";