2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-16 10:46:03 +00:00

50_HP1000: use UConv::DbLog_split

git-svn-id: https://svn.fhem.de/fhem/trunk@12493 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2016-11-03 07:45:35 +00:00
parent 17550d38de
commit aa2c104f0f

View File

@ -66,7 +66,7 @@ sub HP1000_Initialize($) {
$hash->{GetFn} = "HP1000_Get";
$hash->{DefFn} = "HP1000_Define";
$hash->{UndefFn} = "HP1000_Undefine";
$hash->{DbLog_splitFn} = "HP1000_DbLog_split";
$hash->{DbLog_splitFn} = "UConv::DbLog_split";
$hash->{parseParams} = 1;
$hash->{AttrList} =
@ -1335,208 +1335,6 @@ sub HP1000_ReturnWU($$$) {
return;
}
###################################
sub HP1000_DbLog_split($$) {
my ( $event, $device ) = @_;
my ( $reading, $value, $unit ) = "";
my $hash = $defs{$device};
if ( $event =~
/^(wind_compasspoint.*|.*_sum10m|.*_avg2m|uvCondition):\s([\w\.,]+)\s*(.*)/
)
{
return undef;
}
elsif ( $event =~
/^(dewpoint|indoorDewpoint|temperature|indoorTemperature|wind_chill):\s([\w\.,]+)\s*(.*)/
)
{
$reading = $1;
$value = $2;
$unit = "°C";
}
elsif ( $event =~
/^(dewpoint_f|indoorDewpoint_f|temperature_f|indoorTemperature_f|wind_chill_f):\s([\w\.,]+)\s*(.*)/
)
{
$reading = $1;
$value = $2;
$unit = "°F";
}
elsif ( $event =~ /^(humidity.*):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1;
$value = $2;
$unit = "%";
}
elsif ( $event =~ /^(luminosity):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1;
$value = $2;
$unit = "lux";
}
elsif ( $event =~ /^(solarradiation):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1;
$value = $2;
$unit = "W/m2";
}
elsif ( $event =~ /^(pressure_trend):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1;
$value = "";
$value = "0" if ( $2 eq "=" );
$value = "1" if ( $2 eq "+" );
$value = "2" if ( $2 eq "-" );
return undef if ( $value eq "" );
$unit = "";
}
elsif ( $event =~ /^(pressure|pressureAbs):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1;
$value = $2;
$unit = "hPa";
}
elsif ( $event =~ /^(pressure_in|pressureAbs_in):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1;
$value = $2;
$unit = "inHg";
}
elsif ( $event =~ /^(pressure_mm|pressureAbs_mm):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1;
$value = $2;
$unit = "mmHg";
}
elsif ( $event =~ /^(rain):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1;
$value = $2;
$unit = "mm/h";
}
elsif ( $event =~ /^(rain_in):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1;
$value = $2;
$unit = "in/h";
}
elsif ( $event =~
/^(rain_day|rain_week|rain_month|rain_year):\s([\w\.,]+)\s*(.*)/ )
{
$reading = $1;
$value = $2;
$unit = "mm";
}
elsif ( $event =~
/^(rain_day_in|rain_week_in|rain_month_in|rain_year_in):\s([\w\.,]+)\s*(.*)/
)
{
$reading = $1;
$value = $2;
$unit = "in";
}
elsif ( $event =~ /^(uv):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1;
$value = $2;
$unit = "uW/cm2";
}
elsif ( $event =~ /^(UV):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1;
$value = $2;
$unit = "UVI";
}
elsif ( $event =~ /^(wind_direction.*):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1;
$value = $2;
$unit = "°";
}
elsif ( $event =~ /^(wind_gust.*|wind_speed.*):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1;
$value = $2;
$unit = "km/h";
}
elsif (
$event =~ /^(wind_gust_mph.*|wind_speed_mph.*):\s([\w\.,]+)\s*(.*)/ )
{
$reading = $1;
$value = $2;
$unit = "mph";
}
elsif (
$event =~ /^(wind_gust_bft.*|wind_speed_bft.*):\s([\w\.,]+)\s*(.*)/ )
{
$reading = $1;
$value = $2;
$unit = "Bft";
}
elsif (
$event =~ /^(wind_gust_mps.*|wind_speed_mps.*):\s([\w\.,]+)\s*(.*)/ )
{
$reading = $1;
$value = $2;
$unit = "m/s";
}
elsif (
$event =~ /^(wind_gust_fts.*|wind_speed_fts.*):\s([\w\.,]+)\s*(.*)/ )
{
$reading = $1;
$value = $2;
$unit = "ft/s";
}
elsif ( $event =~ /^(wind_gust_kn.*|wind_speed_kn.*):\s([\w\.,]+)\s*(.*)/ )
{
$reading = $1;
$value = $2;
$unit = "kn";
}
elsif ( $event =~ /^(Activity):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1;
$value = $2;
$value = "1" if ( $2 eq "alive" );
$value = "0" if ( $2 eq "dead" );
$unit = "";
}
elsif ( $event =~ /^(condition):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1;
$value = "";
$value = "0" if ( $2 eq "clear" );
$value = "1" if ( $2 eq "sunny" );
$value = "2" if ( $2 eq "cloudy" );
$value = "3" if ( $2 eq "rain" );
return undef if ( $value eq "" );
$unit = "";
}
elsif ( $event =~ /^(humidityCondition):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1;
$value = "";
$value = "0" if ( $2 eq "dry" );
$value = "1" if ( $2 eq "low" );
$value = "2" if ( $2 eq "optimal" );
$value = "3" if ( $2 eq "wet" );
$value = "4" if ( $2 eq "rain" );
return undef if ( $value eq "" );
$unit = "";
}
elsif ( $event =~ /^(indoorHumidityCondition):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1;
$value = "";
$value = "0" if ( $2 eq "dry" );
$value = "1" if ( $2 eq "low" );
$value = "2" if ( $2 eq "optimal" );
$value = "3" if ( $2 eq "wet" );
return undef if ( $value eq "" );
$unit = "";
}
elsif ( $event =~ /^(wu_state):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1;
$value = "1" if ( $2 eq "ok" );
$value = "0" if ( $2 ne "ok" );
$unit = "";
}
elsif ( $event =~ /(.+):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1;
$value = $2;
$unit = $3;
}
Log3 $device, 5,
"HP1000 $device: Splitting event $event > reading=$reading value=$value unit=$unit";
return ( $reading, $value, $unit );
}
1;
=pod