From 92339238fa62498c2bee0714aafcdd6bf70389ba Mon Sep 17 00:00:00 2001 From: LeonGaultier Date: Fri, 27 Oct 2017 04:21:08 +0000 Subject: [PATCH] 46_Aqicn: FHEMWEB text color formated, thanks to maddhin git-svn-id: https://svn.fhem.de/fhem/trunk@15326 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/46_Aqicn.pm | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 31d681725..5127c9b5e 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - feature: 46_Aqicn: FHEMWEB text color formated, thanks to maddhin - update: 74_74_XiaomiFlowerMonitor: new version, change internal routine - feature: fhemweb_iconRadio.js: optionally colorize selected icons instead of its background by prefix use4icon@ diff --git a/fhem/FHEM/46_Aqicn.pm b/fhem/FHEM/46_Aqicn.pm index ef03ab3b3..e348cd8fd 100644 --- a/fhem/FHEM/46_Aqicn.pm +++ b/fhem/FHEM/46_Aqicn.pm @@ -62,19 +62,20 @@ eval "use Encode qw(encode encode_utf8 decode_utf8);1" or $missingModul .= "Enco eval "use JSON;1" or $missingModul .= "JSON "; -my $version = "0.2.0"; +my $version = "0.2.1"; ### Air Quality Index scale my %AQIS = ( - 1 => { 'i18nde' => 'Gut' ,'i18nen' => 'Good' ,'bgcolor' => '#009966'}, - 2 => { 'i18nde' => 'Moderat' ,'i18nen' => 'Moderate' ,'bgcolor' => '#ffde33'}, - 3 => { 'i18nde' => 'Ungesund für empfindliche Personengruppen' ,'i18nen' => 'Unhealthy for Sensitive Groups' ,'bgcolor' => '#ff9933'}, - 4 => { 'i18nde' => 'Ungesund' ,'i18nen' => 'Unhealthy' ,'bgcolor' => '#cc0033'}, - 5 => { 'i18nde' => 'Sehr ungesund' ,'i18nen' => 'Very Unhealthy' ,'bgcolor' => '#660099'}, - 6 => { 'i18nde' => 'Gefährlich' ,'i18nen' => 'Hazardous' ,'bgcolor' => '#7e0023'}, + + 1 => { 'i18nde' => 'Gut' ,'i18nen' => 'Good' ,'bgcolor' => '#009966' ,'font color' => '#FFFFFF'}, + 2 => { 'i18nde' => 'Moderat' ,'i18nen' => 'Moderate' ,'bgcolor' => '#ffde33' ,'font color' => '#000000'}, + 3 => { 'i18nde' => 'Ungesund für empfindliche Personengruppen' ,'i18nen' => 'Unhealthy for Sensitive Groups' ,'bgcolor' => '#ff9933' ,'font color' => '#000000'}, + 4 => { 'i18nde' => 'Ungesund' ,'i18nen' => 'Unhealthy' ,'bgcolor' => '#cc0033' ,'font color' => '#FFFFFF'}, + 5 => { 'i18nde' => 'Sehr ungesund' ,'i18nen' => 'Very Unhealthy' ,'bgcolor' => '#660099' ,'font color' => '#FFFFFF'}, + 6 => { 'i18nde' => 'Gefährlich' ,'i18nen' => 'Hazardous' ,'bgcolor' => '#7e0023' ,'font color' => '#FFFFFF'}, ); @@ -492,7 +493,8 @@ sub Aqicn_WriteReadings($$) { } if( defined($readings->{'PM2.5-AQI'}) ) { - readingsBulkUpdateIfChanged($hash,'htmlStyle','
'.( ((AttrVal('global','language','none') eq 'DE' or AttrVal($name,'language','none') eq 'de') and AttrVal($name,'language','none') ne 'en') ? "$AQIS{Aqicn_AirPollutionLevel($readings->{'PM2.5-AQI'})}{'i18nde'}: $readings->{'PM2.5-AQI'} " : " $AQIS{Aqicn_AirPollutionLevel($readings->{'PM2.5-AQI'})}{'i18nen'}: $readings->{'PM2.5-AQI'}").'
'); + + readingsBulkUpdateIfChanged($hash,'htmlStyle','
'.( ((AttrVal('global','language','none') eq 'DE' or AttrVal($name,'language','none') eq 'de') and AttrVal($name,'language','none') ne 'en') ? "$AQIS{Aqicn_AirPollutionLevel($readings->{'PM2.5-AQI'})}{'i18nde'}: $readings->{'PM2.5-AQI'} " : " $AQIS{Aqicn_AirPollutionLevel($readings->{'PM2.5-AQI'})}{'i18nen'}: $readings->{'PM2.5-AQI'}").'
'); readingsBulkUpdateIfChanged($hash,'state',( ((AttrVal('global','language','none') eq 'DE' or AttrVal($name,'language','none') eq 'de') and AttrVal($name,'language','none') ne 'en') ? "$AQIS{Aqicn_AirPollutionLevel($readings->{'PM2.5-AQI'})}{'i18nde'}: $readings->{'PM2.5-AQI'}" : "$AQIS{Aqicn_AirPollutionLevel($readings->{'PM2.5-AQI'})}{'i18nen'}: $readings->{'PM2.5-AQI'}") ); @@ -500,7 +502,8 @@ sub Aqicn_WriteReadings($$) { readingsBulkUpdateIfChanged($hash,'healthImplications',Aqicn_HealthImplications($hash,Aqicn_AirPollutionLevel($readings->{'PM2.5-AQI'})) ); } else { - readingsBulkUpdateIfChanged($hash,'htmlStyle','
'.( ((AttrVal('global','language','none') eq 'DE' or AttrVal($name,'language','none') eq 'de') and AttrVal($name,'language','none') ne 'en') ? "$AQIS{Aqicn_AirPollutionLevel($readings->{'AQI'})}{'i18nde'}: $readings->{'AQI'} " : " $AQIS{Aqicn_AirPollutionLevel($readings->{'AQI'})}{'i18nen'}: $readings->{'AQI'}").'
'); + + readingsBulkUpdateIfChanged($hash,'htmlStyle','
'.( ((AttrVal('global','language','none') eq 'DE' or AttrVal($name,'language','none') eq 'de') and AttrVal($name,'language','none') ne 'en') ? "$AQIS{Aqicn_AirPollutionLevel($readings->{'AQI'})}{'i18nde'}: $readings->{'AQI'} " : " $AQIS{Aqicn_AirPollutionLevel($readings->{'AQI'})}{'i18nen'}: $readings->{'AQI'}").'
'); readingsBulkUpdateIfChanged($hash,'state',( ((AttrVal('global','language','none') eq 'DE' or AttrVal($name,'language','none') eq 'de') and AttrVal($name,'language','none') ne 'en') ? "$AQIS{Aqicn_AirPollutionLevel($readings->{'AQI'})}{'i18nde'}: $readings->{'AQI'}" : "$AQIS{Aqicn_AirPollutionLevel($readings->{'AQI'})}{'i18nen'}: $readings->{'AQI'}") ); @@ -511,7 +514,6 @@ sub Aqicn_WriteReadings($$) { readingsEndUpdate($hash,1); } - ##### ##### ## my little Helper