From c902e29e5fc1b8edc1a7b667b9943938befdb1ff Mon Sep 17 00:00:00 2001 From: justme-1968 Date: Thu, 31 Jan 2019 17:45:22 +0000 Subject: [PATCH] 31_LightScene.pm: addeed clear command git-svn-id: https://svn.fhem.de/fhem/trunk@18469 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/31_LightScene.pm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fhem/FHEM/31_LightScene.pm b/fhem/FHEM/31_LightScene.pm index 9bef554c7..e19affccd 100644 --- a/fhem/FHEM/31_LightScene.pm +++ b/fhem/FHEM/31_LightScene.pm @@ -599,7 +599,7 @@ 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) ." all nextScene:noArg previousScene:noArg"}; + if( $cmd eq "?" ){ return "Unknown argument ?, choose one of clear 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 " }; @@ -607,7 +607,14 @@ LightScene_Set($@) if( $cmd eq "remove" && !defined( $scene ) ) { return "Usage: set $name remove " }; if( $cmd eq "rename" && !defined( $scene ) ) { return "Usage: set $name rename " }; - if( $cmd eq "remove" ) { + if( $cmd eq "clear" ) { + foreach my $s (keys %{ $hash->{SCENES} }) { + next if( $scene && $s !~ m/^$scene$/ ); + delete $hash->{SCENES}{$s}; + } + return undef; + + } elsif( $cmd eq "remove" ) { return "no such scene: $scene" if( !defined $hash->{SCENES}{$scene} ); delete( $hash->{SCENES}{$scene} ); return undef; @@ -1063,6 +1070,8 @@ LightScene_editTable($) {
  • 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
  • +
  • clear [<regex>]
    + clears all scenes or all scenes matching <regex> from list of saved scenes
  • remove <scene_name>
    remove <scene_name> from list of saved scenes
  • rename <scene_old_name> <scene_new_name>