From c4d3daffda2876df9e76bbf9c9fbbf358e953ab3 Mon Sep 17 00:00:00 2001 From: jpawlowski Date: Fri, 28 Oct 2016 15:48:35 +0000 Subject: [PATCH] 50_HP1000: use UConv to get short reading names git-svn-id: https://svn.fhem.de/fhem/trunk@12454 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/50_HP1000.pm | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/fhem/FHEM/50_HP1000.pm b/fhem/FHEM/50_HP1000.pm index a64af45b4..243bc6788 100755 --- a/fhem/FHEM/50_HP1000.pm +++ b/fhem/FHEM/50_HP1000.pm @@ -108,7 +108,7 @@ sub HP1000_Get($$$) { if ( !defined($result) ); } else { - $result = "Found existing WU device for this PWS ID: @wudev[0]"; + $result = "Found existing WU device for this PWS ID: $wudev[0]"; } } @@ -168,7 +168,7 @@ sub HP1000_Define($$$) { $hash->{FW_PORT} = $defs{ $hash->{FW} }{PORT}; - fhem 'attr ' . $name . ' stateReadings temp_c humidity'; + fhem 'attr ' . $name . ' stateReadings temperature humidity'; } if ( HP1000_addExtension( $name, "HP1000_CGI", "updateweatherstation" ) ) { @@ -296,8 +296,8 @@ sub HP1000_CGI() { delete $hash->{FORECASTDEV} if ( $hash->{FORECASTDEV} ); my @wudev = devspec2array( "TYPE=Wunderground:FILTER=PWS_ID=" . AttrVal( $name, "wu_id", "-" ) ); - $hash->{FORECASTDEV} = @wudev[0] - if ( defined( @wudev[0] ) ); + $hash->{FORECASTDEV} = $wudev[0] + if ( defined( $wudev[0] ) ); HP1000_SetAliveState( $hash, 1 ); @@ -1060,34 +1060,15 @@ sub HP1000_CGI() { # brightness in % ?? # state - my %shortnames = ( - "dewpoint" => "D", - "humidity" => "H", - "light" => "L", - "pressure" => "P", - "rain" => "R", - "rain_day" => "RD", - "rain_week" => "RW", - "rain_month" => "RM", - "rain_year" => "RY", - "solarradiation" => "SR", - "temp_c" => "T", - "wind_speed" => "W", - "wind_chill" => "WC", - "wind_gust" => "WG", - "wind_direction" => "WD", - "wind_dewpoint" => "D", - ); - my @stateReadings = split( /\s+/, AttrVal( $name, "stateReadings", "" ) ); foreach (@stateReadings) { $_ =~ /^(\w+):?(\w+)?$/; my $r = $1; - my $n = ( $2 ? $2 : ( $shortnames{$r} ? $shortnames{$r} : $1 ) ); + my $n = ( $2 ? $2 : UConv::rname2rsname($r) ); my $v = ReadingsVal( $name, $r, undef ); - if ($v) { - $$result .= " " if ( $result ne "Initialized" ); + if ( defined($v) ) { + $result .= " " if ( $result ne "Initialized" ); $result = "" if ( $result eq "Initialized" ); $result .= "$n: $v"; }