diff --git a/fhem/CHANGED b/fhem/CHANGED index 94c58a9c7..9aed5737a 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,12 +1,11 @@ # 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: update is executed per default in the background - bugfix: FB_CALLLIST: fix "Use of uninitialized value" warnings on startup - - feature: 2016-01-17 - *** - *** Do not worry about a lot of updates. Many - *** modules were modified only to support the - *** new commandref mechanism for automatic - *** classification of helper and command modules. - *** + - feature: *** 2016-01-17 + *** Do not worry about a lot of updates. Many modules were + *** modified only to support the new commandref mechanism for + *** automatic classification of helper and command modules. - change: 49_SSCam: Change of define-string related to rectime. Note: see all changes of rectime usage in commandref or in Forum: diff --git a/fhem/FHEM/01_FHEMWEB.pm b/fhem/FHEM/01_FHEMWEB.pm index 8105800ac..83819f054 100755 --- a/fhem/FHEM/01_FHEMWEB.pm +++ b/fhem/FHEM/01_FHEMWEB.pm @@ -2001,10 +2001,11 @@ FW_style($$) FW_pO ""; FW_pO "
"; - my $filter = ($a[2] && $a[2] ne "1") ? $a[2] : ".*"; + my $filter = ($a[2] && $a[2] ne "log") ? $a[2] : ".*"; FW_pO "Events (Filter: $filter) ". - "  FHEM log ". - "". + "  FHEM log ". + "". "  

