30_pilight_contact: add battery reading if information is available

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@14105 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Risiko 2017-04-25 18:05:58 +00:00
parent 17b4fed581
commit e132c90b76
3 changed files with 16 additions and 5 deletions

View File

@ -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

View File

@ -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}));

View File

@ -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);