mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
91_notify: readLog attribute (Forum #48523)
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@10694 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
9c848a3df3
commit
2b721a004b
1
CHANGED
1
CHANGED
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# 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.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- feature: 91_notify: add readLog attribute
|
||||||
- feature: 98_ping: Add attribute for minimum fails before reporting
|
- feature: 98_ping: Add attribute for minimum fails before reporting
|
||||||
(minFailCount)
|
(minFailCount)
|
||||||
- bugfix: PRESENCE: fix log warning "use of uninitialized value ..." when
|
- bugfix: PRESENCE: fix log warning "use of uninitialized value ..." when
|
||||||
|
@ -15,7 +15,8 @@ notify_Initialize($)
|
|||||||
$hash->{DefFn} = "notify_Define";
|
$hash->{DefFn} = "notify_Define";
|
||||||
$hash->{NotifyFn} = "notify_Exec";
|
$hash->{NotifyFn} = "notify_Exec";
|
||||||
$hash->{AttrFn} = "notify_Attr";
|
$hash->{AttrFn} = "notify_Attr";
|
||||||
$hash->{AttrList} = "disable:0,1 disabledForIntervals forwardReturnValue:0,1 showtime:0,1 addStateEvent:0,1";
|
$hash->{AttrList} ="disable:1,0 disabledForIntervals forwardReturnValue:1,0 ".
|
||||||
|
"readLog:1,0 showtime:1,0 addStateEvent:1,0";
|
||||||
$hash->{SetFn} = "notify_Set";
|
$hash->{SetFn} = "notify_Set";
|
||||||
$hash->{StateFn} = "notify_State";
|
$hash->{StateFn} = "notify_State";
|
||||||
$hash->{FW_detailFn} = "notify_fhemwebFn";
|
$hash->{FW_detailFn} = "notify_fhemwebFn";
|
||||||
@ -107,6 +108,22 @@ notify_Attr(@)
|
|||||||
{
|
{
|
||||||
my @a = @_;
|
my @a = @_;
|
||||||
my $do = 0;
|
my $do = 0;
|
||||||
|
my $hash = $defs{$a[1]};
|
||||||
|
|
||||||
|
if($a[0] eq "set" && $a[2] eq "readLog") {
|
||||||
|
if(!defined($a[3]) || $a[3]) {
|
||||||
|
$logInform{$a[1]} = sub($$){
|
||||||
|
my ($me, $msg) = @_;
|
||||||
|
return if(defined($hash->{CHANGED}));
|
||||||
|
$hash->{CHANGED}[0] = $msg;
|
||||||
|
notify_Exec($hash, $hash);
|
||||||
|
delete($hash->{CHANGED});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
delete $logInform{$a[1]};
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if($a[0] eq "set" && $a[2] eq "disable") {
|
if($a[0] eq "set" && $a[2] eq "disable") {
|
||||||
$do = (!defined($a[3]) || $a[3]) ? 1 : 2;
|
$do = (!defined($a[3]) || $a[3]) ? 1 : 2;
|
||||||
@ -114,7 +131,7 @@ notify_Attr(@)
|
|||||||
$do = 2 if($a[0] eq "del" && (!$a[2] || $a[2] eq "disable"));
|
$do = 2 if($a[0] eq "del" && (!$a[2] || $a[2] eq "disable"));
|
||||||
return if(!$do);
|
return if(!$do);
|
||||||
|
|
||||||
readingsSingleUpdate($defs{$a[1]}, "state", $do==1 ? "disabled":"active", 1);
|
readingsSingleUpdate($hash, "state", $do==1 ? "disabled":"active", 1);
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -384,14 +401,6 @@ notify_fhemwebFn($$$$)
|
|||||||
<li><a href="#disable">disable</a></li>
|
<li><a href="#disable">disable</a></li>
|
||||||
<li><a href="#disabledForIntervals">disabledForIntervals</a></li>
|
<li><a href="#disabledForIntervals">disabledForIntervals</a></li>
|
||||||
|
|
||||||
<a name="forwardReturnValue"></a>
|
|
||||||
<li>forwardReturnValue<br>
|
|
||||||
Forward the return value of the executed command to the caller,
|
|
||||||
default is disabled (0). If enabled (1), then e.g. a set command which
|
|
||||||
triggers this notify will also return this value. This can cause e.g
|
|
||||||
FHEMWEB to display this value, when clicking "on" or "off", which is
|
|
||||||
often not intended.</li>
|
|
||||||
|
|
||||||
<a name="addStateEvent"></a>
|
<a name="addStateEvent"></a>
|
||||||
<li>addStateEvent<br>
|
<li>addStateEvent<br>
|
||||||
The event associated with the state Reading is special, as the "state: "
|
The event associated with the state Reading is special, as the "state: "
|
||||||
@ -406,6 +415,26 @@ notify_fhemwebFn($$$$)
|
|||||||
Note 2: this attribute will only work for events generated by devices
|
Note 2: this attribute will only work for events generated by devices
|
||||||
supporting the <a href="#readingFnAttributes">readingFnAttributes</a>.
|
supporting the <a href="#readingFnAttributes">readingFnAttributes</a>.
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<a name="forwardReturnValue"></a>
|
||||||
|
<li>forwardReturnValue<br>
|
||||||
|
Forward the return value of the executed command to the caller,
|
||||||
|
default is disabled (0). If enabled (1), then e.g. a set command which
|
||||||
|
triggers this notify will also return this value. This can cause e.g
|
||||||
|
FHEMWEB to display this value, when clicking "on" or "off", which is
|
||||||
|
often not intended.</li>
|
||||||
|
|
||||||
|
<a name="readLog"></a>
|
||||||
|
<li>readLog<br>
|
||||||
|
Execute the notify for messages appearing in the FHEM Log. The device
|
||||||
|
in this case is set to the notify itself, e.g. checking for the startup
|
||||||
|
message looks like:
|
||||||
|
<ul><code>
|
||||||
|
define n notify n:.*Server.started.* { Log 1, "Really" }<br>
|
||||||
|
attr n readLog
|
||||||
|
</code></ul>
|
||||||
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
@ -576,12 +605,7 @@ notify_fhemwebFn($$$$)
|
|||||||
<b>Attribute</b>
|
<b>Attribute</b>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#disable">disable</a></li>
|
<li><a href="#disable">disable</a></li>
|
||||||
<a name="forwardReturnValue"></a>
|
<li><a href="#disabledForIntervals">disabledForIntervals</a></li>
|
||||||
<li>forwardReturnValue<br>
|
|
||||||
Rückgabe der Werte eines ausgeführten Kommandos an den
|
|
||||||
Aufrufer. Die Voreinstellung ist 0 (ausgeschaltet), um weniger
|
|
||||||
Meldungen im Log zu haben.
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<a name="addStateEvent"></a>
|
<a name="addStateEvent"></a>
|
||||||
<li>addStateEvent<br>
|
<li>addStateEvent<br>
|
||||||
@ -600,10 +624,27 @@ notify_fhemwebFn($$$$)
|
|||||||
<li>dieses Attribut zeigt nur für solche Geräte-Events eine
|
<li>dieses Attribut zeigt nur für solche Geräte-Events eine
|
||||||
Wirkung, die <a href="#readingFnAttributes">readingFnAttributes</a>
|
Wirkung, die <a href="#readingFnAttributes">readingFnAttributes</a>
|
||||||
unterstützen.</li>
|
unterstützen.</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<a name="forwardReturnValue"></a>
|
||||||
|
<li>forwardReturnValue<br>
|
||||||
|
Rückgabe der Werte eines ausgeführten Kommandos an den
|
||||||
|
Aufrufer. Die Voreinstellung ist 0 (ausgeschaltet), um weniger
|
||||||
|
Meldungen im Log zu haben.
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<a name="readLog"></a>
|
||||||
|
<li>readLog<br>
|
||||||
|
Das notify wird für Meldungen, die im FHEM-Log erscheinen,
|
||||||
|
ausgegeführt. Das "Event-Generierende-Gerät" wird auf dem
|
||||||
|
notify selbst gesetzt. Z.Bsp. kann man mit folgendem notify auf die
|
||||||
|
Startup Meldung reagieren:
|
||||||
|
<ul><code>
|
||||||
|
define n notify n:.*Server.started.* { Log 1, "Wirklich" }<br>
|
||||||
|
attr n readLog
|
||||||
|
</code></ul>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user