mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-26 22:25:43 +00:00
HP1000: fix UV readings when SERVER_TYPE=php
Forum topic,44022.msg618189.html#msg618189 git-svn-id: https://svn.fhem.de/fhem/trunk@13950 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
1ea9cce528
commit
1f5602a269
@ -771,8 +771,9 @@ sub HP1000_CGI() {
|
||||
$p = "humidity" if ( $p eq "_outhumi" );
|
||||
$p = "indoorHumidity" if ( $p eq "_inhumi" );
|
||||
$p = "luminosity" if ( $p eq "_light" );
|
||||
$p = "UVR" if ( $p eq "_UV" );
|
||||
$p = "wind_direction" if ( $p eq "_winddir" );
|
||||
$p = "UV" if ( $p eq "_UV" && $hash->{SERVER_TYPE} eq "php" );
|
||||
$p = "UVR" if ( $p eq "_UV" && $hash->{SERVER_TYPE} ne "php" );
|
||||
|
||||
# name translation for Metric standard
|
||||
$p = "dewpoint" if ( $p eq "_dewpoint" );
|
||||
@ -850,10 +851,23 @@ sub HP1000_CGI() {
|
||||
UConv::humidity2condition( $webArgs->{inhumi} ) );
|
||||
}
|
||||
|
||||
# UV (convert from uW/cm2)
|
||||
if ( defined( $webArgs->{UV} ) ) {
|
||||
$webArgs->{UVI} = UConv::uwpscm2uvi( $webArgs->{UV} );
|
||||
readingsBulkUpdate( $hash, "UV", $webArgs->{UVI} );
|
||||
|
||||
# php reports UV as index
|
||||
# UVR (convert from UVI)
|
||||
if ( $hash->{SERVER_TYPE} eq 'php' ) {
|
||||
$webArgs->{UVI} = $webArgs->{UV};
|
||||
$webArgs->{UVR} = UConv::uvi2uwpscm( $webArgs->{UVI} );
|
||||
readingsBulkUpdate( $hash, "UVR", $webArgs->{UVR} );
|
||||
}
|
||||
|
||||
# jsp reports UV as radiation
|
||||
# UV (convert from uW/cm2)
|
||||
else {
|
||||
$webArgs->{UVR} = $webArgs->{UV};
|
||||
$webArgs->{UVI} = UConv::uwpscm2uvi( $webArgs->{UVR} );
|
||||
readingsBulkUpdate( $hash, "UV", $webArgs->{UVI} );
|
||||
}
|
||||
}
|
||||
|
||||
# UVcondition
|
||||
|
@ -274,6 +274,13 @@ sub uwpscm2uvi($) {
|
||||
return int( ( $data - 100 ) / 450 + 1 );
|
||||
}
|
||||
|
||||
# Power: convert UV-Index to uW/cm2 (micro watt per square centimeter)
|
||||
sub uvi2uwpscm($) {
|
||||
my ($data) = @_;
|
||||
|
||||
return ( $data * ( 450 + 1 ) ) + 100;
|
||||
}
|
||||
|
||||
# Power: convert lux to W/m2 (watt per square meter)
|
||||
sub lux2wpsm($;$) {
|
||||
my ( $data, $rnd ) = @_;
|
||||
@ -486,7 +493,7 @@ sub decimal_mark ($$) {
|
||||
|
||||
sub roundX($;$) {
|
||||
my ( $v, $n ) = @_;
|
||||
$n = 1 if ( !$n );
|
||||
$n = 1 unless ($n);
|
||||
return sprintf( "%.${n}f", $v );
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user