2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

fhem.pl: deviceEvents withState replaces the state to "state: xx" instead of

adding it. (Forum #51102)


git-svn-id: https://svn.fhem.de/fhem/trunk@11109 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2016-03-21 09:29:52 +00:00
parent 4793205852
commit 202b670fe9
3 changed files with 12 additions and 17 deletions

View File

@ -2559,13 +2559,6 @@ FW_Notify($$)
if($events) { # It gets deleted sometimes (?)
my $tn = TimeNow();
my $max = int(@{$events});
my $state = "";
if($max) {
my ($rn,$rv) = split(": ",$events->[$max-1],2);
$state = $rv if($rn eq "state");
}
for(my $i = 0; $i < $max; $i++) {
if($events->[$i] !~ /: /) {
if($dev->{NAME} eq 'global') { # Forum #47634
@ -2576,7 +2569,6 @@ FW_Notify($$)
next; #ignore 'set' commands
}
next if($events->[$i] eq $state);
my ($readingName,$readingVal) = split(": ",$events->[$i],2);
push @data, FW_longpollInfo($h->{fmt},
"$dn-$readingName", $readingVal,$readingVal);

View File

@ -405,9 +405,9 @@ notify_fhemwebFn($$$$)
<li>addStateEvent<br>
The event associated with the state Reading is special, as the "state: "
string is stripped, i.e $EVENT is not "state: on" but just "on". In some
circumstances it is desireable to get an additional event where "state: "
is not stripped. In such a case the addStateEvent attribute should be
set to 1 (default is 0, i.e. do not generate an additional event).<br>
circumstances it is desireable to get the event without "state: "
stripped. In such a case the addStateEvent attribute should be set to 1
(default is 0, i.e. strip the "state: " string).<br>
Note 1: you have to set this attribute for the event "receiver", i.e.
notify, FileLog, etc.<br>
@ -612,8 +612,8 @@ notify_fhemwebFn($$$$)
Das mit dem state Reading verkn&uuml;pfte Event ist speziell, da das
dazugeh&ouml;rige Prefix "state: " entfernt wird, d.h. $EVENT ist nicht
"state: on", sondern nur "on". In manchen F&auml;llen ist es aber
erw&uuml;nscht ein zus&auml;tzliches Event zu bekommen, wo "state: " nicht
entfernt ist. F&uuml;r diese F&auml;lle sollte addStateEvent auf 1
erw&uuml;nscht das unmodifizierte Event zu bekommen, d.h. wo "state: "
nicht entfernt ist. F&uuml;r diese F&auml;lle sollte addStateEvent auf 1
gesetzt werden, die Voreinstellung ist 0 (deaktiviert).<br>
Achtung:

View File

@ -3001,7 +3001,7 @@ GetTimeSpec($)
sub
deviceEvents($$)
{
my ($hash, $withState) = @_;
my ($hash, $withState) = @_; # withState returns stateEvent as state:event
return undef if(!$hash || !$hash->{CHANGED});
@ -3009,9 +3009,12 @@ deviceEvents($$)
my $cws = $hash->{CHANGEDWITHSTATE};
if(defined($cws)){
if(int(@{$cws}) == 0) {
@{$cws} = @{$hash->{CHANGED}};
push @{$cws}, "state: $hash->{READINGS}{state}{VAL}"
if($hash->{READINGS} && $hash->{READINGS}{state});
if($hash->{READINGS} && $hash->{READINGS}{state}) {
my $state = $hash->{READINGS}{state}{VAL};
@{$cws} = map { $_ eq $state ? "state: $_" : $_ } @{$hash->{CHANGED}};
} else {
@{$cws} = @{$hash->{CHANGED}};
}
}
return $cws;
}