2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-18 05:56:03 +00:00

30_pilight_temp: FIX: pressure, windavg, winddir, windgust from weather stations without temperature

git-svn-id: https://svn.fhem.de/fhem/trunk@9207 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
risiko79 2015-09-06 14:28:04 +00:00
parent 7a2478f10c
commit 1da758f2a5
3 changed files with 27 additions and 28 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.
- bugfix: 30_pilight_temp: pressure, windavg, winddir, windgust from weather stations without temperature
- feature: 74_Unifi: - new readings for controller, accesspoints and clients
- new Setter: archiveAlerts, disconnectClient, restartAP
setLocateAP, unsetLocateAP

View File

@ -1,5 +1,5 @@
##############################################
# $Id: 10_pilight_ctrl.pm 1.10 2015-08-30 Risiko $
# $Id: 10_pilight_ctrl.pm 1.11 2015-09-06 Risiko $
#
# Usage
#
@ -35,6 +35,7 @@
# V 1.08 2015-06-23 - NEW: attribute SendTimeout for abort sending command non blocking
# V 1.09 2015-07-21 - NEW: support submodule pilight_raw to send raw codes
# V 1.10 2015-08-30 - NEW: support pressure, windavg, winddir, windgust from weather stations and GPIO sensors
# V 1.11 2015-09-06 - FIX: pressure, windavg, winddir, windgust from weather stations without temperature
##############################################
package main;
@ -689,7 +690,7 @@ sub pilight_ctrl_Parse($$)
{
my ($hash, $rmsg) = @_;
my $me = $hash->{NAME};
Log3 $me, 5, "$me(Parse): RCV -> $rmsg";
next if(!$rmsg || length($rmsg) < 1);
@ -838,20 +839,17 @@ sub pilight_ctrl_Parse($$)
}
return;
}
case 4 {
my $temp = (defined($data->{$s}{temperature})) ? $data->{$s}{temperature} : "";
return if ($temp eq "");
case 4 {
my $piTempData = "";
$piTempData .= ",temperature:$data->{$s}{temperature}" if (defined($data->{$s}{temperature}));
$piTempData .= ",humidity:$data->{$s}{humidity}" if (defined($data->{$s}{humidity}));
$piTempData .= ",battery:$data->{$s}{battery}" if (defined($data->{$s}{battery}));
$piTempData .= ",pressure:$data->{$s}{pressure}" if (defined($data->{$s}{pressure}));
$piTempData .= ",windavg:$data->{$s}{windavg}" if (defined($data->{$s}{windavg}));
$piTempData .= ",winddir:$data->{$s}{winddir}" if (defined($data->{$s}{winddir}));
$piTempData .= ",windgust:$data->{$s}{windgust}" if (defined($data->{$s}{windgust}));
my $humidity = (defined($data->{$s}{humidity})) ? $data->{$s}{humidity} : "";
my $battery = (defined($data->{$s}{battery})) ? $data->{$s}{battery} : "";
my $more = "";
$more .= ",pressure:$data->{$s}{pressure}" if (defined($data->{$s}{pressure}));
$more .= ",windavg:$data->{$s}{windavg}" if (defined($data->{$s}{windavg}));
$more .= ",winddir:$data->{$s}{winddir}" if (defined($data->{$s}{winddir}));
$more .= ",windgust:$data->{$s}{windgust}" if (defined($data->{$s}{windgust}));
my $msg = "PITEMP,$proto,$id,$temp,$humidity,$battery$more";
my $msg = "PITEMP,$proto,$id$piTempData";
return Dispatch($hash, $msg,undef);
}
case 5 { return Dispatch($hash, "PISCREEN,$proto,$id,$unit,$state",undef); }

View File

@ -1,5 +1,5 @@
##############################################
# $Id: 30_pilight_temp.pm 0.15 2015-08-30 Risiko $
# $Id: 30_pilight_temp.pm 0.16 2015-09-06 Risiko $
#
# Usage
#
@ -14,6 +14,7 @@
# V 0.13 2015-05-17 - NEW: attribut corrHumidity, a factor to modify humidity
# V 0.14 2015-05-30 - FIX: StateFn
# V 0.15 2015-08-30 - NEW: support pressure, windavg, winddir, windgust
# V 0.16 2015-09-06 - FIX: pressure, windavg, winddir, windgust from weather stations without temperature
##############################################
package main;
@ -22,6 +23,7 @@ use strict;
use warnings;
use Time::HiRes qw(gettimeofday);
use JSON;
use Switch; #libswitch-perl
sub pilight_temp_Parse($$);
sub pilight_temp_Define($$);
@ -84,7 +86,7 @@ sub pilight_temp_Parse($$)
Log3 $backend, 4, "pilight_temp_Parse: RCV -> $rmsg";
my ($dev,$protocol,$id,$temp,$humidity,$battery,@args) = split(",",$rmsg);
my ($dev,$protocol,$id,@args) = split(",",$rmsg);
return () if($dev ne "PITEMP");
my $chash;
@ -100,23 +102,21 @@ sub pilight_temp_Parse($$)
return () if (!defined($chash->{NAME}));
my $corrTemp = AttrVal($chash->{NAME}, "corrTemp",1);
$temp = $temp * $corrTemp;
my $corrHumidity = AttrVal($chash->{NAME}, "corrHumidity",1);
readingsBeginUpdate($chash);
readingsBulkUpdate($chash,"state",$temp);
readingsBulkUpdate($chash,"temperature",$temp);
if (defined($humidity) && $humidity ne "") {
my $corrHumidity = AttrVal($chash->{NAME}, "corrHumidity",1);
$humidity = $humidity * $corrHumidity;
readingsBulkUpdate($chash,"humidity",$humidity);
}
readingsBulkUpdate($chash,"battery",$battery) if (defined($battery) && $battery ne "");
foreach my $arg (@args){
#temperature, humidity, battery
#pressure, windavg, winddir, windgust
my($feature,$value) = split(":",$arg);
switch($feature) {
case m/temperature/ {
$value = $value * $corrTemp;
readingsBulkUpdate($chash,"state",$value);
}
case m/humidity/ { $value = $value * $corrHumidity;}
}
readingsBulkUpdate($chash,$feature,$value);
}
readingsEndUpdate($chash, 1);