\n"; FW_pO "
"; FW_pO "
"; @@ -2482,7 +2483,7 @@ FW_logInform($$) return; } $msg = FW_htmlEscape($msg); - if(!addToWritebuffer($ntfy, "
$msg
") ){ + if(!addToWritebuffer($ntfy, "
$msg
") ){ TcpServer_Close($ntfy); delete $logInform{$me}; delete $defs{$me}; diff --git a/fhem/FHEM/98_telnet.pm b/fhem/FHEM/98_telnet.pm index 91cff0de7..05f5edcd7 100644 --- a/fhem/FHEM/98_telnet.pm +++ b/fhem/FHEM/98_telnet.pm @@ -26,11 +26,14 @@ telnet_Initialize($) "encoding:utf8,latin1 sslVersion"; $hash->{ActivateInformFn} = "telnet_ActivateInform"; - my %lhash = ( Fn=>"CommandTelnetEncoding", - ClientFilter => "telnet", - Hlp=>"[utf8|latin1],query and set the character encoding ". - "for the current telnet session" ); - $cmds{encoding} = \%lhash; + $cmds{encoding} = { Fn=>"CommandTelnetEncoding", + ClientFilter => "telnet", + Hlp=>"[utf8|latin1],query and set the character encoding ". + "for the current telnet session" }; + + $cmds{inform} = { Fn=>"CommandTelnetInform", + ClientFilter => "telnet", + Hlp=>"{on|off|log|raw|timer|status},echo all events to this client" }; } sub @@ -348,16 +351,59 @@ sub telnet_Undef($$) { my ($hash, $arg) = @_; + delete($logInform{$hash->{NAME}}); + delete($inform{$hash->{NAME}}); return TcpServer_Close($hash); } +##################################### sub -telnet_ActivateInform($;$) +CommandTelnetInform($$) { - my ($cl, $arg) = @_; + my ($cl, $param) = @_; + + return if(!$cl); my $name = $cl->{NAME}; - $arg = "" if(!defined($arg)); - CommandInform($cl, "timer $arg") if(!$inform{$name}); + + return "Usage: inform {on|off|raw|timer|log|status} [regexp]" + if($param !~ m/^(on|off|raw|timer|log|status)/); + + if($param eq "status") { + my $i = $inform{$name}; + return $i ? ($i->{type} . ($i->{regexp} ? " ".$i->{regexp} : "")) : "off"; + } + + if($param eq "off") { + delete($logInform{$name}); + delete($inform{$name}); + + } elsif($param eq "log") { + $logInform{$name} = sub($$){ + my ($me, $msg) = @_; # _NO_ Log3 here! + telnet_Output($defs{$me}, $msg."\n"); + } + + } elsif($param ne "off") { + my ($type, $regexp) = split(" ", $param); + $inform{$name}{NR} = $cl->{NR}; + $inform{$name}{type} = $type; + if($regexp) { + eval { "Hallo" =~ m/$regexp/ }; + return "Bad regexp: $@" if($@); + $inform{$name}{regexp} = $regexp; + } + Log 4, "Setting inform to $param"; + + } + + return undef; +} + +sub +telnet_ActivateInform($) +{ + my ($cl) = @_; + CommandTelnetInform($cl, "log"); } diff --git a/fhem/FHEM/98_update.pm b/fhem/FHEM/98_update.pm index 5fe9318f1..ed002abdc 100644 --- a/fhem/FHEM/98_update.pm +++ b/fhem/FHEM/98_update.pm @@ -25,6 +25,7 @@ my $updArg; my $mainPgm = "/fhem.pl\$"; my %upd_connecthash; my $upd_needJoin; +my $upd_nChanged; ######################################## @@ -64,11 +65,11 @@ CommandUpdate($$) if($arg =~ m/^[-\?\*]/ || $ret); $arg = lc($arg) if($arg =~ m/^(check|all|force)$/i); - $updateInBackground = AttrVal("global","updateInBackground",undef); + $updateInBackground = AttrVal("global","updateInBackground",1); $updateInBackground = 0 if($arg ne "all"); $updArg = $arg; if($updateInBackground) { - CallFn($cl->{NAME}, "ActivateInformFn", $cl, "global"); + CallFn($cl->{NAME}, "ActivateInformFn", $cl, "log"); BlockingCall("doUpdateInBackground", {src=>$src,arg=>$arg}); return "Executing the update the background."; @@ -167,7 +168,6 @@ update_Log2Event($$) return if($inLog || $level > $attr{global}{verbose}); $inLog = 1; $text =~ s/\n/ /g; # Multiline text causes havoc in Analyze - BlockingInformParent("DoTrigger", ["global", $text, 1], 0); BlockingInformParent("Log", [$level, $text], 0); $inLog = 0; } @@ -189,6 +189,7 @@ doUpdateLoop($$) my ($src, $arg) = @_; $upd_needJoin = 0; + $upd_nChanged = 0; if($src =~ m/^http.*/) { doUpdate(1,1, $src, $arg); HttpUtils_Close(\%upd_connecthash); @@ -233,7 +234,8 @@ doUpdate($$$$) $ctrlFileName =~ m/controls_(.*).txt/; my $srcName = $1; - if(AttrVal("global", "backup_before_update", 0) && $arg ne "check" && $curr==1) { + if(AttrVal("global", "backup_before_update", 0) && + $arg ne "check" && $curr==1) { my $cmdret = AnalyzeCommand(undef, "backup"); if ($cmdret !~ m/backup done.*/) { uLog 1, "Something went wrong during backup: $cmdret"; @@ -391,7 +393,8 @@ doUpdate($$$$) } } - return "" if(!$nChanged); + $upd_nChanged += $nChanged; + return "" if(!$upd_nChanged); uLog(1, ""); if($curr == $max) { @@ -658,7 +661,7 @@ upd_initRestoreDirs($) If this attribute is set (to 1), the update will be executed in a background process. The return message is communicated via events, and in telnet the inform command is activated, in FHEMWEB the Event - Monitor. + Monitor. Default is set. Set it to 0 to switch it off.
@@ -760,7 +763,8 @@ upd_initRestoreDirs($) Wenn dieses Attribut gesetzt ist, wird das update Befehl in einem separaten Prozess ausgeführt, und alle Meldungen werden per Event übermittelt. In der telnet Sitzung wird inform, in FHEMWEB wird - das Event Monitor aktiviert. + das Event Monitor aktiviert. Die Voreinstellung ist an, zum + Deaktivieren bitte Attribut auf 0 setzen.
diff --git a/fhem/fhem.pl b/fhem/fhem.pl index 088ad5daa..3eec1b12c 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -139,7 +139,6 @@ sub CommandDisplayAttr($$); sub CommandGet($$); sub CommandIOWrite($$); sub CommandInclude($$); -sub CommandInform($$); sub CommandList($$); sub CommandModify($$); sub CommandQuit($$); @@ -333,9 +332,6 @@ $readingFnAttributes = "event-on-change-reading event-on-update-reading ". Hlp=>" ,request data from " }, "include" => { Fn=>"CommandInclude", Hlp=>",read the commands from " }, - "inform" => { Fn=>"CommandInform", - ClientFilter => "telnet", - Hlp=>"{on|off|raw|timer|status},echo all events to this client" }, "iowrite" => { Fn=>"CommandIOWrite", Hlp=>" ,write raw data with iodev" }, "list" => { Fn=>"CommandList", @@ -498,7 +494,7 @@ if(time() < 2*3600) { require RTypes; RTypes_Initialize(); -my $cfgErrMsg = "Error messages while initializing FHEM:"; +my $cfgErrMsg = "Messages collected while initializing FHEM:"; my $cfgRet=""; if(configDBUsed()) { my $ret = cfgDB_ReadAll(undef); @@ -838,7 +834,11 @@ Log3($$$) no strict "refs"; foreach my $li (keys %logInform) { - &{$logInform{$li}}($li, "$tim $loglevel : $text"); + if($defs{$li}) { + &{$logInform{$li}}($li, "$tim $loglevel : $text"); + } else { + delete $logInform{$li}; + } } use strict "refs"; @@ -2637,40 +2637,6 @@ CommandTrigger($$) return join("\n", @rets); } -##################################### -sub -CommandInform($$) -{ - my ($cl, $param) = @_; - - return if(!$cl); - my $name = $cl->{NAME}; - - return "Usage: inform {on|timer|raw|off} [regexp]" - if($param !~ m/^(on|off|raw|timer|status)/); - - if($param eq "status") { - my $i = $inform{$name}; - return $i ? ($i->{type} . ($i->{regexp} ? " ".$i->{regexp} : "")) : "off"; - } - - delete($inform{$name}); - if($param !~ m/^off/) { - my ($type, $regexp) = split(" ", $param); - $inform{$name}{NR} = $cl->{NR}; - $inform{$name}{type} = $type; - if($regexp) { - eval { "Hallo" =~ m/$regexp/ }; - return "Bad regexp: $@" if($@); - $inform{$name}{regexp} = $regexp; - } - Log 4, "Setting inform to $param"; - - } - - return undef; -} - ##################################### sub WakeUpFn($) diff --git a/fhem/www/pgm2/console.js b/fhem/www/pgm2/console.js index 93acad6ee..cf8378cc9 100644 --- a/fhem/www/pgm2/console.js +++ b/fhem/www/pgm2/console.js @@ -65,6 +65,7 @@ consStart() if(consFilter == undefined) consFilter = ".*"; oldFilter = consFilter; + withLog = ($("#eventWithLog").is(':checked') ? 1 : 0); setTimeout(consFill, 1000); $("#eventReset").click(function(evt){ // Event Monitor Reset diff --git a/fhem/www/pgm2/darkCommon.css b/fhem/www/pgm2/darkCommon.css index 02d857360..4aa2a82c1 100644 --- a/fhem/www/pgm2/darkCommon.css +++ b/fhem/www/pgm2/darkCommon.css @@ -11,3 +11,5 @@ div.ui-widget-content a {color: #CCCCCC!important; text-decoration: none!importa .ui-button-text { font-weight:normal!important; color:#555!important; } div.detLink { display:inline-block; margin-right:0.5em; } + +.fhemlog { color:#FFFFFF; } diff --git a/fhem/www/pgm2/defaultCommon.css b/fhem/www/pgm2/defaultCommon.css index 48b2d36bf..7cfaafd3e 100644 --- a/fhem/www/pgm2/defaultCommon.css +++ b/fhem/www/pgm2/defaultCommon.css @@ -21,6 +21,7 @@ table.room { border:1px solid gray; width: 100%; background: #D7FFFF; } table.room tr.sel { background: #A0FFFF; } tr.column > td { padding:0; vertical-align:top;} .changed a, .changed { color:red; } +.fhemlog { color:#278727; } .col2 { text-align:center; } /* Documentation */