mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-23 20:52:13 +00:00
98_MSwitch.pm:Update -> V2.1
git-svn-id: https://svn.fhem.de/fhem/trunk@18332 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
77b9271f7b
commit
5efd899c32
@ -83,7 +83,7 @@ if ( $preconf && $preconf ne "" ) {
|
||||
}
|
||||
|
||||
my $autoupdate = 'off'; #off/on
|
||||
my $version = '2.09';
|
||||
my $version = '2.10_test';
|
||||
my $vupdate = 'V2.00'
|
||||
; # versionsnummer der datenstruktur . änderung der nummer löst MSwitch_VUpdate aus .
|
||||
my $savecount = 30
|
||||
@ -230,8 +230,10 @@ sub MSwitch_Initialize($) {
|
||||
. " MSwitch_Safemode:0,1"
|
||||
. " MSwitch_Startdelay:0,10,20,30,60,90,120"
|
||||
. " MSwitch_Wait"
|
||||
. " MSwitch_Event_Id_Distributor:textField-long "
|
||||
. " setList:textField-long "
|
||||
. " readingList:textField-long "
|
||||
. " textField-long "
|
||||
. $readingFnAttributes;
|
||||
$hash->{FW_addDetailToSummary} = 0;
|
||||
}
|
||||
@ -1144,7 +1146,15 @@ sub MSwitch_Set($@) {
|
||||
$execids = $args[1];
|
||||
$args[0] = 'ID';
|
||||
}
|
||||
if ( $args[0] ne 'ID' || $args[0] ne '' ){
|
||||
|
||||
if ( $args[1] !~ m/.\d/ )
|
||||
|
||||
{
|
||||
Log3( $name, 1, "error at id call $args[1]: format must be exec_cmd_1 <ID x,z,y>" );
|
||||
return ;
|
||||
}
|
||||
}
|
||||
# cmd1 abarbeiten
|
||||
MSwitch_Exec_Notif( $hash, 'on', 'nocheck', '', $execids );
|
||||
return;
|
||||
@ -1158,6 +1168,18 @@ sub MSwitch_Set($@) {
|
||||
$execids = $args[1];
|
||||
$args[0] = 'ID';
|
||||
}
|
||||
if ( $args[0] ne '' || $args[0] ne "ID" ){
|
||||
|
||||
|
||||
if ( $args[1] !~ m/.\d/ )
|
||||
|
||||
{
|
||||
Log3( $name, 1, "error at id call $args[1]: format must be exec_cmd_2 <ID x,z,y>" );
|
||||
return ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# cmd2 abarbeiten
|
||||
MSwitch_Exec_Notif( $hash, 'off', 'nocheck', '', $execids );
|
||||
@ -2117,6 +2139,75 @@ sub MSwitch_Attr(@) {
|
||||
}
|
||||
|
||||
}
|
||||
##################################
|
||||
|
||||
|
||||
|
||||
if ( $cmd eq 'set' && $aName eq 'MSwitch_Event_Id_Distributor')
|
||||
{
|
||||
|
||||
|
||||
delete( $hash->{helper}{eventtoid});
|
||||
|
||||
#$aVal =~ s/\n/,/g;
|
||||
#$aVal =~ s/,,/,/g;
|
||||
#Log3( $name, 0, $aVal );
|
||||
return "Invalid Regex $aVal: $@" if $aVal eq "" ;
|
||||
return "Invalid Regex $aVal: $@" if !$aVal;
|
||||
return "Invalid Regex $aVal: $@" if $aVal eq "1" ;
|
||||
|
||||
|
||||
|
||||
my @test = split(/\n/,$aVal);
|
||||
#Log3( $name, 0, "@test" );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#my %setid =();
|
||||
|
||||
foreach my $testdevices (@test ) {
|
||||
Log3( $name, 0, $testdevices );
|
||||
|
||||
|
||||
if ( $testdevices !~ m/(.*:)?.*:.*=\>cmd(1|2)[\s]ID[\s](\d)(,\d){0,5}$/ ) {
|
||||
return "wrong syntax. The syntax must be: \n\n[DEVICE:]READING:STATE=>cmd<1|2> ID x[,y,z] \n\n[] = optional \n<1|2> = 1 or 2 \nseveral entries are separated by a line break";
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $testdevices (@test ) {
|
||||
Log3( $name, 0, $testdevices );
|
||||
|
||||
my ( $key,$val) = split(/=>/,$testdevices);
|
||||
Log3( $name, 0, $key );
|
||||
Log3( $name, 0, $val );
|
||||
|
||||
#$setid{$key} = $val;
|
||||
$hash->{helper}{eventtoid}{$key} = $val;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $cmd eq 'del' && $aName eq 'MSwitch_Event_Id_Distributor' )
|
||||
{
|
||||
delete( $hash->{helper}{eventtoid});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
###################################
|
||||
|
||||
|
||||
|
||||
if ( $cmd eq 'set' && $aName eq 'disable' && $aVal == 1 ) {
|
||||
$hash->{NOTIFYDEV} = 'no_trigger';
|
||||
@ -2323,9 +2414,11 @@ sub MSwitch_Notify($$) {
|
||||
my $devicemode = AttrVal( $ownName, 'MSwitch_Mode', 'Full' );
|
||||
my $devicefilter = AttrVal( $ownName, 'MSwitch_Trigger_Filter', 'undef' );
|
||||
my $debugmode = AttrVal( $ownName, 'MSwitch_Debug', "0" );
|
||||
my $startdelay =
|
||||
AttrVal( $ownName, 'MSwitch_Startdelay', $standartstartdelay );
|
||||
my $startdelay = AttrVal( $ownName, 'MSwitch_Startdelay', $standartstartdelay );
|
||||
my $attrrandomnumber = AttrVal( $ownName, 'MSwitch_RandomNumber', '' );
|
||||
#my $bridgemode = AttrVal( $ownName, 'MSwitch_Event_Id_Distributor:', 'undef' );
|
||||
#my $expertmode = AttrVal( $ownName, 'MSwitch_Expert:', '0' );
|
||||
|
||||
|
||||
return if ( $devicemode eq 'Dummy' );
|
||||
return
|
||||
@ -2459,7 +2552,7 @@ sub MSwitch_Notify($$) {
|
||||
my $activecount = 0;
|
||||
my $anzahl;
|
||||
EVENT: foreach my $event (@eventscopy) {
|
||||
|
||||
##################################
|
||||
MSwitch_LOG( $ownName, 5, "$ownName: event -> $event " );
|
||||
|
||||
|
||||
@ -2603,6 +2696,10 @@ sub MSwitch_Notify($$) {
|
||||
@eventsplit );
|
||||
|
||||
if ( $testvar ne 'undef' ) {
|
||||
|
||||
my $chbridge = MSwitch_checkbridge( $own_hash, $ownName, $eventcopy,);
|
||||
next EVENT if $chbridge ne "no_bridge";
|
||||
|
||||
$set = $testvar;
|
||||
$check = 1;
|
||||
$foundcmd1 = 1;
|
||||
@ -2623,6 +2720,10 @@ sub MSwitch_Notify($$) {
|
||||
$triggeroff, $incommingdevice, 'off', $eventcopy,
|
||||
@eventsplit );
|
||||
if ( $testvar ne 'undef' ) {
|
||||
|
||||
my $chbridge = MSwitch_checkbridge( $own_hash, $ownName, $eventcopy,);
|
||||
next EVENT if $chbridge ne "no_bridge";
|
||||
|
||||
$set = $testvar;
|
||||
$check = 1;
|
||||
$foundcmd2 = 1;
|
||||
@ -2646,6 +2747,11 @@ sub MSwitch_Notify($$) {
|
||||
$triggercmdoff, $incommingdevice, 'offonly', $eventcopy,
|
||||
@eventsplit );
|
||||
if ( $testvar ne 'undef' ) {
|
||||
|
||||
my $chbridge = MSwitch_checkbridge( $own_hash, $ownName, $eventcopy,);
|
||||
next EVENT if $chbridge ne "no_bridge";
|
||||
|
||||
|
||||
push @cmdarray, $own_hash . ',off,check,' . $eventcopy1;
|
||||
$check = 1;
|
||||
$foundcmd2 = 1;
|
||||
@ -2662,6 +2768,10 @@ sub MSwitch_Notify($$) {
|
||||
$triggercmdon, $incommingdevice, 'ononly', $eventcopy,
|
||||
@eventsplit );
|
||||
if ( $testvar ne 'undef' ) {
|
||||
|
||||
my $chbridge = MSwitch_checkbridge( $own_hash, $ownName, $eventcopy,);
|
||||
next EVENT if $chbridge ne "no_bridge";
|
||||
|
||||
push @cmdarray, $own_hash . ',on,check,' . $eventcopy1;
|
||||
$check = 1;
|
||||
$foundcmd1 = 1;
|
||||
@ -2885,7 +2995,22 @@ sub MSwitch_Notify($$) {
|
||||
}
|
||||
}
|
||||
#########################
|
||||
sub MSwitch_checkbridge($$$) {
|
||||
my ( $hash, $name, $event ) = @_;
|
||||
my $bridgemode = AttrVal( $name, 'MSwitch_Event_Id_Distributor', '0' );
|
||||
my $expertmode = AttrVal( $name, 'MSwitch_Expert', '0' );
|
||||
return "no_bridge" if $expertmode eq "0";
|
||||
return "no_bridge" if $bridgemode eq "0";
|
||||
return "no_bridge" if !defined $hash->{helper}{eventtoid}{$event};
|
||||
my @bridge = split(/ /,$hash->{helper}{eventtoid}{$event});
|
||||
my $zweig ;
|
||||
$zweig = "on" if $bridge[0] eq "cmd1";
|
||||
$zweig = "off" if $bridge[0] eq "cmd2";
|
||||
MSwitch_Exec_Notif( $hash, $zweig, 'nocheck', '', $bridge[2] );
|
||||
return "undef";
|
||||
}
|
||||
|
||||
############################
|
||||
sub MSwitch_fhemwebFn($$$$) {
|
||||
|
||||
# my $loglevel = 5;
|
||||
@ -4921,6 +5046,30 @@ sub MSwitch_fhemwebFn($$$$) {
|
||||
else {
|
||||
$ret .= "<p id=\"MSwitchWebTRDT\"></p>";
|
||||
}
|
||||
# id event bridge
|
||||
|
||||
|
||||
|
||||
#my $bridgemode = AttrVal( $name, 'MSwitch_Event_Id_Distributor', '0' );
|
||||
my $expertmode = AttrVal( $Name, 'MSwitch_Expert', '0' );
|
||||
|
||||
|
||||
if ($hash->{helper}{eventtoid} && $expertmode eq "1" ){
|
||||
$ret .=
|
||||
"<table border='$border' class='block wide' id='MSwitchWebBridge' nm='$hash->{NAME}'>
|
||||
<tr class=\"even\">
|
||||
<td>Event to ID distributor (Settings via attribute):</td></tr>
|
||||
<tr class=\"even\">
|
||||
<td> </td></tr>";
|
||||
my $toid = $hash->{helper}{eventtoid};
|
||||
foreach my $a ( keys %{$toid} )
|
||||
{
|
||||
$ret .="<tr class=\"even\"><td> incommming Event: ".$a." =\> execute ".$hash->{helper}{eventtoid}{$a}."</td></tr>";
|
||||
}
|
||||
|
||||
$ret .="<tr class=\"even\">
|
||||
<td> </td></tr></table></p>";
|
||||
}
|
||||
|
||||
# affected devices
|
||||
$ret .=
|
||||
@ -6026,7 +6175,7 @@ sub MSwitch_Exec_Notif($$$$$) {
|
||||
my $ekey = '';
|
||||
my $out = '0';
|
||||
|
||||
MSwitch_LOG( $name, 5,
|
||||
MSwitch_LOG( $name,5,
|
||||
"$name: execnotif -> $hash, $comand, $check, $event,$execids " );
|
||||
|
||||
return ""
|
||||
@ -7085,7 +7234,7 @@ sub MSwitch_Checkcond_time($$) {
|
||||
# my $timeaktuell =
|
||||
# timelocal( '00', $aktmin, $akthour, $date, $month, $time1 );
|
||||
|
||||
my $return = "($timecond1 < $timeaktuell && $timeaktuell < $timecond2)";
|
||||
my $return = "($timecond1 <= $timeaktuell && $timeaktuell <= $timecond2)";
|
||||
if ( $days ne '' ) {
|
||||
$daycondition = MSwitch_Checkcond_day( $days, $name, $adday, $day );
|
||||
$return = "($return $daycondition)";
|
||||
@ -9077,8 +9226,9 @@ MSwitch is an auxiliary module that works both event- and time-controlled. <br /
|
||||
<li> MSwitch_Mode: Full, Notify, Toggle - Device Operation Mode </li>
|
||||
<li> MSwitch_Condition_Time: 0.1 - activation of the trigger conditions for timed triggering </li>
|
||||
<li> MSwitch_Safemode: 0.1 - 1. aborts all actions of the device if more than 20 calls per second take place </li>
|
||||
<li> MSwitch_RandomTime - see Wiki </li>
|
||||
<li> MSwitch_RandomNumber - see Wiki </li>
|
||||
<li> MSwitch_RandomTime - see Wiki: https://wiki.fhem.de/wiki/MSwitch#MSwitch_Random_Time_.28HH:MM:SS-HH:MM:SS.29 </li>
|
||||
<li> MSwitch_RandomNumber - see Wiki: https://wiki.fhem.de/wiki/MSwitch#MSwitch_Random_Number </li>
|
||||
<li> MSwitch_Event_Id_Distributor - see Wiki: https://wiki.fhem.de/wiki/MSwitch#MSwitch_Event_Id_Distributor </li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user