From a98dc940e76272f7b9f185a5775f3ae8a6fddc3a Mon Sep 17 00:00:00 2001 From: justme1968 Date: Wed, 15 May 2013 14:33:26 +0000 Subject: [PATCH] allow starting of bridge firmware update git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@3181 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/30_HUEBridge.pm | 26 +++++++++++++++++++++++--- fhem/FHEM/31_HUEDevice.pm | 2 +- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 9a97c6eb4..03bd5b736 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII - SVN + - feature: HUEBridge: allow starting of bridge firmware update - change: EnOcean: profil PM101 changed, old profiles FAH, FBH, FTF, SR04 removed - feature: TCM: new attr blockSenderID: Block receiving telegrams with a TCM SenderID sent by repeaters diff --git a/fhem/FHEM/30_HUEBridge.pm b/fhem/FHEM/30_HUEBridge.pm index e97e3e678..cf5c19780 100644 --- a/fhem/FHEM/30_HUEBridge.pm +++ b/fhem/FHEM/30_HUEBridge.pm @@ -149,8 +149,23 @@ HUEBridge_Set($@) RemoveInternalTimer($hash); HUEBridge_GetUpdate($hash); return undef; + } elsif($cmd eq 'swupdate') { + my $obj = { + 'swupdate' => { 'updatestate' => 3, }, + }; + my $result = HUEBridge_Call($hash, 'config', $obj); + + if( !defined($result) || $result->{'error'} ) { + return $result->{'error'}->{'description'}; + } + + $hash->{updatestate} = 3; + $hash->{STATE} = "updating"; + return "starting update"; } else { - return "Unknown argument $cmd, choose one of statusRequest"; + my $list = "statusRequest"; + $list .= " swupdate" if( defined($hash->{updatestate}) && $hash->{updatestate} == 2 ); + return "Unknown argument $cmd, choose one of $list"; } } @@ -191,7 +206,10 @@ HUEBridge_GetUpdate($) if( defined( $result->{swupdate} ) ) { my $txt = $result->{swupdate}->{text}; - readingsSingleUpdate($hash, "swupdate", $txt, defined($hash->{LOCAL} ? 0 : 1)) if( $txt ne ReadingsVal($name,"swupdate","") ); + readingsSingleUpdate($hash, "swupdate", $txt, defined($hash->{LOCAL} ? 0 : 1)) if( $txt && $txt ne ReadingsVal($name,"swupdate","") ); + $hash->{STATE} = "update done" if( $result->{swupdate}->{updatestate} == 0 && $hash->{updatestate} >= 2 ); + $hash->{STATE} = "update failed" if( $result->{swupdate}->{updatestate} == 2 && $hash->{updatestate} == 3 ); + $hash->{updatestate} = $result->{swupdate}->{updatestate}; } elsif ( defined( $hash->{swupdate} ) ) { delete( $hash->{updatestate} ); @@ -419,7 +437,7 @@ HUEBridge_HTTP_Request($$$@) $ret=~ s/(.*?)\r\n\r\n//s; # Not greedy: switch off the header. my @header= split("\r\n", $1); my $hostpath= $quiet ? "" : $host . $path; - Log 4, "HUEBridge_HTTP_Request $displayurl: Got data, length: ".length($ret); + Log 5, "HUEBridge_HTTP_Request $displayurl: Got data, length: ".length($ret); if(!length($ret)) { Log 4, "HUEBridge_HTTP_Request $displayurl: Zero length data, header follows..."; for (@header) { @@ -489,6 +507,8 @@ HUEBridge_HTTP_Request($$$@)

diff --git a/fhem/FHEM/31_HUEDevice.pm b/fhem/FHEM/31_HUEDevice.pm index 815d8aacc..8843f3fbe 100644 --- a/fhem/FHEM/31_HUEDevice.pm +++ b/fhem/FHEM/31_HUEDevice.pm @@ -120,7 +120,7 @@ sub HUEDevice_Define($$) $hash->{fhem}{xy} = ''; - $attr{$name}{devStateIcon} = '{CommandGet("","'.$name.' devStateIcon")}' if( !defined( $attr{$name}{devStateIcon} ) ); + $attr{$name}{devStateIcon} = '{(CommandGet("","'.$name.' devStateIcon"),"toggle")}' if( !defined( $attr{$name}{devStateIcon} ) ); AssignIoPort($hash); if(defined($hash->{IODev}->{NAME})) {