";
@@ -3541,7 +3738,6 @@ sub MSwitch_fhemwebFn($$$$) {
# $ret = $ret. " ";
$ret = $ret. " ";
-
}
@@ -3656,7 +3852,7 @@ sub MSwitch_fhemwebFn($$$$) {
";
- if ( AttrVal( $Name, 'MSwitch_Debug', "0" ) eq '1'&& $optiongeneral ne '' )
+ if ( AttrVal( $Name, 'MSwitch_Debug', "0" ) eq '1' && $optiongeneral ne '' )
{
$ret .=""
. $optiongeneral
@@ -3778,14 +3974,9 @@ sub MSwitch_fhemwebFn($$$$) {
for (var i = 0; i < x.length; i++)
{
var t = x[i].id;
-
-
globaldetails2 +=document.getElementById(t).value;
-
}
- //alert(globaldetails2 );
-
-
+
var globaldetails='undefined';
var x = document.getElementsByClassName('devdetails');
for (var i = 0; i < x.length; i++)
@@ -3964,9 +4155,7 @@ sub MSwitch_fhemwebFn($$$$) {
actaffected +=pos.value;
}
}
- //alert (actaffected);
-
- //return;
+
if (actaffected != globalaffected)
{
globallock =' unsaved affected device';
@@ -3990,20 +4179,15 @@ sub MSwitch_fhemwebFn($$$$) {
if (!document.getElementById(elem).model)
{
-
document.getElementById(elem).model=document.getElementById(elem).value;
}
-
-
-
+
document.getElementById(elem).value = 'N/A'+globallock;
}
-
}";
$j1 .= "function unlock (elem, index){
-
if (document.getElementById(elem)){
document.getElementById(elem).style.backgroundColor = \"\"
document.getElementById(elem).disabled = false;
@@ -4013,15 +4197,48 @@ sub MSwitch_fhemwebFn($$$$) {
#####################
$j1 .= "function saveconfig(conf){
- conf = conf.replace(/ /g,'[s]');
- conf = conf.replace(/\\n/g,'[nl]');
+
+ conf = conf.replace(/\\n/g,'#[EOL]');
+ conf = conf.replace(/:/g,'#c[dp]');
+ conf = conf.replace(/;/g,'#c[se]');
+ conf = conf.replace(/ /g,'#c[sp]');
+
var nm = \$(t).attr(\"nm\");
var def = nm+\" saveconfig \"+encodeURIComponent(conf);
location = location.pathname+\"?detail=" . $Name . "&cmd=set \"+addcsrf(def);
- }
+ }";
+
+
+ $j1 .= "function vupdate(){
+ conf='';
+ var nm = \$(t).attr(\"nm\");
+ var def = nm+\" VUpdate \"+encodeURIComponent(conf);
+ location = location.pathname+\"?detail=" . $Name . "&cmd=set \"+addcsrf(def);
+ }";
+
+
+ $j1 .= "function clearlog(){
+ conf='';
+ var nm = \$(t).attr(\"nm\");
+ var def = nm+\" clearlog \"+encodeURIComponent(conf);
+ location = location.pathname+\"?detail=" . $Name . "&cmd=set \"+addcsrf(def);
+ }";
+
+
+
+ $j1 .= "function savesys(conf){
+ conf = conf.replace(/:/g,'#[dp]');
+ conf = conf.replace(/;/g,'#[se]');
+ conf = conf.replace(/ /g,'#[sp]');
+ conf = conf.replace(/'/g,'#[st]');
+
+ var nm = \$(t).attr(\"nm\");
+ var def = nm+\" savesys \"+encodeURIComponent(conf);
+ location = location.pathname+\"?detail=" . $Name . "&cmd=set \"+addcsrf(def);
+ }";
- function checkcondition(condition,event){
+ $j1 .= "function checkcondition(condition,event){
//alert(condition,event);
var selected =document.getElementById(condition).value;
@@ -4032,14 +4249,7 @@ sub MSwitch_fhemwebFn($$$$) {
FW_okDialog(textfinal);
return;
}
-
-
- //var textfinal = \"\"+event+\"
\";
- //FW_okDialog(textfinal);
- //return;
-
-
-
+
selected = selected.replace(/\\|/g,'(DAYS)');
selected = selected.replace(/\\./g,'#[pt]');
selected = selected.replace(/:/g,'#[dp]');
@@ -4096,7 +4306,7 @@ sub MSwitch_fhemwebFn($$$$) {
text = text + 'Eingabe von Befehlswiederholungen. Bei Belegung der Felder wird ein Befehl um die Angabe \"Repeats\" mit der jeweiligen Verzögerung \"Repeatdelay in sec\" wiederholt. In dem Feld \"Repeats\" ist eine Angabe im \"setmagic\"-Format möglich.';}
if (from == 'priority'){
- text = text + 'Auswahl der Reihenfolge der Befehlsabarbeitung. Ein Befehl mit der Nr. 1 wird als erstes ausgeführt , die höchste Nummer zuletzt. Sollte mehrere Befehle die gleiche Nummer haben , so werden diese Befehle in zufälliger Reihenfolge ausgeführt.';}
+ text = text + 'priority - Auswahl der Reihenfolge der Befehlsabarbeitung. Ein Befehl mit der Nr. 1 wird als erstes ausgeführt , die höchste Nummer zuletzt. Sollte mehrere Befehle die gleiche Nummer haben , so werden diese Befehle in dargestellter Reihenfolge ausgeführt. ID - Devices denen eine ID zugewiesen ist , werden in der normalen abarbeitung der Befehle nicht mehr berücksichtigt und somit nicht ausgeführt. Wenn eine ID-Zuweisung erfolgt ist, kann dieser Befehlszweig nur noch über das cmd set DEVICE ID NR on/off erfolgen. Diese Option wird nur in Ausnahmefällen benötigt , wenn die Pipes nicht ausrechend sind um verschiedene Aktionen unter verschiedenen Bedingungen auszuführen. ';}
if (from == 'saveevent'){
text = text + 'Bei Anwahl dieser Option werden alle eingehenden Events des ausgewählten Triggerdevices gespeichert und sind in den Auswahlfeldern \"execute cmd1\" und \"execute cmd2\" sowie in allen \"Test-Condition\" zur Auswahl verfügbar. Diese Auswahl sollte zur Resourcenschonung nach der Einrichtung des MSwitchdevices abgewählt werden , da hier je nach Trigger erhebliche Datenmengen anfallen können und gespeichert werden.';}
@@ -4187,43 +4397,28 @@ sub MSwitch_fhemwebFn($$$$) {
function activate(state,target,options,copytofield) ////aufruf durch selctfield
{
- //alert('activate aufgerufen');
-
var globaldetails3='undefined';
var x = document.getElementsByClassName('devdetails2');
for (var i = 0; i < x.length; i++)
{
var t = x[i].id;
-
-
globaldetails3 +=document.getElementById(t).value;
}
- //alert(globaldetails3 );
-
-
- //alert(globaldetails3 );
-
+
if ( globaldetails2 )
{
if (globaldetails3 != globaldetails2)
{
-
- //alert ('changed: '+globaldetails2);
-
globallock =' unsaved device actions';
[ \"aw_trig\",\"aw_md1\",\"aw_md2\",\"aw_addevent\",\"aw_dev\"].forEach (lock,);
randomdev.forEach (lock);
-
}
else
{
-
- //alert ('not changed: '+globaldetails2);
-
[ \"aw_trig\",\"aw_md1\",\"aw_md2\",\"aw_addevent\",\"aw_dev\"].forEach (unlock,);
randomdev.forEach (unlock);
}
@@ -4257,7 +4452,6 @@ sub MSwitch_fhemwebFn($$$$) {
}
-
function addevice(device){
var nm = \$(t).attr(\"nm\");
var def = nm+\" add_device \"+device;
@@ -4352,7 +4546,7 @@ sub MSwitch_fhemwebFn($$$$) {
event= event.replace(/ /g,'~');
event= event.replace(/\\|/g,'[bs]');
if (event == ''){
- alert('no event specified');
+ //alert('no event specified');
return;
}
var def = nm+\" addevent \"+event+\" \";
@@ -4366,12 +4560,20 @@ sub MSwitch_fhemwebFn($$$$) {
location = location.pathname+\"?detail=" . $Name . "&cmd=set \"+addcsrf(def);
});
+
+
\$(\"#aw_det\").click(function(){
var nm = \$(t).attr(\"nm\");
devices = '';
$javaform
+
+ devices = devices.replace(/:/g,'#[dp]');
+ devices = devices.replace(/;/g,'#[se]');
+ devices = devices.replace(/ /g,'#[sp]');
+ devices = encodeURIComponent(devices);
+
var def = nm+\" details \"+devices+\" \";
- def = encodeURIComponent(def);
+
location = location.pathname+\"?detail=" . $Name . "&cmd=set \"+addcsrf(def);
});
@@ -4450,24 +4652,23 @@ sub MSwitch_makeCmdHash($) {
# detailsatz in scalar laden
my @devicedatails ;
- @devicedatails = split( /\|/, ReadingsVal( $Name, '.Device_Affected_Details', 'no_device' ) ) if defined ReadingsVal( $Name, '.Device_Affected_Details', 'no_device');#inhalt decice und cmds durch komma getrennt
+ @devicedatails = split( /#\[ND\]/, ReadingsVal( $Name, '.Device_Affected_Details', 'no_device' ) ) if defined ReadingsVal( $Name, '.Device_Affected_Details', 'no_device');#inhalt decice und cmds durch komma getrennt
my %savedetails;
foreach (@devicedatails)
{
- #Log3( $Name, 0,"$_ " . __LINE__ );
- my @detailarray = split( /,/, $_ ); #enthält daten 0-5 0 - name 1-5 daten 7 und9 sind zeitangaben
-
- ## ersetzung für delayangaben
-
- $detailarray[3] =~ s/##/,/g; #alt
- $detailarray[4] =~ s/##/,/g; #alt
- $detailarray[3] =~ s/\[k\]/,/g; #alt
- $detailarray[4] =~ s/\[k\]/,/g; #alt
- $detailarray[3] =~ s/#\[ko\]/,/g; #neu
- $detailarray[4] =~ s/#\[ko\]/,/g; #neu
+ # ersetzung
+ $_ =~ s/#\[sp\]/ /g;
+ $_ =~ s/#\[nl\]/\n/g;
+ $_ =~ s/#\[se\]/;/g;
+ $_ =~ s/#\[dp\]/:/g;
+ $_ =~ s/\(DAYS\)/|/g;
+ $_ =~ s/#\[ko\]/,/g; #neu
+ $_ =~ s/#\[bs\]/\\/g; #neu
+
+ my @detailarray = split( /#\[NF\]/, $_ ); #enthält daten 0-5 0 - name 1-5 daten 7 und9 sind zeitangaben
my $key = '';
my $testtimestroff = $detailarray[7];
@@ -4480,27 +4681,34 @@ sub MSwitch_makeCmdHash($) {
if ( $testtimestroff ne "[:]" )
{
my $hdel = ( substr( $detailarray[7], 0, 2 ) ) * 3600;
- my $mdel = ( substr( $detailarray[7], 2, 2 ) ) * 60;
- my $sdel = ( substr( $detailarray[7], 4, 2 ) ) * 1;
+ my $mdel = ( substr( $detailarray[7], 3, 2 ) ) * 60;
+ my $sdel = ( substr( $detailarray[7], 6, 2 ) ) * 1;
$detailarray[7] = $hdel + $mdel + $sdel;
}
}
+
my $testtimestron = $detailarray[8];
$key = $detailarray[0] . "_delayatofforg";
$savedetails{$key} = $detailarray[8];
+
if ( $testtimestron ne '[random]' )
{
$testtimestron =~ s/[A-Za-z0-9#\.\-_]//g;
+
+
if ( $testtimestron ne "[:]" )
{
my $hdel = substr( $detailarray[8], 0, 2 ) * 3600;
- my $mdel = substr( $detailarray[8], 2, 2 ) * 60;
- my $sdel = substr( $detailarray[8], 4, 2 ) * 1;
- $detailarray[8] = $hdel + $mdel + $sdel;
+ my $mdel = substr( $detailarray[8], 3, 2 ) * 60;
+ my $sdel = substr( $detailarray[8], 6, 2 ) * 1;
+
+ $detailarray[8] = $hdel + $mdel + $sdel;
+
}
}
+
$key = $detailarray[0] . "_on";
$savedetails{$key} = $detailarray[1];
$key = $detailarray[0] . "_off";
@@ -4522,9 +4730,6 @@ sub MSwitch_makeCmdHash($) {
if ( defined $detailarray[11] )
{
- $detailarray[11] =~ s/#ko/[/g;
- $detailarray[11] =~ s/#kc/]/g;
-
$savedetails{$key} = $detailarray[11];
}
else
@@ -4553,18 +4758,23 @@ sub MSwitch_makeCmdHash($) {
$savedetails{$key} = 1;
}
+
+ $key = $detailarray[0] . "_id";
+ if ( defined $detailarray[14] )
+ {
+ $savedetails{$key} = $detailarray[14];
+ }
+ else
+ {
+ $savedetails{$key} = 0;
+ }
+
$key = $detailarray[0] . "_conditionon";
if ( defined $detailarray[9] )
{
- $detailarray[9] =~ s/\(:\)/:/g; #alt
- $detailarray[9] =~ s/#\[pt\]/./g;
- $detailarray[9] =~ s/#\[dp\]/:/g;
- $detailarray[9] =~ s/#\[ti\]/~/g;
- $detailarray[9] =~ s/#\[sp\]/ /g;
- $detailarray[9] =~ s/#\[wa\]/|/g;
- $detailarray[9] =~ s/\(DAYS\)/|/g;
+
$savedetails{$key} = $detailarray[9];
}
else
@@ -4572,16 +4782,10 @@ sub MSwitch_makeCmdHash($) {
$savedetails{$key} = '';
}
$key = $detailarray[0] . "_conditionoff";
+
if ( defined $detailarray[10] )
{
- $detailarray[10] =~ s/\(:\)/:/g; #alt
- $detailarray[10] =~ s/#\[pt\]/./g;
- $detailarray[10] =~ s/#\[dp\]/:/g;
- $detailarray[10] =~ s/#\[ti\]/~/g;
- $detailarray[10] =~ s/#\[sp\]/ /g;
- $detailarray[10] =~ s/#\[wa\]/|/g;
-
- $detailarray[10] =~ s/\(DAYS\)/|/g;
+
$savedetails{$key} = $detailarray[10];
}
else
@@ -4634,12 +4838,19 @@ sub MSwitch_Delete_Triggermemory($) {
return;
}
###########################################################################
-sub MSwitch_Exec_Notif($$$$) {
+sub MSwitch_Exec_Notif($$$$$) {
#Inhalt Übergabe -> push @cmdarray, $own_hash . ',on,check,' . $eventcopy1
- my ( $hash, $comand, $check, $event ) = @_;
+ my ( $hash, $comand, $check, $event,$execids ) = @_;
my $name = $hash->{NAME};
my $protokoll = '';
my $satz;
+
+
+ $execids = "0";
+
+
+ MSwitch_LOG( $name, 5,"$name: execnotif -> $hash, $comand, $check, $event,$execids ");
+
#### teste auf condition nur wenn nicht von timer
return "" if ( IsDisabled($name) );# Return without any further action if the module is disabled
@@ -4647,6 +4858,8 @@ sub MSwitch_Exec_Notif($$$$) {
{
my $triggercondition = ReadingsVal( $name, '.Trigger_condition', '' );
+# achtung format change
+
$triggercondition =~ s/#\[dp\]/:/g;
$triggercondition =~ s/#\[pt\]/./g;
$triggercondition =~ s/#\[ti\]/~/g;
@@ -4654,16 +4867,18 @@ sub MSwitch_Exec_Notif($$$$) {
if ( $triggercondition ne '' )
{
-
+ MSwitch_LOG( $name, 5,"$name: check triggercondition -> ");
my $ret = MSwitch_checkcondition( $triggercondition, $name, '' );
+ MSwitch_LOG( $name, 5,"$name: ergebniss triggercondition -> ".$ret);
if ( $ret eq 'false' )
{
+ MSwitch_LOG( $name, 5,"$name: ergebniss triggercondition false -> abbruch");
return;
}
}
}
- ### ausführen des on befehls
+
my %devicedetails = MSwitch_makeCmdHash($name);
# betroffene geräte suchen
@@ -4671,8 +4886,11 @@ sub MSwitch_Exec_Notif($$$$) {
my $update = '';
my $testtoggle = '';
+ MSwitch_LOG( $name, 5,"$name: zu schaltende devices -> ".@devices);
+
+
# liste nach priorität ändern , falls expert
- @devices = MSwitch_priority($hash,@devices);
+ @devices = MSwitch_priority($hash,$execids,@devices);
foreach my $device (@devices)
{
@@ -4687,23 +4905,23 @@ sub MSwitch_Exec_Notif($$$$) {
# teste auf on kommando
my $key = $device . "_" . $comand;
my $timerkey = $device . "_time" . $comand;
- $devicedetails{ $device . '_onarg' } =~ s/~/ /g;
- $devicedetails{ $device . '_offarg' } =~ s/~/ /g;
my $testtstate = $devicedetails{$timerkey};
$testtstate =~ s/[A-Za-z0-9#\.\-_]//g;
if ( $testtstate eq "[:]" )
{
+
$devicedetails{$timerkey} =
- eval MSwitch_Checkcond_state( $devicedetails{$timerkey}, $name );
+ eval MSwitch_Checkcond_state( $devicedetails{$timerkey}, $name );
my $hdel = ( substr( $devicedetails{$timerkey}, 0, 2 ) ) * 3600;
my $mdel = ( substr( $devicedetails{$timerkey}, 3, 2 ) ) * 60;
my $sdel = ( substr( $devicedetails{$timerkey}, 6, 2 ) ) * 1;
$devicedetails{$timerkey} = $hdel + $mdel + $sdel;
}
-
+ MSwitch_LOG( $name, 5,"$name: timer des devices -> ".$devicedetails{$timerkey});
# teste auf condition
# antwort $execute 1 oder 0 ;
+
my $conditionkey = $device . "_condition" . $comand;
if ( $devicedetails{$key} ne "" && $devicedetails{$key} ne "no_action" )
{
@@ -4711,18 +4929,17 @@ sub MSwitch_Exec_Notif($$$$) {
if ( $devicenamet eq 'FreeCmd' )
{
$cs = " $devicedetails{$device.'_'.$comand.'arg'}";
-
$cs = MSwitch_makefreecmd($hash,$cs);
-
-
}
else
{
$cs ="set $devicenamet $devicedetails{$device.'_'.$comand} $devicedetails{$device.'_'.$comand.'arg'}";
}
+
#Variabelersetzung
$cs =~ s/\$NAME/$hash->{helper}{eventfrom}/;
+ $cs =~ s/\$SELF/$name/;
if ( $devicedetails{$timerkey} eq "0" || $devicedetails{$timerkey} eq "" )
{
# teste auf condition
@@ -4732,7 +4949,6 @@ sub MSwitch_Exec_Notif($$$$) {
$testtoggle = 'undef';
if ( $execute eq 'true' )
{
- Log3( $name, 3,"$name MSwitch_Notif: Befehlsausfüehrung -> $cs " . __LINE__ );
$testtoggle = $cs;
#############
Log3( $name, 3,"$name MSwitch_Restartcm: Befehlsausfuehrung -> $cs ". __LINE__ );
@@ -4742,11 +4958,13 @@ sub MSwitch_Exec_Notif($$$$) {
$toggle = $cs;
$cs = MSwitch_toggle( $hash, $cs );
}
-
+ MSwitch_LOG( $name, 5,"$name: auszufuehrender Befehl -> ".$cs);
# neu
$devicedetails{ $device . '_repeatcount' } = 0 if !defined $devicedetails{ $device . '_repeatcount' };
$devicedetails{ $device . '_repeattime' } = 0 if !defined $devicedetails{ $device . '_repeattime' };
+
+ MSwitch_LOG( $name, 5,"$name: teste auf repeasts ");
my $x =0;
while ( $devicedetails{ $device . '_repeatcount' } =~ m/\[(.*)\:(.*)\]/ )
{
@@ -4755,10 +4973,23 @@ sub MSwitch_Exec_Notif($$$$) {
my $setmagic = ReadingsVal( $1, $2, 0 );
$devicedetails{ $device . '_repeatcount' } = $setmagic
}
+
+ $x =0;
+ while ( $devicedetails{ $device . '_repeattime' } =~ m/\[(.*)\:(.*)\]/ )
+ {
+ $x++; # exit
+ last if $x > 20; # exit
+ my $setmagic = ReadingsVal( $1, $2, 0 );
+ $devicedetails{ $device . '_repeattime' } = $setmagic
+ }
+
if ($devicedetails{ $device . '_repeatcount' } eq "") {$devicedetails{ $device . '_repeatcount' } = 0};
if ($devicedetails{ $device . '_repeattime' } eq "") {$devicedetails{ $device . '_repeattime' } = 0};
+ MSwitch_LOG( $name, 5,"$name: anzahl repeats -> ".$devicedetails{ $device . '_repeatcount' });
+ MSwitch_LOG( $name, 5,"$name: delay repeats -> ".$devicedetails{ $device . '_repeattime' });
+
if ( AttrVal( $name, 'MSwitch_Expert', "0" ) eq '1' && $devicedetails{ $device . '_repeatcount' } > 0 && $devicedetails{ $device . '_repeattime' } > 0 )
{
my $i;
@@ -4773,6 +5004,7 @@ sub MSwitch_Exec_Notif($$$$) {
$msg = $msg.",".$timecond;
$hash->{helper}{repeats}{$timecond} = "$msg";
+ MSwitch_LOG( $name, 5,"$name: repeat gesetzt -> ".$timecond." ".$msg);
InternalTimer( $timecond, "MSwitch_repeat", $msg );
}
}
@@ -4780,6 +5012,13 @@ sub MSwitch_Exec_Notif($$$$) {
my $todec = $cs;
$cs = MSwitch_dec($hash,$todec);
############################
+
+ if ( AttrVal( $name, 'MSwitch_Debug', "0" ) eq '2' )
+ {
+ MSwitch_LOG( $name, 5,"$name: execute -> ".$cs);
+ }
+ else{
+
if ( $cs =~ m/{.*}/ )
{
eval($cs);
@@ -4798,6 +5037,7 @@ sub MSwitch_Exec_Notif($$$$) {
Log3( $name, 1,"$name Absent_Exec_Notif $comand: ERROR $device: $errors -> Comand: $cs" );
}
}
+ }
my $msg = $cs;
if (length($msg) > 100 ){ $msg = substr($msg,0,100).'....';}
@@ -4817,8 +5057,6 @@ sub MSwitch_Exec_Notif($$$$) {
{
$devicedetails{$timerkey} = 0;
}
-
-
my $timecond = gettimeofday() + $devicedetails{$timerkey};
my $delaykey = $device . "_delayat" . $comand;
my $delayinhalt = $devicedetails{$delaykey};
@@ -4849,14 +5087,22 @@ sub MSwitch_Exec_Notif($$$$) {
$cs =~ s/,/##/g;
my $msg =
- $cs . ","
- . $name . ","
- . $conditionkey . ","
- . $event . ","
- . $timecond . ","
+ $cs . "#[tr]"
+ . $name . "#[tr]"
+ . $conditionkey . "#[tr]"
+ . $event . "#[tr]"
+ . $timecond . "#[tr]"
. $device;
$hash->{helper}{delays}{$msg} = $timecond;
$testtoggle = 'undef';
+
+
+ MSwitch_LOG( $name, 5,"$name: timer gesetzt -> ".$cs);
+ MSwitch_LOG( $name, 5,"$name: timer gesetzt name -> ".$name);
+ MSwitch_LOG( $name, 5,"$name: timer gesetzt conditionkey-> ".$conditionkey);
+ MSwitch_LOG( $name, 5,"$name: timer gesetzt event-> ".$event);
+ MSwitch_LOG( $name, 5,"$name: timer gesetzt timecond-> ".$timecond);
+ MSwitch_LOG( $name, 5,"$name: timer gesetzt -> device ".$device);
InternalTimer( $timecond, "MSwitch_Restartcmd", $msg );
}
}
@@ -4933,27 +5179,47 @@ sub MSwitch_Filter_Trigger($) {
####################
sub MSwitch_Restartcmd($) {
my $incomming = $_[0];
- my @msgarray = split( /,/, $incomming );
+ my @msgarray = split( /#\[tr\]/, $incomming );
my $name = $msgarray[1];
return "" if ( IsDisabled($name) );
+
+ MSwitch_LOG( $name, 5, "----------------------------------------" );
+ MSwitch_LOG( $name, 5, "$name: aufruf restartcmd -> ".$incomming );
+ MSwitch_LOG( $name, 5, "----------------------------------------" );
+
+
+
+ # checke versionskonflikt der datenstruktur
if ( ReadingsVal( $name, '.V_Check', $vupdate ) ne $vupdate )
{
my $ver = ReadingsVal( $name, '.V_Check', '' );
- Log3( $name, 0, $name.' Versionskonflikt, aktion abgebrochen ! erwartet:'.$vupdate.' vorhanden:'.$ver );
+ MSwitch_LOG( $name, 5, "$name: Versionskonflikt - aktion abgebrochen");
return;
}
my $cs = $msgarray[0];
- $cs =~ s/##/,/g;
+ #$cs =~ s/##/,/g;
my $conditionkey = $msgarray[2];
my $event = $msgarray[2];
my $device = $msgarray[5];
+
my $hash = $modules{MSwitch}{defptr}{$name};
+ MSwitch_LOG( $name, 5, "$name: msga4 -> ".$msgarray[4]);
+ MSwitch_LOG( $name, 5, "$name: msga5 -> ".$msgarray[5]);
+ MSwitch_LOG( $name, 5, "$name: msga6 -> ".$msgarray[6]);
+ MSwitch_LOG( $name, 5, "$name: befehl -> ".$cs);
+ MSwitch_LOG( $name, 5, "$name: event -> ".$event);
+ MSwitch_LOG( $name, 5, "$name: device -> ".$device);
+ #MSwitch_LOG( $name, 5, "$name: befehl -> ".$cs);
+
+ MSwitch_LOG( $name, 5, "$name: erstelle cmdhash -> ".$name);
my %devicedetails = MSwitch_makeCmdHash($name);
+
+
if ( AttrVal( $name, 'MSwitch_RandomNumber', '' ) ne '' )
{
MSwitch_Createnumber1($hash);
@@ -4962,28 +5228,33 @@ sub MSwitch_Restartcmd($) {
############ teste auf condition
### antwort $execute 1 oder 0 ;
- my $execute;
+
+
+ my $execute = "true";
+ MSwitch_LOG( $name, 5, "$name: kein aufruf checkcondition - nicht gesetzt ->".$execute) if $devicedetails{$conditionkey} eq '' || $devicedetails{$conditionkey} eq 'nocheck';
+
if ( $msgarray[2] ne 'nocheck' )
{
+ MSwitch_LOG( $name, 5, "$name: aufruf checkcondition mit -> ".$devicedetails{$conditionkey});
$execute = MSwitch_checkcondition( $devicedetails{$conditionkey}, $name,$event );
+ MSwitch_LOG( $name, 5, "$name: ergebniss checkcondition -> ".$execute);
}
- else
- {
- $execute = 'true';
- }
+
- #sleep 5;
+
my $toggle = '';
if ( $execute eq 'true' )
{
Log3( $name, 3, "$name MSwitch_Restartcm: Befehlsausfuehrung -> $cs " . __LINE__ );
- if ( $cs =~ m/set (.*)(MSwitchtoggle)(.*)/ )
+
+ if ( $cs =~ m/set (.*)(MSwitchtoggle)(.*)/ )
{
$toggle = $cs;
$cs = MSwitch_toggle( $hash, $cs );
}
+
-
+ MSwitch_LOG( $name, 5, "$name: teste repeat -> ".$devicedetails{ $device . '_repeatcount' });
my $x =0;
while ( $devicedetails{ $device . '_repeatcount' } =~ m/\[(.*)\:(.*)\]/ )
{
@@ -4993,8 +5264,18 @@ sub MSwitch_Restartcmd($) {
$devicedetails{ $device . '_repeatcount' } = $setmagic
}
-
-
+ $x =0;
+ while ( $devicedetails{ $device . '_repeattime' } =~ m/\[(.*)\:(.*)\]/ )
+ {
+ $x++; # notausstieg notausstieg
+ last if $x > 20; # notausstieg notausstieg
+ my $setmagic = ReadingsVal( $1, $2, 0 );
+ $devicedetails{ $device . '_repeattime' } = $setmagic
+ }
+
+ MSwitch_LOG( $name, 5, "$name: repetcount nach test -> ".$devicedetails{ $device . '_repeatcount' });
+ MSwitch_LOG( $name, 5, "$name: repeattime nach test -> ".$devicedetails{ $device . '_repeattime' });
+
######################################
if ( AttrVal( $name, 'MSwitch_Expert', "0" ) eq '1' && $devicedetails{ $device . '_repeatcount' } > 0 && $devicedetails{ $device . '_repeattime' } > 0 )
{
@@ -5010,34 +5291,43 @@ sub MSwitch_Restartcmd($) {
$msg = $msg."|".$timecond;
$hash->{helper}{repeats}{$timecond} = "$msg";
+ MSwitch_LOG( $name, 5, "$name: repeat gesetzt -> ".$timecond." - ".$msg);
InternalTimer( $timecond, "MSwitch_repeat", $msg );
}
}
-
- #$cs =~ s/\n//g;
- #$cs =~ s/#\[wa\]/|/g;
- # s/#\[wa\]/|/g;
+
my $todec = $cs;
- #Log3( $name, 0," $cs: " . __LINE__ );
+
$cs = MSwitch_dec($hash,$todec);
############################
+
+ if ( AttrVal( $name, 'MSwitch_Debug', "0" ) eq '2' )
+ {
+ MSwitch_LOG( $name, 5,"$name: exec comand -> ".$cs );
+ }
+ else
+ {
+
if ( $cs =~ m/{.*}/ )
{
+ MSwitch_LOG( $name, 5,"$name: exec als perlcode -> ".$cs );
eval($cs);
if ($@)
{
- Log3( $name, 1,"$name MSwitch_Set: ERROR $cs: $@ " . __LINE__ );
+ MSwitch_LOG( $name, 1,"$name MSwitch_Set: ERROR $cs: $@ " . __LINE__ );
}
}
else
{
+ MSwitch_LOG( $name, 5,"$name: execute als fhemcode -> ".$cs );
my $errors = AnalyzeCommandChain( undef, $cs );
if ( defined($errors) )
{
- Log3( $name, 1,"$name MSwitch_Restartcmd :Fehler bei Befehlsausfuehrung ERROR $errors ". __LINE__ );
+ MSwitch_LOG( $name, 1,"$name MSwitch_Restartcmd :Fehler bei Befehlsausfuehrung ERROR $errors ". __LINE__ );
}
}
+ }
if (length($cs) > 100 ){ $cs = substr($cs,0,100).'....';}
readingsSingleUpdate( $hash, "Exec_cmd", $cs, 1 ) if $cs ne '';
}
@@ -5054,8 +5344,8 @@ sub MSwitch_checkcondition($$$) {
#$event ="test:test:test" if $event eq "";
- Log3( $name, 3,"$name Checkcondition - Parameter condition: $condition ") ;
- Log3( $name, 3,"$name Checkcondition - Parameter event: $event ") ;
+ MSwitch_LOG( $name, 5,"$name: Checkcondition - Parameter condition -> ".$condition ) ;
+ MSwitch_LOG( $name, 5,"$name: Checkcondition - Parameter event -> ".$event ) ;
MSwitch_EventBulk($hash,$event ,'0');
@@ -5091,8 +5381,8 @@ sub MSwitch_checkcondition($$$) {
return "false";
}
- $event =~ s/ //ig;
- $event =~ s/~/ /g;
+ #$event =~ s/ //ig;
+ #$event =~ s/~/ /g;
MSwitch_EventBulk($hash , $event , '0') if $event eq "";;
@@ -5127,6 +5417,17 @@ sub MSwitch_checkcondition($$$) {
my $x = 0;
while ( $condition =~ m/(.*?)(\$NAME)(.*)?/)
+ {
+ my $firstpart = $1;
+ my $secondpart = $2;
+ my $lastpart = $3;
+ $condition = $firstpart.$name.$lastpart;
+ $x++;
+ last if $x > 10; #notausstieg
+ }
+
+ $x = 0;
+ while ( $condition =~ m/(.*?)(\$SELF)(.*)?/)
{
my $firstpart = $1;
my $secondpart = $2;
@@ -5265,14 +5566,14 @@ sub MSwitch_checkcondition($$$) {
$finalstring ="if (" . $condition . "){\$answer = 'true';} else {\$answer = 'false';} ";
- Log3( $name, 3,"$name Checkcondition - finalstring $finalstring ") ;
+ MSwitch_LOG( $name, 5,"$name: Checkcondition - finalstring -> ".$finalstring ) ;
my $ret = eval $finalstring;
- Log3( $name, 3,"$name Checkcondition - return $ret ") ;
+ MSwitch_LOG( $name, 5,"$name: Checkcondition - return -> ".$ret ) ;
if ($@)
{
- Log3( $name, 1, "ERROR: $@ " . __LINE__ );
- Log3( $name, 1, "$finalstring " . __LINE__ );
+ MSwitch_LOG( $name, 1, "ERROR: $@ " . __LINE__ );
+ MSwitch_LOG( $name, 1, "$finalstring " . __LINE__ );
$hash->{helper}{conditionerror} = $@;
return 'false';
}
@@ -5284,6 +5585,7 @@ sub MSwitch_checkcondition($$$) {
return $ret;
}
####################
+####################
sub MSwitch_Checkcond_state($$) {
my ( $condition, $name ) = @_;
@@ -5441,8 +5743,6 @@ sub MSwitch_Createtimer($) {
my $x =0;
# achtung perl 5.30
while ($condition =~ m/(.*).\{(.*)\}.(.*)/ )
- # while ($condition =~ m/(.*).{(.*)}.(.*)/ )
-
{
$x++; # notausstieg
last if $x > 20; # notausstieg
@@ -5592,13 +5892,7 @@ sub MSwitch_Createtimer($) {
$time = $time . ':00';
delete( $hash->{helper}{error} );
- # if ( $time !~ m/([0-2][0-3]|[0-1][0-9]):([0-5][0-9]):([0-5][0-9])/ || $time !~ m/(.*)-(.*)/ )
- # {
- # Log3( $Name, 1,"ERROR: ($Name) wrong timespec at comand (at) - $time");
-
- # $hash->{helper}{error}='Devicefehler erkannt: Ergebniss der AT - Schaltzeiten enthält ein falsches Format. Bitte prüfen. ('.$time.')';
- # return;
- # }
+
my $timecond = timelocal( substr( $time, 6, 2 ),substr( $time, 3, 2 ),substr( $time, 0, 2 ),$date, $aktmonth, $aktyear);
my $test = FmtDateTime($timecond);
@@ -5657,7 +5951,7 @@ sub MSwitch_Execute_Timer($) {
if ( ReadingsVal( $Name, '.V_Check', $vupdate ) ne $vupdate )
{
my $ver = ReadingsVal( $Name, '.V_Check', '' );
- Log3( $Name, 0, $Name.' Versionskonflikt, aktion abgebrochen ! erwartet:'.$vupdate.' vorhanden:'.$ver );
+ Log3( $Name, 1, $Name.' Versionskonflikt, aktion abgebrochen ! erwartet:'.$vupdate.' vorhanden:'.$ver );
return;
}
@@ -5678,17 +5972,8 @@ sub MSwitch_Execute_Timer($) {
$triggercondition =~ s/#\[ti\]/~/g;
$triggercondition =~ s/#\[sp\]/ /g;
-
-
-
-
-
if ( $triggercondition ne '' )
{
-
- #Log3( $Name, 0,"aufruf triggerconditionr". __LINE__ );
-
-
my $ret = MSwitch_checkcondition( $triggercondition, $Name, '' );
if ( $ret eq 'false' )
{
@@ -5697,7 +5982,6 @@ sub MSwitch_Execute_Timer($) {
}
}
-
my $extime = POSIX::strftime("%H:%M",localtime);
@@ -5713,7 +5997,6 @@ sub MSwitch_Execute_Timer($) {
{
my $cs = "set $Name on";
Log3( $Name, 3, "$Name MSwitch_Execute_Timer: Befehlsausfuehrung -> $cs" . __LINE__ );
- #Log3( $Name, 3, "$Name MSwitch_Execute_Timer: Befehlsausfuehrung -> $cs" . __LINE__ );
my $errors = AnalyzeCommandChain( undef, $cs );
if ( defined($errors) )
{
@@ -5736,13 +6019,13 @@ sub MSwitch_Execute_Timer($) {
if ( $param eq '3' )
{
- MSwitch_Exec_Notif( $hash, 'on', 'nocheck', '' );
+ MSwitch_Exec_Notif( $hash, 'on', 'nocheck', '',0 );
return;
}
if ( $param eq '4' )
{
- MSwitch_Exec_Notif( $hash, 'off', 'nocheck', '' );
+ MSwitch_Exec_Notif( $hash, 'off', 'nocheck', '',0 );
return;
}
return;
@@ -5799,12 +6082,19 @@ sub MSwitch_Del_Device($$) {
my ( $hash, $device ) = @_;
my $Name = $hash->{NAME};
my @olddevices = split( /,/, ReadingsVal( $Name, '.Device_Affected', '' ) );
- my @olddevicesset = split( /\|/, ReadingsVal( $Name, '.Device_Affected_Details', '' ) );
+ my @olddevicesset = split( /#\[ND\]/, ReadingsVal( $Name, '.Device_Affected_Details', '' ) );
+
+ #Log3( $Name, 5, "olddevice: @olddevicesset" );
+
+
my @newdevice;
my @newdevicesset;
my $count = 0;
LOOP8: foreach (@olddevices)
{
+ #Log3( $Name, 5, "olddevice: $_" );
+
+
if ( $device eq $_ )
{
$count++;
@@ -5835,11 +6125,14 @@ sub MSwitch_Del_Device($$) {
LOOP10: foreach (@newdevicesset)
{
- my ( $name, @comands ) = split( /,/, $_ );
+ # my ( $name, @comands ) = split( /,/, $_ );
+
+ my ( $name, @comands ) = split( /#\[NF\]/, $_ );
my ( $devicename, $devicecmd ) = split( /-AbsCmd/, $name );
if ( $devicemaster eq $devicename )
{
- my $newname = $devicename . '-AbsCmd' . $count . ',' . join( ',', @comands );
+ # my $newname = $devicename . '-AbsCmd' . $count . ',' . join( ',', @comands );
+ my $newname = $devicename . '-AbsCmd' . $count . '#[NF]' . join( '#[NF]', @comands );
push( @newdevicesset1, $newname );
$count++;
next LOOP10;
@@ -5849,7 +6142,11 @@ sub MSwitch_Del_Device($$) {
my $newaffected = join( ',', @newdevice1 );
if ( $newaffected eq '' ) { $newaffected = 'no_device' }
- my $newaffecteddet = join( '|', @newdevicesset1 );
+ my $newaffecteddet = join( '#[ND]', @newdevicesset1 );
+
+ #Log3( $Name, 5, "deldevice new: $newaffecteddet" );
+
+ #return;
readingsBeginUpdate($hash);
readingsBulkUpdate( $hash, ".Device_Affected", $newaffected );
readingsBulkUpdate( $hash, ".Device_Affected_Details", $newaffecteddet );
@@ -5907,15 +6204,7 @@ sub MSwitch_Delete_Delay($$) {
}
}
- # lösche repeats
- #$timehash = $hash->{helper}{repeats};
- #foreach my $a ( keys %{$timehash} )
- #{
- #my $inhalt = $hash->{helper}{repeats}{$a};
- #RemoveInternalTimer($a);
- #RemoveInternalTimer($inhalt);
- #delete( $hash->{helper}{repeats}{$a} );
- #}
+
}
@@ -6058,84 +6347,50 @@ sub MSwitch_VUpdate($) {
my ($hash) = @_;
my $Name = $hash->{NAME};
- # my $test = "";
- # $test=-e "MSwitch_backup_V05.cfg";
- # if ($test ne "1")
- # {
-
- # #Log3( $Name, 0, "Backupdatei vor Strukturupdate wird erzeugt: MSwitch_backup_V03.cfg. Für einen Restore muss diese in MSwitch_backup.cfg umbenannt werden. " );
- # # backup anlegen
- # my @areadings =
- # qw(.Device_Affected .Device_Affected_Details .Device_Events .First_init .Trigger_Whitelist .Trigger_cmd_off .Trigger_cmd_on .Trigger_condition .Trigger_off .Trigger_on .Trigger_time .V_Check Exec_cmd Trigger_device Trigger_log last_event state) ; #alle readings
- # my %keys;
- # open( BACKUPDATEI, ">MSwitch_backup_V03.cfg" ); # Datei zum Schreiben öffnen
- # print BACKUPDATEI "# Mswitch Devices\n"; #
- # foreach my $testdevice ( keys %{ $modules{MSwitch}{defptr} } ) #
- # {
- # print BACKUPDATEI "$testdevice\n";
- # }
- # print BACKUPDATEI "# Mswitch Devices END\n"; #
- # print BACKUPDATEI "\n"; # HTML-Datei schreiben
- # foreach my $testdevice ( keys %{ $modules{MSwitch}{defptr} } ) #
- # {
- # print BACKUPDATEI "#N -> $testdevice\n"; #
- # foreach my $key (@areadings)
- # {
- # my $tmp = ReadingsVal( $testdevice, $key, 'undef' );
- # print BACKUPDATEI "#S $key -> $tmp\n";
- # }
- # my %keys;
- # foreach my $attrdevice ( keys %{ $attr{$testdevice} } ) #geht
- # {
- # print BACKUPDATEI "#A $attrdevice -> ". AttrVal( $testdevice, $attrdevice, '' ) . "\n";
- # }
- # print BACKUPDATEI "#E -> $testdevice\n";
- # print BACKUPDATEI "\n";
- # }
- # close(BACKUPDATEI);
- # }
- ##########
-
- #Log3( $Name, 0, "Strukturupdate $vupdate fuer MSwitch - $Name" );
- #MSwitch_Delete_Triggermemory($hash);
- #readingsSingleUpdate( $hash, ".V_Check", $vupdate, 0 );
- #return;
- ####
-
- # my $triggercondition = ReadingsVal( $Name, '.Trigger_condition', '' );
- # $triggercondition =~ s/\./#[dp]/g;
- # $triggercondition =~ s/\:/#[dp]/g;
- # $triggercondition =~ s/~/#[sp]/g;
- # readingsSingleUpdate( $hash, ".Trigger_condition", $triggercondition, 0 );
- # my @devs = split( /\|/, ReadingsVal( $Name, '.Device_Affected_Details', '' ) );
- # my$x =0;
- # foreach my $triggercondition (@devs)
- # {
- # my @array = split( /,/, $triggercondition );
- # if (defined $array[9])
- # {
- # $array[9] =~ s/\./#[dp]/g;
- # $array[9] =~ s/\:/#[dp]/g;
- # $array[9] =~ s/~/#[sp]/g;
- # }
- # if (defined $array[10])
- # {
- # $array[10] =~ s/\./#[dp]/g;
- # $array[10] =~ s/\:/#[dp]/g;
- # $array[10] =~ s/~/#[sp]/g;
- # }
- # @devs[$x] = join( ',', @array );
- # $x++;
- # }
- # my $newtriggercond = join( '|', @devs );
- # readingsSingleUpdate( $hash, ".Device_Affected_Details", $newtriggercond, 0 );
-
- Log3( $Name, 0,"vupdate - $Name". __LINE__ );
- #$attr{$Name}{disable} = '0';
-
readingsSingleUpdate( $hash, ".V_Check", $vupdate, 0 );
+ my $devs = ReadingsVal( $Name, '.Device_Affected_Details', '' ) ;
- #$attr{$Name}{MSwitch_Safemode} = '1';
+ # encode from old format
+
+ $devs =~ s/,/#[NF]/g;
+ $devs =~ s/\|/#[ND]/g;
+ $devs =~ s/~/ /g;
+ $devs =~ s/\[cnl\]/\n/g;
+ $devs =~ s/\[se\]/;/g;
+ $devs =~ s/#\[ko\]/,/g;
+ $devs =~ s/#\[sp\]/ /g;
+
+ # decode to new format
+
+ $devs =~ s/#\[wa\]/|/g;
+ $devs =~ s/\n/#[nl]/g;
+ $devs =~ s/;/#[se]/g;
+ $devs =~ s/\:/#[dp]/g;
+ $devs =~ s/\t/ /g;
+ $devs =~ s/ /#[sp]/g;
+ $devs =~ s/\\/#[bs]/g;
+ $devs =~ s/,/#[ko]/g;
+ $devs =~ s/^#\[/#[eo]/g;
+ $devs =~ s/^#\]/#[ec]/g;
+ $devs =~ s/\|/#[wa]/g;
+
+ # change timerkey to new format
+
+ my $x =0;
+ while ( $devs =~ m/(.*#\[NF\])([0-9]{2})([0-9]{2})([0-9]{2})(#\[NF\].*)/ )
+ {
+
+
+
+ $x++; # exit
+ last if $x > 20; # exit
+ $devs = $1.$2."#[dp]".$3."#[dp]".$4.$5 ;
+
+ }
+
+
+ readingsSingleUpdate( $hash, ".Device_Affected_Details", $devs, 0 );
+
return;
}
@@ -6145,34 +6400,27 @@ sub MSwitch_backup($) {
my $Name = $hash->{NAME};
my @areadings =
- qw(.Device_Affected .Device_Affected_Details .Device_Events .First_init .Trigger_Whitelist .Trigger_cmd_off .Trigger_cmd_on .Trigger_condition .Trigger_off .Trigger_on .Trigger_time .V_Check Exec_cmd Trigger_device Trigger_log last_event state) ; #alle readings
- my %keys;
- open( BACKUPDATEI, ">MSwitch_backup.cfg" ); # Datei zum Schreiben öffnen
+ qw(.Device_Affected .Device_Affected_Details .Device_Events .First_init .Trigger_Whitelist .Trigger_cmd_off .Trigger_cmd_on .Trigger_condition .Trigger_off .Trigger_on .Trigger_time .V_Check Exec_cmd Trigger_device Trigger_log last_event state .sysconf Sys_Extension) ; #alle readings
+
+ my %keys;
+ open( BACKUPDATEI, ">MSwitch_backup_$vupdate.cfg" ); # Datei zum Schreiben öffnen
print BACKUPDATEI "# Mswitch Devices\n"; #
foreach my $testdevice ( keys %{ $modules{MSwitch}{defptr} } ) #
{
print BACKUPDATEI "$testdevice\n";
}
print BACKUPDATEI "# Mswitch Devices END\n"; #
- print BACKUPDATEI "\n"; # HTML-Datei schreiben
+
+ print BACKUPDATEI "\n"; # HTML-Datei schreiben
foreach my $testdevice ( keys %{ $modules{MSwitch}{defptr} } ) #
{
print BACKUPDATEI "#N -> $testdevice\n"; #
foreach my $key (@areadings)
{
my $tmp = ReadingsVal( $testdevice, $key, 'undef' );
-
-
- if ($key eq ".Device_Affected_Details")
- {
- $tmp =~ s/\n/[cnl]/g;
- $tmp =~ s/;/[se]/g;
- $tmp =~ s/\\/[bs]/g;
- $tmp =~ s/(.*?)\t/$1~~~~/g;
- }
-
print BACKUPDATEI "#S $key -> $tmp\n";
}
+
my %keys;
foreach my $attrdevice ( keys %{ $attr{$testdevice} } ) #geht
{
@@ -6190,28 +6438,27 @@ sub MSwitch_backup_this($) {
my $Name = $hash->{NAME};
my $Zeilen = ("");
my $Zeilen1 ="";
- open( BACKUPDATEI, ")
{
$Zeilen = $Zeilen . $_;
}
close(BACKUPDATEI);
- $Zeilen =~ s/\n/[nl]/g;
- if ( $Zeilen !~ m/#N -> $Name\[nl\](.*)#E -> $Name\[nl\]/ )
+ $Zeilen =~ s/\n/[NL]/g;
+
+ if ( $Zeilen !~ m/#N -> $Name\[NL\](.*)#E -> $Name\[NL\]/ )
{
return "no Backupfile found\n";
}
- my @found = split( /\[nl\]/, $1 );
+
+ my @found = split( /\[NL\]/, $1 );
foreach (@found)
{
-
- #Log3( $Name, 0, "$_" );
-
if ( $_ =~ m/#S (.*) -> (.*)/ ) # setreading
{
- #Log3( $Name, 0, "$1" );
- #Log3( $Name, 0, "$2" );
+ # Log3( $Name, 0, "s1 $1" );
+ # Log3( $Name, 0, "s2 $2" );
if ( $2 eq 'undef' || $2 eq '' || $2 eq ' ' )
{
@@ -6219,17 +6466,7 @@ sub MSwitch_backup_this($) {
else
{
$Zeilen1 = $2;
- if ($1 eq ".Device_Affected_Details")
- {
- #Log3( $Name, 0, "found details" );
-
- $Zeilen1 =~ s/\[se\]/;/g;
- $Zeilen1 =~ s/\[cnl\]/\n/g;
- $Zeilen1 =~ s/\[bs\]/\\/g;
- }
-
-
- readingsSingleUpdate( $hash, "$1", $Zeilen1, 0 );
+ readingsSingleUpdate( $hash, "$1", $Zeilen1, 0 );
}
}
if ( $_ =~ m/#A (.*) -> (.*)/ ) # setattr
@@ -6252,31 +6489,49 @@ sub MSwitch_backup_this($) {
sub MSwitch_Getconfig($) {
my ($hash) = @_;
my $Name = $hash->{NAME};
- my @areadings = qw(.Device_Affected .Device_Affected_Details .Device_Events .First_init .Trigger_Whitelist .Trigger_cmd_off .Trigger_cmd_on .Trigger_condition .Trigger_off .Trigger_on .Trigger_time .V_Check Trigger_device Trigger_log last_event state);
+ my @areadings = qw(.Device_Affected .Device_Affected_Details .Device_Events .First_init .Trigger_Whitelist .Trigger_cmd_off .Trigger_cmd_on .Trigger_condition .Trigger_off .Trigger_on .Trigger_time .V_Check Trigger_device Trigger_log last_event .sysconf state Sys_Extension);
+
+ #.sysconf
+
#alle readings
- # my %keys;
+ # my %keys; $vupdate
my $count = 0;
my $out = "#V $version\\n";
+ $out .= "#VS $vupdate\\n";
my $testdevice = $Name;
foreach my $key (@areadings)
{
my $tmp = ReadingsVal( $testdevice, $key, 'undef' );
if ($key eq ".Device_Affected_Details")
{
- $tmp =~ s/\n/[cnl]/g;
- $tmp =~ s/;/[se]/g;
- $tmp =~ s/\\/[bs]/g;
- $tmp =~ s/(.*?)\t/$1~~~~/g;
- my $x = 0; # notausstieg
- while ( $tmp =~ m/(.*?)(\[.*)(\:)(.*\])(.*)?/ )
- {
- $x++; # notausstieg notausstieg
- last if $x > 20; # notausstieg notausstieg
- $tmp = $1.$2.'.'.$4.$5;
- }
+ $tmp =~ s/#\[nl\]/;;/g;
+
+ $tmp =~ s/#\[sp\]/ /g;
+ $tmp =~ s/#\[nl\]/\\n/g;
+ $tmp =~ s/#\[se\]/;/g;
+ $tmp =~ s/#\[dp\]/:/g;
+ $tmp =~ s/\(DAYS\)/|/g;
+ $tmp =~ s/#\[ko\]/,/g; #neu
+ $tmp =~ s/#\[wa\]/|/g;
+ $tmp =~ s/#\[st\]/\\'/g;
+ $tmp =~ s/'/\\'/g;
+ $tmp =~ s/#\[bs\]/\\\\/g;
+ #Log3( $Name, 0, $tmp );
+ }
+
+ if ($key eq ".sysconf")
+ {
+
+ }
+
+ if ($key eq ".Device_Events")
+ {
+ $tmp =~ s/#\[tr\]/ /g;
}
+
+
$out .= "#S $key -> $tmp\\n";
$count++;
}
@@ -6289,24 +6544,62 @@ sub MSwitch_Getconfig($) {
}
$count++;
$count++;
+
+
my $client_hash = $hash->{CL};
+
asyncOutput( $hash->{CL},
- "