From fe83da85ad4c99fea892c7b9b1eeccb693b5f06f Mon Sep 17 00:00:00 2001 From: justme-1968 Date: Sat, 23 Sep 2017 17:20:38 +0000 Subject: [PATCH] 30_HUEBridge: added set inactive/active commands, create event for lastError reading git-svn-id: https://svn.fhem.de/fhem/trunk@15123 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 2 ++ fhem/FHEM/30_HUEBridge.pm | 29 ++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index acd565cfc..b49b9f9f7 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,7 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - changed: 30_HUEBridge: added set inactive/active commands + create event for lastError reading - change: 93_DbLog: V2.22.6 commandref revised - new: 73_UpsPico: New module for UpsPico UPS from pimodules - feature: LightScene: added traversalOrder attribute diff --git a/fhem/FHEM/30_HUEBridge.pm b/fhem/FHEM/30_HUEBridge.pm index 667112edd..b515df0cb 100644 --- a/fhem/FHEM/30_HUEBridge.pm +++ b/fhem/FHEM/30_HUEBridge.pm @@ -139,7 +139,7 @@ HUEBridge_Notify($$) return if(!grep(m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}})); if( IsDisabled($name) > 0 ) { - readingsSingleUpdate($hash, 'state', 'disabled', 1 ) if( ReadingsVal($name,'state','' ) ne 'disabled' ); + readingsSingleUpdate($hash, 'state', 'inactive', 1 ) if( ReadingsVal($name,'inactive','' ) ne 'disabled' ); return undef; } @@ -624,9 +624,19 @@ HUEBridge_Set($@) return undef; + } elsif($cmd eq 'active') { + return "can't activate disabled bridge." if(AttrVal($name, "disable", undef)); + + readingsSingleUpdate($hash, 'state', 'active', 1 ); + HUEBridge_OpenDev($hash); + return undef; + + } elsif($cmd eq 'inactive') { + readingsSingleUpdate($hash, 'state', 'inactive', 1 ); + return undef; } else { - my $list = "delete creategroup deletegroup savescene deletescene modifyscene scene createrule updaterule deleterule createsensor deletesensor configsensor setsensor deletewhitelist touchlink:noArg checkforupdate:noArg autodetect:noArg autocreate:noArg statusRequest:noArg"; + my $list = "active inactive delete creategroup deletegroup savescene deletescene modifyscene scene createrule updaterule deleterule createsensor deletesensor configsensor setsensor deletewhitelist touchlink:noArg checkforupdate:noArg autodetect:noArg autocreate:noArg statusRequest:noArg"; $list .= " swupdate:noArg" if( defined($hash->{updatestate}) && $hash->{updatestate} =~ '^2' ); return "Unknown argument $cmd, choose one of $list"; } @@ -948,7 +958,7 @@ sub HUEBridge_ProcessResponse($$) { my $error = $obj->[0]->{error}->{'description'}; - readingsSingleUpdate($hash, 'lastError', $error, 0 ); + readingsSingleUpdate($hash, 'lastError', $error, 1 ); } if( !AttrVal( $name,'queryAfterSet', 1 ) ) { @@ -1029,7 +1039,7 @@ HUEBridge_Call($$$$;$) my $name = $hash->{NAME}; if( IsDisabled($name) ) { - readingsSingleUpdate($hash, 'state', 'disabled', 1 ) if( ReadingsVal($name,'state','' ) ne 'disabled' ); + readingsSingleUpdate($hash, 'state', 'inactive', 1 ) if( ReadingsVal($name,'state','' ) ne 'inactive' ); return undef; } @@ -1234,7 +1244,7 @@ HUEBridge_dispatch($$$;$) { my $error = $json->[0]->{error}->{'description'}; - readingsSingleUpdate($hash, 'lastError', $error, 0 ); + readingsSingleUpdate($hash, 'lastError', $error, 1 ); Log3 $name, 3, $error; } @@ -1593,6 +1603,15 @@ HUEBridge_Attr($$$) available (indicated by updatestate with a value of 2. The version and release date is shown in the reading swupdate.
A notify of the form define HUEUpdate notify bridge:swupdate.* {...} can be used to be informed about available firmware updates.
+
  • inactive
    + inactivates the current device. note the slight difference to the + disable attribute: using set inactive the state is automatically saved + to the statefile on shutdown, there is no explicit save necesary.
    + this command is intended to be used by scripts to temporarily + deactivate the harmony device.
    + the concurrent setting of the disable attribute is not recommended.
  • +
  • active
    + activates the current device (see inactive).