From 8768b31dba6e42077502c14b8c8b1ee04b840d5d Mon Sep 17 00:00:00 2001
From: Byte09 <>
Date: Thu, 6 Sep 2018 03:24:26 +0000
Subject: [PATCH] 98_MSwitch.pm:update V1.75
git-svn-id: https://svn.fhem.de/fhem/trunk@17283 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/FHEM/98_MSwitch.pm | 574 ++++++++++++++++++++++++++++------------
1 file changed, 408 insertions(+), 166 deletions(-)
diff --git a/fhem/FHEM/98_MSwitch.pm b/fhem/FHEM/98_MSwitch.pm
index 084094706..35b869c21 100644
--- a/fhem/FHEM/98_MSwitch.pm
+++ b/fhem/FHEM/98_MSwitch.pm
@@ -36,7 +36,7 @@ use warnings;
use POSIX;
# Version #######################################################
-my $version = 'V1.74';
+my $version = 'V1.75';
my $vupdate = 'V 1.2';
my $savecount = 30;
my $standartstartdelay =60;
@@ -576,8 +576,39 @@ sub MSwitch_Get($$@) {
$ret =
"eingehender String:
$condstring
If Anweisung Perl:
$condstring1
";
$ret .= "If Anweisung Perl Klarzeiten:
$condmarker
"
- if $x > 0;
+
+
+ if $x > 0;
$ret .= $ret1;
+ my $condsplit = $condmarker;
+
+ my $reads ='
States der geprüften Readings:
';
+
+
+ #Log3( $name, 0,"condsplit - $condsplit". __LINE__ );
+
+
+ $x = 0; # exit
+ while ( $condsplit =~ m/(.*')(.*)',\s'(.*)',\s(.*)/ )
+ {
+
+ #Log3( $name, 0,"condsplit s1,s2,s3,s4 - $1 - $2 - $3 - $4". __LINE__ );
+
+ $x++; # exit
+ last if $x > 20; # exit
+ $reads .="Reading: [$2:$3] - Inhalt: ".ReadingsVal( $2, $3, 'undef' );
+
+ $reads .="
Reading nicht vorhanden !
" if (ReadingsVal( $2, $3, 'undef' )) eq "undef";
+ $reads .="
";
+
+ $condsplit = $1.$4;
+ }
+
+ #Log3( $name, 0,"reads - $reads". __LINE__ );
+
+ $ret .= $reads if $x > 0;
+
+
my $err1;
my $err2;
@@ -676,7 +707,51 @@ sub MSwitch_AsyncOutput ($) {
sub MSwitch_Set($@) {
my ( $hash, $name, $cmd, @args ) = @_;
+
return "" if ( IsDisabled($name) );# Return without any further action if the module is disabled
+ Log3( $name, 4,"$name Set: eingehend cmd - $cmd ");
+ Log3( $name, 4,"$name Set: eingehend argumente - @args ");
+
+
+ # verry special commands readingactivated
+ my $special='';
+ if (ReadingsVal( $name, 'AcceptPCT', '') eq 'on')
+ {
+ $special='pct:slider,0,1,100';
+ my $arg = $args[0];
+ if ($cmd eq "pct" && $arg eq '0')
+ {
+ $cmd ='off';
+ }
+
+ if ($cmd eq "pct" && $arg ne '0')
+ {
+ $cmd ='on';
+ }
+ if ( $cmd eq 'on' && $arg eq '' )
+ {
+ $args[0] = ReadingsVal( $name, 'pct', 100);
+ }
+ if ( $cmd eq 'off' && $arg eq '' )
+ {
+ $args[0] = 0;
+ }
+
+ readingsSingleUpdate( $hash, "pct", $args[0], 1 );
+ }
+ #######################################
+
+ if (!defined $args[0]) { $args[0]='';}
+
+ #######################################
+ if ((($cmd eq 'on') || ($cmd eq 'off')) && ($args[0] ne ''))
+ {
+ readingsSingleUpdate( $hash, "Parameter", $args[0], 1 );
+ if ($cmd eq 'on'){$args[0] = "$name:on_with_Parameter:$args[0]";}
+ if ($cmd eq 'off'){$args[0] = "$name:off_with_Parameter:$args[0]";}
+ }
+
+ #######################################
if ( AttrVal( $name, 'MSwitch_Debug', "0" ) eq '2' )
#AUFRUF DEBUGFUNKTIONEN
{
@@ -710,14 +785,17 @@ sub MSwitch_Set($@) {
}
elsif ( AttrVal( $name, 'MSwitch_Mode', 'Full' ) eq "Toggle" )
{
- return "Unknown argument $cmd, choose one of on:noArg off:noArg del_delays:noArg backup_MSwitch:all_devices fakeevent wait";
+ return "Unknown argument $cmd, choose one of on offdel_delays:noArg backup_MSwitch:all_devices fakeevent wait";
}
else
{
- return "Unknown argument $cmd, choose one of on:noArg off:noArg del_delays:noArg backup_MSwitch:all_devices fakeevent exec_cmd1:noArg exec_cmd2:noArg wait";
+
+
+ return "Unknown argument $cmd, choose one of on off del_delays:noArg backup_MSwitch:all_devices fakeevent exec_cmd1:noArg exec_cmd2:noArg wait $special";
+
}
}
-
+ #"position" => "slider,0,1,100"
if ( AttrVal( $name, 'MSwitch_RandomNumber', '' ) ne '' )
{
# randomnunner erzeugen wenn attr an
@@ -1188,42 +1266,7 @@ sub MSwitch_Set($@) {
{
$cs = "$devicedetails{$device.'_onarg'}";
$cs = MSwitch_makefreecmd($hash,$cs);
- # # setmagic
- # my $ersetzung ="";
- # #Log3( $name, 0,"$name MSwitch_Set: ".$cs." L:". __LINE__ );
-
- # $cs =~ s/#\[ti\]/~/g;
-
- # # entferne kommntarzeilen
- # $cs =~ s/#.*\n//g;
-
-
- # $cs =~ s/\n//g;
-
- # $ersetzung = ReadingsVal( $name, "EVTPART3", "" );
- # $cs =~ s/\$EVTPART3/$ersetzung/g;
- # $ersetzung = ReadingsVal( $name, "EVTPART2", "" );
- # $cs =~ s/\$EVTPART2/$ersetzung/g;
- # $ersetzung = ReadingsVal( $name, "EVTPART1", "" );
- # $cs =~ s/\$EVTPART1/$ersetzung/g;
- # $ersetzung = ReadingsVal( $name, "EVENT", "" );
- # $cs =~ s/\$EVENT/$ersetzung/g;
- # $ersetzung = ReadingsVal( $name, "EVENTFULL", "" );
- # $cs =~ s/\$EVENTFULL/$ersetzung/g;
-
-
-
-
-
-
- # my $x =0;
- # while ( $cs =~ m/(.*)\[(.*)\:(.*)\](.*)/ )
- # {
- # $x++; # notausstieg notausstieg
- # last if $x > 20; # notausstieg notausstieg
- # my $setmagic = ReadingsVal( $2, $3, 0 );
- # $cs = $1.$setmagic.$4;
- # }
+
}
if ($devicedetails{$timerkey} eq "0"|| $devicedetails{$timerkey} eq "")
@@ -1235,7 +1278,7 @@ sub MSwitch_Set($@) {
if ( $execute eq 'true' )
{
# variabelersetzung
- Log3( $name, 3,"$name MSwitch_Set: Befehlsausfuehrung -> $cs L:". __LINE__ );
+ Log3( $name, 3,"$name Set - Befehlsausfuehrung: $cs ");
$cs =~ s/\$NAME/$hash->{helper}{eventfrom}/;
#Log3( $name, 5,"eintrag cmdpool $cs . '|' . $device L:". __LINE__ );
push @cmdpool, $cs . '|' . $device;
@@ -1372,38 +1415,7 @@ sub MSwitch_Set($@) {
{
$cs = "$devicedetails{$device.'_offarg'}";
$cs = MSwitch_makefreecmd($hash,$cs);
- # # setmagic
- # my $ersetzung ="";
- # $cs =~ s/#\[ti\]/~/g;
-
- # # entferne kommntarzeilen
- # $cs =~ s/#.*\n//g;
-
-
- # $cs =~ s/\n//g;
-
- # $ersetzung = ReadingsVal( $name, "EVTPART3", "" );
- # $cs =~ s/\$EVTPART3/$ersetzung/g;
- # $ersetzung = ReadingsVal( $name, "EVTPART2", "" );
- # $cs =~ s/\$EVTPART2/$ersetzung/g;
- # $ersetzung = ReadingsVal( $name, "EVTPART1", "" );
- # $cs =~ s/\$EVTPART1/$ersetzung/g;
- # $ersetzung = ReadingsVal( $name, "EVENT", "" );
- # $cs =~ s/\$EVENT/$ersetzung/g;
- # $ersetzung = ReadingsVal( $name, "EVENTFULL", "" );
- # $cs =~ s/\$EVENTFULL/$ersetzung/g;
-
-
-
-
- # my $x =0;
- # while ( $cs =~ m/(.*)\[(.*)\:(.*)\](.*)/ )
- # {
- # $x++; # exit
- # last if $x > 20; # exit
- # my $setmagic = ReadingsVal( $2, $3, 0 );
- # $cs = $1.$setmagic.$4;
- # }
+
}
#my $conditionkey;
@@ -1543,21 +1555,18 @@ sub MSwitch_Cmd(@) {
InternalTimer( $timecond, "MSwitch_repeat", $msg );
}
}
- #$cmds =~ s/\n//g;
+
my $todec = $cmds;
$cmds = MSwitch_dec($hash,$todec);
+
+
+
############################
if ( $cmds =~ m/{.*}/ )
{
#Log3( $Name, 0,"$Name MSwitch_Cmd: ".$cmds." " . __LINE__ );
-
-
-
-
-
-
-
+
eval($cmds);
if ($@)
{
@@ -2803,7 +2812,7 @@ sub MSwitch_fhemwebFn($$$$) {
}
$detailhtml = $detailhtml. "MSwitch 'cmd1':
- Set