2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-01 01:09:47 +00:00

50_HP1000: add custom state definition using stateReadings attribute

git-svn-id: https://svn.fhem.de/fhem/trunk@12445 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2016-10-27 16:10:21 +00:00
parent 14ea02de29
commit 3c0f1236dc

View File

@ -70,7 +70,7 @@ sub HP1000_Initialize($) {
$hash->{parseParams} = 1; $hash->{parseParams} = 1;
$hash->{AttrList} = $hash->{AttrList} =
"wu_push:1,0 wu_id wu_password wu_realtime:1,0 extSrvPush_Url " "wu_push:1,0 wu_id wu_password wu_realtime:1,0 extSrvPush_Url stateReadings "
. $readingFnAttributes; . $readingFnAttributes;
} }
@ -167,6 +167,8 @@ sub HP1000_Define($$$) {
} }
$hash->{FW_PORT} = $defs{ $hash->{FW} }{PORT}; $hash->{FW_PORT} = $defs{ $hash->{FW} }{PORT};
fhem 'attr ' . $name . ' stateReadings temp_c humidity';
} }
if ( HP1000_addExtension( $name, "HP1000_CGI", "updateweatherstation" ) ) { if ( HP1000_addExtension( $name, "HP1000_CGI", "updateweatherstation" ) ) {
@ -237,7 +239,7 @@ sub HP1000_CGI() {
my $name = ""; my $name = "";
my $link; my $link;
my $URI; my $URI;
my $result = ""; my $result = "Initialized";
my $webArgs; my $webArgs;
my $servertype; my $servertype;
@ -1057,48 +1059,39 @@ sub HP1000_CGI() {
# soilTemperature # soilTemperature
# brightness in % ?? # brightness in % ??
$result = "T: " . $webArgs->{outtemp} # state
if ( defined( $webArgs->{outtemp} ) ); my %shortnames = (
$result .= " H: " . $webArgs->{outhumi} "dewpoint" => "D",
if ( defined( $webArgs->{outhumi} ) ); "humidity" => "H",
$result .= " Ti: " . $webArgs->{intemp} "light" => "L",
if ( defined( $webArgs->{intemp} ) ); "pressure" => "P",
$result .= " Hi: " . $webArgs->{inhumi} "rain" => "R",
if ( defined( $webArgs->{inhumi} ) ); "rain_day" => "RD",
$result .= " W: " . $webArgs->{windspeed} "rain_week" => "RW",
if ( defined( $webArgs->{windspeed} ) ); "rain_month" => "RM",
$result .= " W: " . $webArgs->{windspdmph} "rain_year" => "RY",
if ( defined( $webArgs->{windspdmph} ) ); "solarradiation" => "SR",
$result .= " WC: " . $webArgs->{windchill} "temp_c" => "T",
if ( defined( $webArgs->{windchill} ) ); "wind_speed" => "W",
$result .= " WG: " . $webArgs->{windgust} "wind_chill" => "WC",
if ( defined( $webArgs->{windgust} ) ); "wind_gust" => "WG",
$result .= " WG: " . $webArgs->{windgustmph} "wind_direction" => "WD",
if ( defined( $webArgs->{windgustmph} ) ); "wind_dewpoint" => "D",
$result .= " R: " . $webArgs->{rainrate} );
if ( defined( $webArgs->{rainrate} ) );
$result .= " RD: " . $webArgs->{dailyrain} my @stateReadings = split( /\s+/, AttrVal( $name, "stateReadings", "" ) );
if ( defined( $webArgs->{dailyrain} ) ); foreach (@stateReadings) {
$result .= " RW: " . $webArgs->{weeklyrain} $_ =~ /^(\w+):?(\w+)?$/;
if ( defined( $webArgs->{weeklyrain} ) ); my $r = $1;
$result .= " RM: " . $webArgs->{monthlyrain} my $n = ( $2 ? $2 : ( $shortnames{$r} ? $shortnames{$r} : $1 ) );
if ( defined( $webArgs->{monthlyrain} ) );
$result .= " RY: " . $webArgs->{yearlyrain} my $v = ReadingsVal( $name, $r, undef );
if ( defined( $webArgs->{yearlyrain} ) ); if ($v) {
$result .= " WD: " . $webArgs->{winddir} $$result .= " " if ( $result ne "Initialized" );
if ( defined( $webArgs->{winddir} ) ); $result = "" if ( $result eq "Initialized" );
$result .= " D: " . $webArgs->{dewpoint} $result .= "$n: $v";
if ( defined( $webArgs->{dewpoint} ) ); }
$result .= " P: " . $webArgs->{relbaro} }
if ( defined( $webArgs->{relbaro} ) );
$result .= " UVR: " . $webArgs->{UV}
if ( defined( $webArgs->{UV} ) );
$result .= " UV: " . $webArgs->{UVI}
if ( defined( $webArgs->{UVI} ) );
$result .= " L: " . $webArgs->{light}
if ( defined( $webArgs->{light} ) );
$result .= " SR: " . $webArgs->{solarradiation}
if ( defined( $webArgs->{solarradiation} ) );
readingsBulkUpdate( $hash, "state", $result ); readingsBulkUpdate( $hash, "state", $result );
readingsEndUpdate( $hash, 1 ); readingsEndUpdate( $hash, 1 );