2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-20 19:36:02 +00:00

59_Wunderground: readings to comply with Fhem standards

git-svn-id: https://svn.fhem.de/fhem/trunk@12441 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2016-10-26 23:39:52 +00:00
parent 4d756dbd69
commit fee4a10a17

View File

@ -307,27 +307,19 @@ sub Wunderground_Hash2Readings($$;$) {
# custom reading # custom reading
$cr = "condition" if ( $cr eq "weather" ); $cr = "condition" if ( $cr eq "weather" );
$cr = "dewpoint" if ( $cr eq "dewpoint_c" ); $cr = "dewpoint" if ( $cr eq "dewpoint_c" );
$cr = "heatIndex" if ( $cr eq "heat_index_c" );
$cr = "heatIndex_f" if ( $cr eq "heat_index_f" );
$cr = "humidity" if ( $cr eq "relative_humidity" ); $cr = "humidity" if ( $cr eq "relative_humidity" );
$cr = "pressure" if ( $cr eq "pressure_mb" ); $cr = "pressure" if ( $cr eq "pressure_mb" );
$cr = "pressureTrend" if ( $cr eq "pressure_trend" );
$cr = "rain" if ( $cr eq "precip_1hr_metric" ); $cr = "rain" if ( $cr eq "precip_1hr_metric" );
$cr = "rainDay" if ( $cr eq "precip_today_metric" ); $cr = "rain_day" if ( $cr eq "precip_today_metric" );
$cr = "rain_in" if ( $cr eq "precip_1hr_in" ); $cr = "rain_in" if ( $cr eq "precip_1hr_in" );
$cr = "rainDay_in" if ( $cr eq "precip_today_in" ); $cr = "rain_day_in" if ( $cr eq "precip_today_in" );
$cr = "temperature" if ( $cr eq "temp_c" ); $cr = "wind_direction" if ( $cr eq "wind_degrees" );
$cr = "temperature_f" if ( $cr eq "temp_f" ); $cr = "wind_gust" if ( $cr eq "wind_gust_kph" );
$cr = "temperatureFeel" if ( $cr eq "feelslike_c" ); $cr = "wind_gust_mph" if ( $cr eq "wind_gust_mph" );
$cr = "temperatureFeel_f" if ( $cr eq "feelslike_f" ); $cr = "wind_speed" if ( $cr eq "wind_kph" );
$cr = "uvIndex" if ( $cr eq "UV" ); $cr = "wind_speed_mph" if ( $cr eq "wind_mph" );
$cr = "windDir" if ( $cr eq "wind_degrees" ); $cr = "wind_chill" if ( $cr eq "windchill_c" );
$cr = "windGust" if ( $cr eq "wind_gust_kph" ); $cr = "wind_chill_f" if ( $cr eq "windchill_f" );
$cr = "windGust_mph" if ( $cr eq "wind_gust_mph" );
$cr = "windSpeed" if ( $cr eq "wind_kph" );
$cr = "windSpeed_mph" if ( $cr eq "wind_mph" );
$cr = "windChill" if ( $cr eq "windchill_c" );
$cr = "windChill_f" if ( $cr eq "windchill_f" );
$cr = "visibility" if ( $cr eq "visibility_km" ); $cr = "visibility" if ( $cr eq "visibility_km" );
next next
@ -373,11 +365,11 @@ sub Wunderground_Hash2Readings($$;$) {
readingsBulkUpdate( $hash, "moonrise", $moonrise ); readingsBulkUpdate( $hash, "moonrise", $moonrise );
readingsBulkUpdate( $hash, "moonset", $moonset ); readingsBulkUpdate( $hash, "moonset", $moonset );
readingsBulkUpdate( $hash, "moonAge", readingsBulkUpdate( $hash, "moon_age",
$h->{moon_phase}{ageOfMoon} ); $h->{moon_phase}{ageOfMoon} );
readingsBulkUpdate( $hash, "moonPct", readingsBulkUpdate( $hash, "moon_pct",
$h->{moon_phase}{percentIlluminated} ); $h->{moon_phase}{percentIlluminated} );
readingsBulkUpdate( $hash, "moonPhase", readingsBulkUpdate( $hash, "moon_phase",
$h->{moon_phase}{phaseofMoon} ); $h->{moon_phase}{phaseofMoon} );
} }
@ -392,7 +384,7 @@ sub Wunderground_Hash2Readings($$;$) {
$h->{conditions} ); $h->{conditions} );
readingsBulkUpdate( readingsBulkUpdate(
$hash, $hash,
$reading . "high", $reading . "high_c",
$h->{high}{celsius} $h->{high}{celsius}
); );
readingsBulkUpdate( readingsBulkUpdate(
@ -402,16 +394,16 @@ sub Wunderground_Hash2Readings($$;$) {
); );
readingsBulkUpdate( $hash, $reading . "humidity", readingsBulkUpdate( $hash, $reading . "humidity",
$h->{avehumidity} ); $h->{avehumidity} );
readingsBulkUpdate( $hash, $reading . "humidityMin", readingsBulkUpdate( $hash, $reading . "humidity_min",
$h->{minhumidity} ); $h->{minhumidity} );
readingsBulkUpdate( $hash, $reading . "humidityMax", readingsBulkUpdate( $hash, $reading . "humidity_max",
$h->{maxhumidity} ); $h->{maxhumidity} );
readingsBulkUpdate( $hash, $reading . "icon", $h->{icon} ); readingsBulkUpdate( $hash, $reading . "icon", $h->{icon} );
readingsBulkUpdate( $hash, $reading . "icon_url", readingsBulkUpdate( $hash, $reading . "icon_url",
$h->{icon_url} ); $h->{icon_url} );
readingsBulkUpdate( readingsBulkUpdate(
$hash, $hash,
$reading . "low", $reading . "low_c",
$h->{low}{celsius} $h->{low}{celsius}
); );
readingsBulkUpdate( readingsBulkUpdate(
@ -422,72 +414,72 @@ sub Wunderground_Hash2Readings($$;$) {
readingsBulkUpdate( $hash, $reading . "pop", $h->{pop} ); readingsBulkUpdate( $hash, $reading . "pop", $h->{pop} );
readingsBulkUpdate( readingsBulkUpdate(
$hash, $hash,
$reading . "rainDay", $reading . "rain_day",
$h->{qpf_allday}{mm} $h->{qpf_allday}{mm}
); );
readingsBulkUpdate( readingsBulkUpdate(
$hash, $hash,
$reading . "rainDay_in", $reading . "rain_day_in",
$h->{qpf_allday}{in} $h->{qpf_allday}{in}
); );
readingsBulkUpdate( readingsBulkUpdate(
$hash, $hash,
$reading . "rainNight", $reading . "rain_night",
$h->{qpf_night}{mm} $h->{qpf_night}{mm}
); );
readingsBulkUpdate( readingsBulkUpdate(
$hash, $hash,
$reading . "rainNight_in", $reading . "rain_night_in",
$h->{qpf_night}{in} $h->{qpf_night}{in}
); );
readingsBulkUpdate( readingsBulkUpdate(
$hash, $hash,
$reading . "snowDay", $reading . "snow_day",
$h->{snow_allday}{cm} $h->{snow_allday}{cm}
); );
readingsBulkUpdate( readingsBulkUpdate(
$hash, $hash,
$reading . "snowDay_in", $reading . "snow_day_in",
$h->{snow_allday}{in} $h->{snow_allday}{in}
); );
readingsBulkUpdate( readingsBulkUpdate(
$hash, $hash,
$reading . "snowNight", $reading . "snow_night",
$h->{snow_night}{cm} $h->{snow_night}{cm}
); );
readingsBulkUpdate( readingsBulkUpdate(
$hash, $hash,
$reading . "snowNight_in", $reading . "snow_night_in",
$h->{snow_night}{in} $h->{snow_night}{in}
); );
readingsBulkUpdate( readingsBulkUpdate(
$hash, $hash,
$reading . "windDir", $reading . "wind_direction",
$h->{avewind}{degrees} $h->{avewind}{degrees}
); );
readingsBulkUpdate( readingsBulkUpdate(
$hash, $hash,
$reading . "windDirMax", $reading . "wind_direction_max",
$h->{maxwind}{degrees} $h->{maxwind}{degrees}
); );
readingsBulkUpdate( readingsBulkUpdate(
$hash, $hash,
$reading . "windSpeed", $reading . "wind_speed",
$h->{avewind}{kph} $h->{avewind}{kph}
); );
readingsBulkUpdate( readingsBulkUpdate(
$hash, $hash,
$reading . "windSpeed_mph", $reading . "wind_speed_mph",
$h->{avewind}{mph} $h->{avewind}{mph}
); );
readingsBulkUpdate( readingsBulkUpdate(
$hash, $hash,
$reading . "windSpeedMax", $reading . "wind_speed_max",
$h->{maxwind}{kph} $h->{maxwind}{kph}
); );
readingsBulkUpdate( readingsBulkUpdate(
$hash, $hash,
$reading . "windSpeedMax_mph", $reading . "wind_speed_max_mph",
$h->{maxwind}{mph} $h->{maxwind}{mph}
); );
} }
@ -501,7 +493,7 @@ sub Wunderground_Hash2Readings($$;$) {
( $period eq "1" ( $period eq "1"
|| $period eq "3" || $period eq "3"
|| $period eq "5" || $period eq "5"
|| $period eq "7" ? "N" : "" ); || $period eq "7" ? "_night" : "" );
if ( $period < 2 ) { if ( $period < 2 ) {
$period = "0"; $period = "0";
@ -598,21 +590,17 @@ sub Wunderground_DbLog_split($$) {
my $hash = $defs{$device}; my $hash = $defs{$device};
if ( $event =~ if ( $event =~
/^(windCompasspoint.*|.*_sum10m|.*_avg2m|uvCondition):\s([\w\.,]+)\s*(.*)/ /^(wind_compasspoint.*|.*_sum10m|.*_avg2m|uvCondition):\s([\w\.,]+)\s*(.*)/
) )
{ {
return undef; return undef;
} }
elsif ( $event =~ elsif ( $event =~ /^(dewpoint|temp_c|wind_chill):\s([\w\.,]+)\s*(.*)/ ) {
/^(dewpoint|dewpointIndoor|temperature|temperatureIndoor|windChill):\s([\w\.,]+)\s*(.*)/
)
{
$reading = $1; $reading = $1;
$value = $2; $value = $2;
$unit = "°C"; $unit = "°C";
} }
elsif ( $event =~ elsif ( $event =~ /^(dewpoint_f|temp_f|wind_chill_f):\s([\w\.,]+)\s*(.*)/ )
/^(dewpoint_f|temperature_f|windChill_f):\s([\w\.,]+)\s*(.*)/ )
{ {
$reading = $1; $reading = $1;
$value = $2; $value = $2;
@ -628,7 +616,7 @@ sub Wunderground_DbLog_split($$) {
$value = $2; $value = $2;
$unit = "W/m2"; $unit = "W/m2";
} }
elsif ( $event =~ /^(pressureTrend):\s([\w\.,]+)\s*(.*)/ ) { elsif ( $event =~ /^(pressure_trend):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1; $reading = $1;
$value = ""; $value = "";
$value = "0" if ( $2 eq "=" ); $value = "0" if ( $2 eq "=" );
@ -662,70 +650,63 @@ sub Wunderground_DbLog_split($$) {
$value = $2; $value = $2;
$unit = "in/h"; $unit = "in/h";
} }
elsif ( $event =~ /^(rain|.*rainDay|.*rainNight):\s([\w\.,]+)\s*(.*)/ ) { elsif ( $event =~ /^(rain|.*rain_day|.*rain_night):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1; $reading = $1;
$value = $2; $value = $2;
$unit = "mm"; $unit = "mm";
} }
elsif ( elsif ( $event =~
$event =~ /^(rain_in|.*rainDay_in|.*rainNight_in):\s([\w\.,]+)\s*(.*)/ ) /^(rain_in|.*rain_day_in|.*rain_night_in):\s([\w\.,]+)\s*(.*)/ )
{ {
$reading = $1; $reading = $1;
$value = $2; $value = $2;
$unit = "in"; $unit = "in";
} }
elsif ( $event =~ /^(uvIndex):\s([\w\.,]+)\s*(.*)/ ) { elsif ( $event =~ /^(UV):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1; $reading = $1;
$value = $2; $value = $2;
$unit = "UVI"; $unit = "UVI";
} }
elsif ( $event =~ /^(.*windDir.*):\s([\w\.,]+)\s*(.*)/ ) { elsif ( $event =~ /^(.*wind_direction.*):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1; $reading = $1;
$value = $2; $value = $2;
$unit = "°"; $unit = "°";
} }
elsif ( $event =~ elsif ( $event =~
/^(.*windGust|.*windSpeed|.*windSpeedMax):\s([\w\.,]+)\s*(.*)/ ) /^(.*wind_gust|.*wind_speed|.*wind_speed_max):\s([\w\.,]+)\s*(.*)/ )
{ {
$reading = $1; $reading = $1;
$value = $2; $value = $2;
$unit = "km/h"; $unit = "km/h";
} }
elsif ( $event =~ elsif ( $event =~
/^(.*windGust_mph|.*windSpeed_mph|.*windSpeedMax_mph):\s([\w\.,]+)\s*(.*)/ /^(.*wind_gust_mph|.*wind_speed_mph|.*wind_speed_max_mph):\s([\w\.,]+)\s*(.*)/
) )
{ {
$reading = $1; $reading = $1;
$value = $2; $value = $2;
$unit = "mph"; $unit = "mph";
} }
elsif ( $event =~ /^(windGust_bft|windSpeed_bft):\s([\w\.,]+)\s*(.*)/ ) { elsif ( $event =~ /^(wind_gust_bft|wind_speed_bft):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1; $reading = $1;
$value = $2; $value = $2;
$unit = "Bft"; $unit = "Bft";
} }
elsif ( $event =~ /^(windGust_mps|windSpeed_mps):\s([\w\.,]+)\s*(.*)/ ) { elsif ( $event =~ /^(wind_gust_mps|wind_speed_mps):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1; $reading = $1;
$value = $2; $value = $2;
$unit = "m/s"; $unit = "m/s";
} }
elsif ( $event =~ /^(windGust_fts|windSpeed_fts):\s([\w\.,]+)\s*(.*)/ ) { elsif ( $event =~ /^(wind_gust_fts|wind_speed_fts):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1; $reading = $1;
$value = $2; $value = $2;
$unit = "ft/s"; $unit = "ft/s";
} }
elsif ( $event =~ /^(windGust_kn|windSpeed_kn):\s([\w\.,]+)\s*(.*)/ ) { elsif ( $event =~ /^(wind_gust_kn|wind_speed_kn):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1; $reading = $1;
$value = $2; $value = $2;
$unit = "kn"; $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*(.*)/ ) { elsif ( $event =~ /^(.*condition):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1; $reading = $1;
$value = ""; $value = "";
@ -736,7 +717,7 @@ sub Wunderground_DbLog_split($$) {
return undef if ( $value eq "" ); return undef if ( $value eq "" );
$unit = ""; $unit = "";
} }
elsif ( $event =~ /^(humidityCondition):\s([\w\.,]+)\s*(.*)/ ) { elsif ( $event =~ /^(humidity_condition):\s([\w\.,]+)\s*(.*)/ ) {
$reading = $1; $reading = $1;
$value = ""; $value = "";
$value = "0" if ( $2 eq "dry" ); $value = "0" if ( $2 eq "dry" );