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

View File

@ -405,9 +405,9 @@ notify_fhemwebFn($$$$)
<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: "
string is stripped, i.e $EVENT is not "state: on" but just "on". In some 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: " circumstances it is desireable to get the event without "state: "
is not stripped. In such a case the addStateEvent attribute should be stripped. In such a case the addStateEvent attribute should be set to 1
set to 1 (default is 0, i.e. do not generate an additional event).<br> (default is 0, i.e. strip the "state: " string).<br>
Note 1: you have to set this attribute for the event "receiver", i.e. Note 1: you have to set this attribute for the event "receiver", i.e.
notify, FileLog, etc.<br> notify, FileLog, etc.<br>
@ -612,8 +612,8 @@ notify_fhemwebFn($$$$)
Das mit dem state Reading verkn&uuml;pfte Event ist speziell, da das 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 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 "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 erw&uuml;nscht das unmodifizierte Event zu bekommen, d.h. wo "state: "
entfernt ist. F&uuml;r diese F&auml;lle sollte addStateEvent auf 1 nicht entfernt ist. F&uuml;r diese F&auml;lle sollte addStateEvent auf 1
gesetzt werden, die Voreinstellung ist 0 (deaktiviert).<br> gesetzt werden, die Voreinstellung ist 0 (deaktiviert).<br>
Achtung: Achtung:

View File

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