From 5cadf7b70f282dd545ab100e2cb88a0d8d050fea Mon Sep 17 00:00:00 2001 From: justme-1968 Date: Thu, 28 Sep 2017 06:28:07 +0000 Subject: [PATCH] 31_LightScene.pm: added set all command git-svn-id: https://svn.fhem.de/fhem/trunk@15146 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/31_LightScene.pm | 33 +++++++++++++++++++++++---------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 85ae9a4c3..555cd1b16 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # 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. + - feature: LightScene: added set all command - feature: 49_SSCam: V3.0.0, new concept - differ between CAM-/SVS-device, version is downwardly compatible, but homeMode-commands are moved from CAM to SVS-device - ! SEE COMMANDREF ! diff --git a/fhem/FHEM/31_LightScene.pm b/fhem/FHEM/31_LightScene.pm index 7b11c7f47..8eb90621d 100644 --- a/fhem/FHEM/31_LightScene.pm +++ b/fhem/FHEM/31_LightScene.pm @@ -590,8 +590,9 @@ LightScene_Set($@) my @sorted = sort keys %{$hash->{SCENES}}; - if( $cmd eq "?" ){ return "Unknown argument ?, choose one of remove:".join(",", @sorted) ." rename save set setcmd scene:".join(",", @sorted) ." nextScene:noArg previousScene:noArg"}; + if( $cmd eq "?" ){ return "Unknown argument ?, choose one of remove:".join(",", @sorted) ." rename save set setcmd scene:".join(",", @sorted) ." all nextScene:noArg previousScene:noArg"}; + if( $cmd eq "all" && !defined( $scene ) ) { return "Usage: set $name all " }; if( $cmd eq "save" && !defined( $scene ) ) { return "Usage: set $name save " }; if( $cmd eq "scene" && !defined( $scene ) ) { return "Usage: set $name scene " }; if( $cmd eq "remove" && !defined( $scene ) ) { return "Usage: set $name remove " }; @@ -671,7 +672,8 @@ LightScene_Set($@) $hash->{INSET} = 1; my @devices; - if( $cmd eq "scene" && defined($hash->{switchingOrder}) && defined($hash->{switchingOrder}{$scene}) ) { + if( ( $cmd eq "scene" || $cmd eq "all" ) + && defined($hash->{switchingOrder}) && defined($hash->{switchingOrder}{$scene}) ) { @devices = @{$hash->{switchingOrder}{$scene}}; } else { @devices = @{$hash->{devices}}; @@ -725,6 +727,13 @@ LightScene_Set($@) $count += $switched; $ret .= $rr // ""; } + + } elsif ( $cmd eq "all" ) { + $ret .= " " if( $ret ); + my($rr,$switched) = LightScene_RestoreDevice($hash,$d,"$scene ".join(" ", @a)); + $count += $switched; + $ret .= $rr // ""; + } else { $ret = "Unknown argument $cmd, choose one of save scene"; } @@ -733,6 +742,8 @@ LightScene_Set($@) if( $cmd eq "scene" ) { readingsSingleUpdate($hash, "state", $scene, 1 ) if( !$hash->{followDevices} || $count == 0 ); + } elsif( $cmd eq "all" ) { + readingsSingleUpdate($hash, "state", "all $scene ".join(" ", @a), 1 ) if( !$hash->{followDevices} || $count == 0 ); } delete($hash->{INSET}); @@ -1019,27 +1030,29 @@ LightScene_editTable($) { Set
    +
  • all <command>
    + execute set <command> for alle devices in this LightScene
  • save <scene_name>
    - save current state for alle devices in this LightScene to <scene_name>
  • + save current state for alle devices in this LightScene to <scene_name>
  • scene <scene_name>
    - shows scene <scene_name> - all devices are switched to the previously saved state
  • + shows scene <scene_name> - all devices are switched to the previously saved state
  • nextScene [nowrap]
    - activates the next scene in alphabetical order after the current scene or the first if no current scene is set.
  • + activates the next scene in alphabetical order after the current scene or the first if no current scene is set.
  • previousScene [nowrap]
    - activates the previous scene in alphabetical order before the current scene or the last if no current scene is set.
  • + activates the previous scene in alphabetical order before the current scene or the last if no current scene is set.
  • set <scene_name> <device> [<cmd>]
    - set the saved state of <device> in <scene_name> to <cmd>
  • + set the saved state of <device> in <scene_name> to <cmd>
  • setcmd <scene_name> <device> [<cmd>]
    - set command to be executed for <device> in <scene_name> to <cmd>. + set command to be executed for <device> in <scene_name> to <cmd>. <cmd> can be any commandline that fhem understands including multiple commands separated by ;;
    • set kino_group setcmd allOff LampeDecke sleep 30 ;; set LampeDecke off
    • set light_group setcmd test Lampe1 sleep 10 ;; set Lampe1 on ;; sleep 5 ;; set Lampe1 off
  • remove <scene_name>
    - remove <scene_name> from list of saved scenes
  • + remove <scene_name> from list of saved scenes
  • rename <scene_old_name> <scene_new_name>
    - rename <scene_old_name> to <scene_new_name>
  • + rename <scene_old_name> to <scene_new_name>