diff --git a/fhem/CHANGED b/fhem/CHANGED index 7242fac56..8feb8b4a7 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # 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: 30_pilight_contact: add battery reading if information is available - update: 88_HMCCU: Homematic firmware download, advanced scripting - feature: 98_TRAFFIC: v1.3.2, stroke styles, warnings reduced, bugfix - update: 98_DOIFtools: more precise regexp for INITIALIZED event because diff --git a/fhem/FHEM/10_pilight_ctrl.pm b/fhem/FHEM/10_pilight_ctrl.pm index 03d029432..1e105c6a1 100644 --- a/fhem/FHEM/10_pilight_ctrl.pm +++ b/fhem/FHEM/10_pilight_ctrl.pm @@ -896,7 +896,13 @@ sub pilight_ctrl_Parse($$) Log3 $me, 4, "$me(Dispatch): $msg"; return Dispatch($hash, $msg ,undef); } - case 3 { return Dispatch($hash, "PICONTACT,$proto,$id,$unit,$state",undef); } + case 3 { + my $piTempData = ""; + $piTempData .= ",battery:$data->{$s}{battery}" if (defined($data->{$s}{battery})); + my $msg = "PICONTACT,$proto,$id,$unit,$state$piTempData"; + Log3 $me, 4, "$me(Dispatch): $msg"; + return Dispatch($hash, $msg,undef); + } case 4 { my $piTempData = ""; $piTempData .= ",temperature:$data->{$s}{temperature}" if (defined($data->{$s}{temperature})); diff --git a/fhem/FHEM/30_pilight_contact.pm b/fhem/FHEM/30_pilight_contact.pm index 9f9abbddc..27ea81b1e 100644 --- a/fhem/FHEM/30_pilight_contact.pm +++ b/fhem/FHEM/30_pilight_contact.pm @@ -81,9 +81,7 @@ sub pilight_contact_Parse($$) my $backend = $mhash->{NAME}; Log3 $backend, 4, "pilight_contact_Parse ($backend): RCV -> $rmsg"; - - Log3 $backend, 4, "pilight_contact_Parse ($backend): RCV -> $rmsg"; - + my ($dev,$protocol,$id,$unit,$state,@args) = split(",",$rmsg); return () if($dev ne "PICONTACT"); @@ -101,8 +99,14 @@ sub pilight_contact_Parse($$) } return () if (!defined($chash->{NAME})); - + readingsBeginUpdate($chash); + + foreach my $arg (@args){ + my($feature,$value) = split(":",$arg); + readingsBulkUpdate($chash,$feature,$value); + } + readingsBulkUpdate($chash,"state",$state); readingsEndUpdate($chash, 1);