From 0138f177424575a7c1d76d36ea74211e82817efa Mon Sep 17 00:00:00 2001 From: telekatz <> Date: Tue, 1 Dec 2015 20:01:05 +0000 Subject: [PATCH] 30_DUOFERN: add toggle functions git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@10069 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- FHEM/30_DUOFERN.pm | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/FHEM/30_DUOFERN.pm b/FHEM/30_DUOFERN.pm index 15c7b3c39..c295226d5 100644 --- a/FHEM/30_DUOFERN.pm +++ b/FHEM/30_DUOFERN.pm @@ -107,6 +107,7 @@ my %commands = ( "up" => "071400FE000000"}, "windDirection" => {"down" => "071500FD000000", "up" => "071500FE000000"}, + "toggle" => {"noArg" => "071A0000000000"}, "slatPosition" => {"value" => "071B00000000nn"}, "sunAutomatic" => {"on" => "080100FD000000", "off" => "080100FE000000"}, @@ -184,6 +185,7 @@ my %setsDefaultRollerShutter = ( "up:noArg" => "", "down:noArg" => "", "stop:noArg" => "", + "toggle:noArg" => "", "dusk:noArg" => "", "dawn:noArg" => "", "sunMode:on,off" => "", @@ -328,7 +330,7 @@ DUOFERN_Initialize($) $hash->{ParseFn} = "DUOFERN_Parse"; $hash->{RenameFn} = "DUOFERN_Rename"; $hash->{AttrFn} = "DUOFERN_Attr"; - $hash->{AttrList} = "IODev timeout ". $readingFnAttributes; + $hash->{AttrList} = "IODev timeout toggleUpDown ". $readingFnAttributes; #$hash->{AutoCreate}= # { "DUOFERN" => { GPLOT => "", FILTER => "%NAME" } }; } @@ -435,6 +437,32 @@ DUOFERN_Set($@) return "Wrong argument $arg" if (!exists $commands{$cmd}{$subCmd}); + my $toggleUpDown = AttrVal($name, "toggleUpDown", "0"); + my $moving = ReadingsVal($name, "moving", "stop"); + my $position = ReadingsVal($name, "position", 50); + my $timeAutomatic = ReadingsVal($name, "timeAutomatic", "on"); + my $dawnAutomatic = ReadingsVal($name, "dawnAutomatic", "on"); + my $duskAutomatic = ReadingsVal($name, "duskAutomatic", "on"); + + readingsSingleUpdate($hash, "moving", "moving", 1) if (($cmd eq "toggle") && ($moving eq "stop")); + readingsSingleUpdate($hash, "moving", "up", 1) if (($cmd eq "dawn") && ($dawnAutomatic eq "on")); + readingsSingleUpdate($hash, "moving", "down", 1) if (($cmd eq "dusk") && ($duskAutomatic eq "on")); + + if ($timer eq "00" || $timeAutomatic eq "on") { + if ($cmd =~ m/^(up|down)$/) { + $cmd = "stop" if (($moving ne "stop") && $toggleUpDown); + readingsSingleUpdate($hash, "moving", $cmd, 1); + } elsif ($cmd eq "position") { + if ($arg > $position) { + readingsSingleUpdate($hash, "moving", "down", 1); + } elsif ($arg < $position) { + readingsSingleUpdate($hash, "moving", "up", 1); + } else { + readingsSingleUpdate($hash, "moving", "stop", 1); + } + } + } + $command = $commands{$cmd}{$subCmd}; $buf =~ s/yyyyyy/$code/; @@ -662,6 +690,7 @@ DUOFERN_Parse($$) readingsBulkUpdate($hash, "manualMode", $manualMode, 1); readingsBulkUpdate($hash, "position", $pos , 1); readingsBulkUpdate($hash, "state", $state , 1); + readingsBulkUpdate($hash, "moving", "stop" , 1); readingsEndUpdate($hash, 1); # Notify is done by Dispatch @@ -801,7 +830,7 @@ DUOFERN_Parse($$) delete($hash->{READINGS}{slatPosition}); } - + readingsBulkUpdate($hash, "moving", "stop" , 1); readingsBulkUpdate($hash, "state", $state , 1); readingsEndUpdate($hash, 1); # Notify is done by Dispatch @@ -849,6 +878,7 @@ DUOFERN_Parse($$) readingsBulkUpdate($hash, "state", $state , 1); readingsBulkUpdate($hash, "obstacle", $obstacle , 1); readingsBulkUpdate($hash, "block", $block , 1); + readingsBulkUpdate($hash, "moving", "stop" , 1); if ($code =~ m/^4E..../) { #SX5 readingsBulkUpdate($hash, "10minuteAlarm", $alert10 , 1); @@ -1128,6 +1158,9 @@ DUOFERN_StatusTimeout($) Set roller shutter to a desired absolut level. If parameter timer is used the command will only be executed if timeAutomatic is activated.
+
  • toggle
    + Switch the roller shutter through the sequence up/stop/down/stop. +

  • on [timer]
    Switch on the actor. If parameter timer is used the command will only be executed if timeAutomatic is activated. @@ -1282,6 +1315,9 @@ DUOFERN_StatusTimeout($) up to two getStatus commands are resend.
    Default 60s.

  • +
  • toggleUpDown
    + If attribute is set, a stop command is send instead of the up or down command if the roller shutter is moving. +