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

50_HP1000: use UConv to get short reading names

git-svn-id: https://svn.fhem.de/fhem/trunk@12454 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2016-10-28 15:48:35 +00:00
parent 3e3ee40144
commit c4d3daffda

View File

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