From 6cb423d6fe5c0e5e270ae9584eac5d5386fc4ec9 Mon Sep 17 00:00:00 2001 From: dev0 <> Date: Mon, 7 Aug 2017 05:01:01 +0000 Subject: [PATCH] 34_ESPEasy.pm: plugin neopixelfx/nfx added (Forum #73949) git-svn-id: https://svn.fhem.de/fhem/trunk@14859 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/34_ESPEasy.pm | 152 +++++++++++++++++++++++++++++++++++----- 2 files changed, 135 insertions(+), 18 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 0c371c217..491f497f2 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: 34_ESPEasy.pm: plugin neopixelfx/nfx added (Forum #73949) - new: 31_Nello: first release - feature: 01_FHEMWEB.pm: add webCmdLabel (Forum #72581) - changed: fhem.pl: search cmds via lowercase/abbrev in modules (Forum #75007) diff --git a/fhem/FHEM/34_ESPEasy.pm b/fhem/FHEM/34_ESPEasy.pm index 0f971f3c2..dfea76fe3 100644 --- a/fhem/FHEM/34_ESPEasy.pm +++ b/fhem/FHEM/34_ESPEasy.pm @@ -36,7 +36,7 @@ use Color; # ------------------------------------------------------------------------------ # global/default values # ------------------------------------------------------------------------------ -my $module_version = "1.23"; # Version of this module +my $module_version = "1.30"; # Version of this module my $minEEBuild = 128; # informational my $minJsonVersion = 1.02; # checked in received data @@ -105,10 +105,15 @@ my %ESPEasy_setCmds = ( "buzzer" => "0", "inputswitchstate" => "0", # _0P001_Switch.ini "event" => "1", - "neopixelfx" => "1" - + "nfx" => "1" ); +my @ESPEasy_maplightCmds = + qw( on off toggle pct ct rgb dim line one all fade colorfade rainbow kitt + comet theatre scan dualscan twinkle twinklefade sparkle wipe fire stop + fadetime fadedelay count speed bgcolor + ); + # ------------------------------------------------------------------------------ # "setCmds" => "syntax", ESPEasy_paramPos() will parse for some <.*> positions # ------------------------------------------------------------------------------ @@ -156,16 +161,40 @@ my %ESPEasy_setCmdsUsage = ( "buzzer" => "buzzer", "inputswitchstate" => "inputswitchstate", "event" => "event ", #Forum #73291 - "neopixelfx" => "neopixelfx ", #Forum #73949 + "nfx" => "nfx ", #Forum #73949 #Lights - "rgb" => "rgb [fadetime]", + "rgb" => "rgb [fadetime] [delay +/-ms]", "pct" => "pct [fadetime]", "ct" => "ct [fadetime] [pct bri]", - "on" => "on [fadetime]", - "off" => "off [fadetime]", - "toggle" => "toggle [fadetime]" + "on" => "on [fadetime] [delay +/-ms]", + "off" => "off [fadetime] [delay +/-ms]", + "toggle" => "toggle [fadetime]", + # more light related commands - Forum #73949 + "dim" => "dim ", + "line" => "line ", + "one" => "one ", + "all" => "all [fadetime] [delay +/-ms]", + "fade" => "fade [fadetime ms] [delay +/-ms]", + "colorfade" => "colorfade [startpixel] [endpixel]", + "rainbow" => "rainbow [speed +/- 0-50]", + "kitt" => "kitt [speed 0-50]", + "comet" => "comet [speed +/- 0-50]", + "theatre" => "theatre [rrggbb background] [speed +/- 0-50]", + "scan" => "scan [rrggbb background] [speed 0-50]", + "dualscan" => "dualscan [rrggbb background] [speed 0-50]", + "twinkle" => "twinkle [rrggbb background] [speed 0-50]", + "twinklefade" => "twinklefade [number of pixels] [speed 0-50]", + "sparkle" => "sparkle [rrggbb background] [speed 0-50]", + "wipe" => "wipe [rrggbb dot] [speed +/- 0-50]", + "fire" => "fire [fps] [brightness 0-255] [cooling 20-100] [sparking 50-200]", + "stop" => "stop", + "fadetime" => "fadetime ", + "fadedelay" => "fadedelay ", + "count" => "count ", + "speed" => "speed ", + "bgcolor" => "bgcolor " ); # ------------------------------------------------------------------------------ @@ -490,7 +519,8 @@ sub ESPEasy_Set($$@) } #Lights Plugin - if (defined AttrVal($name,"mapLightCmds",undef) && $cmd =~ m/^(ct|pct|rgb|on|off|toggle)$/i) { + my $lightCmds = join("|",@ESPEasy_maplightCmds); + if (defined AttrVal($name,"mapLightCmds",undef) && $cmd =~ m/^$lightCmds$/i) { unshift @params, $cmd; $cmd = lc AttrVal($name,"mapLightCmds",""); } @@ -513,18 +543,34 @@ sub ESPEasy_Set($$@) my $clist = join(" ", @cList); my $hlist = join(",", @cList); foreach (@cList) {$clist =~ s/ $_/ $_:noArg/ if $ESPEasy_setCmds{$_} == 0} - # expand rgb - my $cp = AttrVal($name,"colorpicker","HSVp"); - $clist =~ s/rgb/rgb:colorpicker,$cp/; # add colorPicker if rgb cmd is available # expand ct my $ct = "ct:colorpicker,CT," .AttrVal($name,"ctWW_reducedRange",AttrVal($name,"colorpickerCTww",$d_colorpickerCTww)) .",10," .AttrVal($name,"ctCW_reducedRange",AttrVal($name,"colorpickerCTcw",$d_colorpickerCTcw)); $clist =~ s/ct /$ct /; - # expand pct + # expand colorpicker + my $cp = AttrVal($name,"colorpicker","HSVp"); + my $cpRepl = "rgb|bgcolor|fade|all|comet|twinkle|twinklefade|sparkle|theatre|scan|dualscan|wipe"; + $clist =~ s/(($cpRepl)\s)/$2:colorpicker,$cp /g; # add colorPicker if rgb cmd is available + # expand pct colorpicker widget (-100) my $pct = "pct:colorpicker,BRI,0,1,100"; $clist =~ s/pct /$pct /; + # expand dim colorpicker widget (-255) + my $dim = "dim:colorpicker,BRI,0,1,255"; + $clist =~ s/dim /$dim /; + # slider for some values... + my $fadetime = "fadetime:slider,0,100,10000"; + $clist =~ s/fadetime /$fadetime /; + my $fadedelay = "fadedelay:slider,-5000,10,5000"; + $clist =~ s/fadedelay /$fadedelay /; + my $speed = "speed:slider,-50,1,50"; + $clist =~ s/speed /$speed /; + my $count = "count:slider,1,1,50"; + $clist =~ s/count /$count /; + my $rainbow = "rainbow:slider,-10,1,10"; + $clist =~ s/rainbow/$rainbow/; + # expand help $clist =~ s/help/help:$hlist/; Log3 $name, 2, "$type $name: Unknown set command $cmd" if $cmd ne "?"; @@ -1442,8 +1488,9 @@ sub ESPEasy_httpReqParse($$$) # maps plugin type (answer for set state/gpio) to SENSOR_TYPE_SWITCH # 10 = SENSOR_TYPE_SWITCH my $vType = (defined $res->{plugin} && $res->{plugin} eq "1") ? "10" : "0"; - if (defined $res->{plugin} && $res->{plugin} eq "123") { - # Lights plugin (eq 123) + + # Plugin lights:123 nfx:124 + if (defined $res->{plugin} && $res->{plugin} =~ m/^(123|124)$/) { foreach (keys %{ $res }) { push @values, "r||$_||".$res->{$_}."||".$vType if $res->{$_} ne "" && $_ ne "plugin"; @@ -2148,6 +2195,30 @@ sub ESPEasy_adjustSetCmds($) delete $ESPEasy_setCmds{on}; delete $ESPEasy_setCmds{off}; delete $ESPEasy_setCmds{toggle}; + + delete $ESPEasy_setCmds{dim}; + delete $ESPEasy_setCmds{line}; + delete $ESPEasy_setCmds{one}; + delete $ESPEasy_setCmds{all}; + delete $ESPEasy_setCmds{fade}; + delete $ESPEasy_setCmds{colorfade}; + delete $ESPEasy_setCmds{rainbow}; + delete $ESPEasy_setCmds{kitt}; + delete $ESPEasy_setCmds{comet}; + delete $ESPEasy_setCmds{theatre}; + delete $ESPEasy_setCmds{scan}; + delete $ESPEasy_setCmds{dualscan}; + delete $ESPEasy_setCmds{twinkle}; + delete $ESPEasy_setCmds{twinklefade}; + delete $ESPEasy_setCmds{sparkle}; + delete $ESPEasy_setCmds{wipe}; + delete $ESPEasy_setCmds{fire}; + delete $ESPEasy_setCmds{stop}; + delete $ESPEasy_setCmds{fadetime}; + delete $ESPEasy_setCmds{fadedelay}; + delete $ESPEasy_setCmds{count}; + delete $ESPEasy_setCmds{speed}; + delete $ESPEasy_setCmds{bgcolor}; if (defined AttrVal($name,"mapLightCmds",undef)) { $ESPEasy_setCmds{rgb} = 1; @@ -2156,6 +2227,31 @@ sub ESPEasy_adjustSetCmds($) $ESPEasy_setCmds{on} = 0; $ESPEasy_setCmds{off} = 0; $ESPEasy_setCmds{toggle} = 0; + + # used by nfx plugin + $ESPEasy_setCmds{dim} = 1; + $ESPEasy_setCmds{line} = 3; + $ESPEasy_setCmds{one} = 2; + $ESPEasy_setCmds{all} = 1; + $ESPEasy_setCmds{fade} = 1; + $ESPEasy_setCmds{colorfade}= 2; + $ESPEasy_setCmds{rainbow} = 0; + $ESPEasy_setCmds{kitt} = 1; + $ESPEasy_setCmds{comet} = 1; + $ESPEasy_setCmds{theatre} = 1; + $ESPEasy_setCmds{scan} = 1; + $ESPEasy_setCmds{dualscan} = 1; + $ESPEasy_setCmds{twinkle} = 1; + $ESPEasy_setCmds{twinklefade} = 1; + $ESPEasy_setCmds{sparkle} = 1; + $ESPEasy_setCmds{wipe} = 1; + $ESPEasy_setCmds{fire} = 0; + $ESPEasy_setCmds{stop} = 0; + $ESPEasy_setCmds{fadetime} = 1; + $ESPEasy_setCmds{fadedelay}= 1; + $ESPEasy_setCmds{speed} = 1; + $ESPEasy_setCmds{count} = 1; + $ESPEasy_setCmds{bgcolor} = 1; } if (defined AttrVal($name,"rgbGPIOs",undef)) { $ESPEasy_setCmds{rgb} = 1; @@ -3197,6 +3293,23 @@ sub ESPEasy_removeGit($)
+
  • nfx (plugin can be found + here)
    + Control nfx plugin
    + Note: To use FHEMWEB's colorpicker and slider widgets you have to set + Attribut mapLightCmds. +
      +
    • arguments: <off|on|dim|line|one|all|rgb|fade|colorfade|rainbow|kitt|comet|theatre|scan|dualscan|twinkle|twinklefade|sparkle|wipe|fire|stop|statusrequest|fadetime|fadedelay|speed|count|bgcolor> [<rgb>] [<fadeing time>] [<delay time>]
    • +
    • examples:
      + + set <esp> nfx all 00ff00 100
      + set <esp> nfx rgb aa00ff 1000 10
      + set <esp> nfx line 0 100 f0f0f0c
      +
      +
    • +
    +

  • +
  • candle
    Control candle rgb plugin
      @@ -3478,9 +3591,12 @@ sub ESPEasy_removeGit($)
    • mapLightCmds
      Enable the following commands and map them to the specified ESPEasy - command: rgb, ct, pct, on, off, toggle
      - Needed if you want to use FHEM's colorpickers to control a rgb/ct ESPEasy - plugin.
      + command: rgb, ct, pct, on, off, toggle, dim, line, one, all, fade, + colorfade, rainbow, kitt, comet, theatre, scan, dualscan, twinkle, + twinklefade, sparkle, wipe, fire, stop, fadetime, fadedelay, count, speed, + bgcolor. Ask the ESPEasy maintainer to add more if required.
      + Needed to use FHEM's colorpicker or slider widgets to control a + rgb/ct/effect/... plugin.
      required values: a valid set command
      eg. attr <esp> mapLightCmds Lights