From 7f5a74a3b17ac9bc31f60756106513690318c989 Mon Sep 17 00:00:00 2001 From: sidey79 Date: Fri, 6 Dec 2019 20:43:40 +0000 Subject: [PATCH] 14_SD_RSL.PM: support for setExtensions added git-svn-id: https://svn.fhem.de/fhem/trunk@20671 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/14_SD_RSL.pm | 77 +++++++++++++++++++----------------------- 2 files changed, 35 insertions(+), 43 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index a9208eeb0..8545878a3 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: 14_SD_RSL.PM: support for setExtensions added - change: 59_Weather: delete table options in commandref - bugfix: 73_AutoShuttersControl: fix Commandref, skip ExternalTrigger Drive from adv check diff --git a/fhem/FHEM/14_SD_RSL.pm b/fhem/FHEM/14_SD_RSL.pm index da7822dd3..560006b3b 100644 --- a/fhem/FHEM/14_SD_RSL.pm +++ b/fhem/FHEM/14_SD_RSL.pm @@ -7,15 +7,19 @@ # 2019 - Ralf9 & Sidey79 # # Supports following devices: -# - Conrad RSL +# - Conrad RSL ##################################################################### package main; use strict; use warnings; +use SetExtensions; -my %sets = ( "on:noArg" => "", "off:noArg" => ""); +my %sets = ( + "on" => sub { return $_[0]->{OnCode}; }, + "off" => sub { return $_[0]->{OffCode}; } + ); my @RSLCodes; @@ -113,35 +117,25 @@ sub SD_RSL_Define($$) { ########################################################## sub SD_RSL_Set($@) { - my ($hash, $name, @a) = @_; - my $ioHash = $hash->{IODev}; - my $ioName = $ioHash->{NAME}; - my $cmd = $a[0]; - my $c; - my $message; - my $device = substr($hash->{DEF},0,6); + my ($hash, $name, @a) = @_; + my $cmd = $a[0]; + return "\"set $name\" needs at least one argument" unless(defined($cmd)); - return join(" ", sort keys %sets) if((@a < 1) || ($cmd eq "?")); - - $c = $hash->{OnCode} if ($cmd eq "on") ; - $c = $hash->{OffCode} if ($cmd eq "off"); - - return "Unknown argument $cmd, choose on or off" if(!$c); - - ## Send Message to IODev using IOWrite - $message = 'P1#0x' . $c . $device . '#R' . AttrVal($name, "RSLrepetition", 6); - Log3 $name, 3, "$ioName RSL_set: $name $cmd -> sendMsg: $message"; - IOWrite($hash, 'sendMsg', $message); - #my $ret = IOWrite($hash, 'sendMsg', $c."_".AttrVal($name, "RSLrepetition", 6)); - #Log3 $hash, 5, "$name Set return : $ret"; - - #if (($cmd eq "on") && ($hash->{STATE} eq "off")){$cmd = "stop";} - #if (($cmd eq "off") && ($hash->{STATE} eq "on")) {$cmd = "stop";} - - #$hash->{CHANGED}[0] = $cmd; - #$hash->{STATE} = $cmd; - readingsSingleUpdate($hash,"state",$cmd,1); - return undef; + my $cmdList= join(" ", map { "$_:noArg" } sort keys %sets); + if (exists($sets{$cmd})) { + my $ioHash = $hash->{IODev}; + my $ioName = $ioHash->{NAME}; + my $device = substr($hash->{DEF},0,6); + my $c= $sets{$cmd}->($hash,@a); + my $message = 'P1#0x' . $c . $device . '#R' . AttrVal($name, "RSLrepetition", 6); + Log3 $name, 3, "$ioName RSL_set: $name $cmd -> sendMsg: $message"; + IOWrite($hash, 'sendMsg', $message); + readingsSingleUpdate($hash,"state",$cmd,1); + } else { + return SetExtensions($hash, $cmdList, $name, @a) + } + + return undef; } ################################################################### @@ -207,7 +201,7 @@ sub SD_RSL_Parse($$) { Log3 $hash, 4, "$name: SD_RSL_Parse - Device: $deviceCode Action: $action"; - $modules{SD_RSL}{defptr}{ioname} = $name; + $modules{SD_RSL}{defptr}{ioname} = $name; my $def = $modules{SD_RSL}{defptr}{$hash->{NAME} . "." . $deviceCode}; $def = $modules{SD_RSL}{defptr}{$deviceCode} if(!$def); @@ -243,6 +237,7 @@ sub SD_RSL_Parse($$) { ######################################################## sub SD_RSL_Undef($$) { my ($hash, $name) = @_; + SetExtensionsCancel($hash); delete($modules{SD_RSL}{defptr}{$hash->{DEF}}) if($hash && $hash->{DEF}); return undef; } @@ -296,13 +291,11 @@ If autocreate is used, a device "<code>_ALL" like RSL_74A400_ALL Set Get @@ -350,13 +343,11 @@ Beim Verwendung von Autocreate wird bei der Taste All anstatt channel und button Set Get