From 24af8c93dbb940fa3a4acc54aa0a13124bbde578 Mon Sep 17 00:00:00 2001 From: justme1968 Date: Mon, 3 Nov 2014 18:21:30 +0000 Subject: [PATCH] 37_harmony.pm: allow command shortcut on activity level git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@6875 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/37_harmony.pm | 44 ++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/fhem/FHEM/37_harmony.pm b/fhem/FHEM/37_harmony.pm index f1840ef9e..9896e44df 100644 --- a/fhem/FHEM/37_harmony.pm +++ b/fhem/FHEM/37_harmony.pm @@ -294,9 +294,16 @@ harmony_Set($$@) } } - if( $cmd eq 'off' ) { - $cmd = "activity"; - $param = "PowerOff"; + if( $cmd ne "?" && !$param ) { + if( $cmd eq 'off' ) { + $cmd = "activity"; + $param = "PowerOff"; + } elsif( my $activity = harmony_activityOfId($hash, $hash->{currentActivityID}) ) { + if( harmony_actionOfCommand( $activity, $cmd ) ) { + $param = $cmd; + $cmd = "command"; + } + } } if( $cmd eq 'activity' ) { @@ -353,12 +360,12 @@ harmony_Set($$@) return undef; } elsif( $cmd eq "getCurrentActivity" ) { - harmony_sendEngineGet($hash, "getCurrentActivity", ""); + harmony_sendEngineGet($hash, "getCurrentActivity"); return undef; } elsif( $cmd eq "getConfig" ) { - harmony_sendEngineGet($hash, "config", ""); + harmony_sendEngineGet($hash, "config"); return undef; @@ -464,6 +471,16 @@ harmony_Set($$@) return undef; + } elsif( $cmd eq "xxx" ) { + #harmony_sendIq($hash, ""); + #harmony_sendIq($hash, ""); + #harmony_sendIq($hash, ""); + #harmony_sendIq($hash, ""); + #harmony_sendIq($hash, ""); + #harmony_sendIq($hash, ""); + + return undef; + } if( $hash->{config} ) { @@ -794,12 +811,14 @@ harmony_Read($) #harmony_sendIq($hash, ""); #harmony_sendIq($hash, ""); #harmony_sendIq($hash, "format=json"); - #harmony_sendIq($hash, "format=json"); + #harmony_sendIq($hash, "format=json"); + #harmony_sendIq($hash, "format=json"); + #harmony_sendIq($hash, "format=json"); #harmony_sendIq($hash, "hetag= :uri=dynamite:://HomeAutomationService/Config/:encode=true"); #harmony_sendIq($hash, ""); #harmony_sendIq($hash, "name=1vm7ATw/tN6HXGpQcCs/A5MkuvI#iOS6.0.1#iPhone"); - harmony_sendEngineGet($hash, "config", ""); + harmony_sendEngineGet($hash, "config"); RemoveInternalTimer($hash); InternalTimer(gettimeofday()+50, "harmony_ping", $hash, 0); @@ -852,7 +871,7 @@ harmony_Read($) if( $decoded ) { if( defined($decoded->{syncStatus}) ) { - harmony_sendEngineGet($hash, "config", "") if( $hash->{syncStatus} && !$decoded->{syncStatus} ); + harmony_sendEngineGet($hash, "config") if( $hash->{syncStatus} && !$decoded->{syncStatus} ); $hash->{syncStatus} = $decoded->{syncStatus}; } @@ -898,7 +917,7 @@ harmony_Read($) harmony_connect($hash); } else { - harmony_sendEngineGet($hash, "config", ""); + harmony_sendEngineGet($hash, "config"); } @@ -929,7 +948,7 @@ harmony_Read($) $hash->{current_fw_version} = $decoded->{current_fw_version} if( defined($decoded->{current_fw_version}) ); - harmony_sendEngineGet($hash, "config", ""); + harmony_sendEngineGet($hash, "config"); } elsif( $content =~ m/engine\?changeChannel/ && $decoded ) { @@ -955,7 +974,7 @@ harmony_Read($) #harmony_sendIq($hash, "hetag= :uri=content:://1.0/user;$hash->{config}->{content}->{householdUserProfileUri}:encode=true"); harmony_sendIq($hash, "format=json"); - #harmony_sendEngineGet($hash, "getCurrentActivity", ""); + #harmony_sendEngineGet($hash, "getCurrentActivity"); } elsif( $cdata =~ m/result=(.*)/ ) { my $result = $1; @@ -1108,9 +1127,10 @@ harmony_sendIq($$;$) harmony_send($hash,$iq); } sub -harmony_sendEngineGet($$$) +harmony_sendEngineGet($$;$) { my ($hash, $endpoint, $payload) = @_; + $payload = '' if ( !$payload ); my $xml = "$payload";