HP1000: add RGB color for UV condition

git-svn-id: https://svn.fhem.de/fhem/trunk@13961 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2017-04-10 11:55:14 +00:00
parent 93ed6ad9dc
commit 160fe56aa0
3 changed files with 29 additions and 11 deletions

View File

@ -88,6 +88,7 @@ sub HP1000_Initialize($) {
'UV' => { rtype => 'uvi', }, 'UV' => { rtype => 'uvi', },
'UVR' => { rtype => 'uwpscm', }, 'UVR' => { rtype => 'uwpscm', },
'UVcondition' => { rtype => 'condition_uvi', }, 'UVcondition' => { rtype => 'condition_uvi', },
'UVcondition_rgb' => { rtype => 'rgb', },
'condition' => { rtype => 'condition_weather', }, 'condition' => { rtype => 'condition_weather', },
'daylight' => { rtype => 'yesno', }, 'daylight' => { rtype => 'yesno', },
'dewpoint' => { rtype => 'c', formula_symbol => 'Td', }, 'dewpoint' => { rtype => 'c', formula_symbol => 'Td', },
@ -873,8 +874,9 @@ sub HP1000_CGI() {
# UVcondition # UVcondition
if ( defined( $webArgs->{UVI} ) ) { if ( defined( $webArgs->{UVI} ) ) {
readingsBulkUpdateIfChanged( $hash, "UVcondition", my ( $v, $rgb ) = UConv::uvi2condition( $webArgs->{UVI} );
UConv::uvi2condition( $webArgs->{UVI} ) ); readingsBulkUpdateIfChanged( $hash, "UVcondition", $v );
readingsBulkUpdateIfChanged( $hash, "UVcondition_rgb", $rgb );
} }
# solarradiation in W/m2 (convert from lux) # solarradiation in W/m2 (convert from lux)

View File

@ -421,20 +421,26 @@ sub humidity2condition($) {
sub uvi2condition($) { sub uvi2condition($) {
my ($data) = @_; my ($data) = @_;
my $v = "low"; my $v = "low";
my $rgb = "4C9329";
if ( $data > 11 ) { if ( $data > 11 ) {
$v = "extreme"; $v = "extreme";
$rgb = "674BC4";
} }
elsif ( $data > 8 ) { elsif ( $data > 8 ) {
$v = "veryhigh"; $v = "veryhigh";
$rgb = "C72A23";
} }
elsif ( $data > 6 ) { elsif ( $data > 6 ) {
$v = "high"; $v = "high";
$rgb = "E7652B";
} }
elsif ( $data > 3 ) { elsif ( $data > 3 ) {
$v = "moderate"; $v = "moderate";
$rgb = "F4E54C";
} }
return ( $v, $rgb ) if (wantarray);
return $v; return $v;
} }
@ -442,17 +448,17 @@ sub values2weathercondition($$$$$) {
my ( $temp, $hum, $light, $isday, $israining ) = @_; my ( $temp, $hum, $light, $isday, $israining ) = @_;
my $condition = "clear"; my $condition = "clear";
if ( $israining eq "1" ) { if ($israining) {
$condition = "rain"; $condition = "rain";
} }
elsif ( $light > 40000 ) { elsif ( $light > 40000 ) {
$condition = "sunny"; $condition = "sunny";
} }
elsif ( $isday eq "1" ) { elsif ($isday) {
$condition = "cloudy"; $condition = "cloudy";
} }
$condition = "nt_" . $condition if ( !$isday ); $condition = "nt_" . $condition unless ($isday);
return $condition; return $condition;
} }

View File

@ -1327,6 +1327,16 @@ my $rtypes = {
}, },
}, },
# color
rgb => {
ref_base => 900,
rtype_description => {
de => 'RGB Farbwert',
en => 'RGB color value',
},
scope => '^#?(([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2}))$',
},
# logical operators # logical operators
bool => { bool => {
ref_base => 26, ref_base => 26,
@ -1334,7 +1344,7 @@ my $rtypes = {
de => [ 'falsch', 'wahr' ], de => [ 'falsch', 'wahr' ],
en => [ 'false', 'true' ], en => [ 'false', 'true' ],
}, },
scope => [ '^(false|no|0)$', '^(true|yes|1)$' ], scope => [ '^(false|n|no|0)$', '^(true|y|yes|1)$' ],
rtype_description => { rtype_description => {
de => 'Boolesch wahr/falsch', de => 'Boolesch wahr/falsch',
en => 'Boolean true/false', en => 'Boolean true/false',