From 2e14f0b61ecce4ae1246804d8ae3869b6323dbbf Mon Sep 17 00:00:00 2001 From: justme-1968 Date: Wed, 5 Nov 2014 21:31:19 +0000 Subject: [PATCH] 37_harmony.pm: added reading newVersion and update command git-svn-id: https://svn.fhem.de/fhem/trunk@6897 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/37_harmony.pm | 43 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/fhem/FHEM/37_harmony.pm b/fhem/FHEM/37_harmony.pm index 4dbad5c33..a2a3c3f67 100644 --- a/fhem/FHEM/37_harmony.pm +++ b/fhem/FHEM/37_harmony.pm @@ -143,7 +143,7 @@ harmony_detailFn() my $hubName = $hash->{discoveryinfo}->{friendlyName}; $hubName =~ s/ /%20/; - + return "myHarmony config
" } @@ -495,7 +495,15 @@ harmony_Set($$@) return undef; + } elsif( $cmd eq "update" ) { + harmony_sendIq($hash, "format=json"); + + return undef; + } elsif( $cmd eq "xxx" ) { + #harmony_sendIq($hash, "format=json"); + #harmony_sendIq($hash, "format=json"); + #harmony_sendIq($hash, "format=json"); #harmony_sendIq($hash, ""); #harmony_sendIq($hash, ""); #harmony_sendIq($hash, ""); @@ -554,6 +562,8 @@ harmony_Set($$@) $list .= " command getConfig:noArg getCurrentActivity:noArg off:noArg reconnect:noArg sleeptimer sync:noArg text cursor:up,down,left,right,pageUp,pageDown,home,end special:previousTrack,nextTrack,stop,playPause,volumeUp,volumeDown,mute"; + $list .= " update:noArg" if( $hash->{hubUpdate} ); + return "Unknown argument $cmd, choose one of $list"; } @@ -844,7 +854,7 @@ harmony_Read($) #harmony_sendIq($hash, "name=1vm7ATw/tN6HXGpQcCs/A5MkuvI#iOS6.0.1#iPhone"); harmony_sendIq($hash, "format=json"); - harmony_sendEngineGet($hash, "config"); + #harmony_sendEngineGet($hash, "config"); RemoveInternalTimer($hash); InternalTimer(gettimeofday()+50, "harmony_ping", $hash, 0); @@ -893,7 +903,7 @@ harmony_Read($) if( ($tag eq "iq" && $content =~ m/statedigest\?get'/) || ($tag eq "message" && $content =~ m/type="connect.stateDigest\?notify"/) ) { - Log3 $name, 4, "$name: notify: $cdata"; + Log3 $name, 4, "$name: statedigest: $cdata"; if( $decoded ) { if( defined($decoded->{syncStatus}) ) { @@ -902,10 +912,14 @@ harmony_Read($) $hash->{syncStatus} = $decoded->{syncStatus}; } + if( defined($decoded->{hubUpdate}) && $decoded->{hubUpdate} eq "true" && !$hash->{hubUpdate} ) { + harmony_sendIq($hash, "format=json"); + } + $hash->{activityStatus} = $decoded->{activityStatus} if( defined($decoded->{activityStatus}) ); $hash->{hubSwVersion} = $decoded->{hubSwVersion} if( defined($decoded->{hubSwVersion}) ); - $hash->{hubUpdate} = $decoded->{hubUpdate} if( defined($decoded->{hubUpdate}) ); + $hash->{hubUpdate} = ($decoded->{hubUpdate} eq 'true'?1:0) if( defined($decoded->{hubUpdate}) ); my $modifier = ""; $modifier = "starting " if( $hash->{activityStatus} == 1 ); @@ -981,6 +995,23 @@ harmony_Read($) } elsif( $content =~ m/engine\?gettimerinterval/ && $decoded ) { $hash->{sleeptimer} = FmtDateTime( gettimeofday() + $decoded->{interval} ); + } elsif( $content =~ m/firmware\?/ && $decoded ) { + Log3 $name, 4, "$name: firmware: $cdata"; + + if( $decoded->{status} && $decoded->{newVersion} ) { + $hash->{newVersion} = $decoded->{newVersion}; + + my $txt = $decoded->{newVersion}; + $txt .= ", isCritical: $decoded->{isCritical}"; + $txt .= ", bytes: $decoded->{totalBytes}"; + + readingsSingleUpdate( $hash, "newVersion", $txt, 1 ) if( $txt ne ReadingsVal($hash->{NAME},"newVersion", "" ) ); + + } else { + delete $hash->{newVersion}; + + } + } elsif( $content =~ m/\?config/ && $decoded ) { $hash->{config} = $decoded; Log3 $name, 3, "$name: new config "; @@ -1623,6 +1654,8 @@ harmony_Attr($$$) the name of the currently selected activity.
  • previousActivity
    the name of the previous selected activity. does not trigger an event.
  • +
  • newVersion
    + will be set if a new firmware version is avaliable.

  • @@ -1672,6 +1705,8 @@ harmony_Attr($$$)
  • autocreate [<id>|<name>]
    creates a fhem device for a single/all device(s) in the harmony hub. if activities are startet the state of these devices will be updatet with the power state defined in these activites.
  • +
  • update
    + triggers a firmware update. only available if a new firmware is available.
  • The command, hidDevice, text, cursor and special commmands are also available for the autocreated devices. The <id>|<name> paramter hast to be omitted.