diff --git a/46_Aqicn.pm b/46_Aqicn.pm
index b1b594b..26b6c85 100644
--- a/46_Aqicn.pm
+++ b/46_Aqicn.pm
@@ -67,7 +67,7 @@ eval "use Encode qw(encode encode_utf8 decode_utf8);1" or $missingModul .= "Enco
eval "use JSON;1" or $missingModul .= "JSON ";
-my $version = "0.0.36";
+my $version = "0.0.44";
@@ -352,7 +352,7 @@ sub Aqicn_GetData($;$) {
$param->{cl} = $hash->{CL} if( $hash->{TOKEN} and ref($hash->{CL}) eq 'HASH' );
HttpUtils_NonblockingGet($param);
- Log3 $name, 3, "Aqicn ($name) - Send with URI: https://$uri";
+ Log3 $name, 4, "Aqicn ($name) - Send with URI: https://$uri";
}
sub Aqicn_ErrorHandling($$$) {
@@ -473,6 +473,7 @@ sub Aqicn_WriteReadings($$) {
readingsBulkUpdate($hash,$r,$v);
}
+ readingsBulkUpdateIfChanged($hash,'htmlStyle','
'.Aqicn_AirPollutionLevel($hash,$readings->{'PM2.5-AQI'}).': '.$readings->{'PM2.5-AQI'}.'
');
readingsBulkUpdateIfChanged($hash,'state',Aqicn_AirPollutionLevel($hash,$readings->{'PM2.5-AQI'}));
readingsEndUpdate($hash,1);
}
@@ -569,38 +570,72 @@ sub Aqicn_AirPollutionLevel($$) {
my $apl;
- if($aqi < 51) { $apl = "Good"}
- elsif($aqi < 101) { $apl = "Moderate"}
- elsif($aqi < 151) { $apl = "Unhealthy for Sensitive Groups"}
- elsif($aqi < 201) { $apl = "Unhealthy"}
- elsif($aqi < 301) { $apl = "Very Unhealthy"}
- else { $apl = "Hazardous"}
+ if($aqi < 51) { $apl = 1}
+ elsif($aqi < 101) { $apl = 2}
+ elsif($aqi < 151) { $apl = 3}
+ elsif($aqi < 201) { $apl = 4}
+ elsif($aqi < 301) { $apl = 5}
+ else { $apl = 6}
if( (AttrVal('global','language','none') eq 'DE' or AttrVal($name,'language','none') eq 'de') and AttrVal($name,'language','none') ne 'en' ) {
return Aqicn_i18n_de($apl);
} else {
- return $apl;
+ return Aqicn_i18n_en($apl);
}
}
+sub Aqicn_HtmlStyle($) {
+
+ my $aqi = shift;
+ my $bgColor;
+
+
+ if($aqi < 51) { $bgColor = '#009966'}
+ elsif($aqi < 101) { $bgColor = '#ffde33'}
+ elsif($aqi < 151) { $bgColor = '#ff9933'}
+ elsif($aqi < 201) { $bgColor = '#cc0033'}
+ elsif($aqi < 301) { $bgColor = '#660099'}
+ else { $bgColor = '#7e0023'}
+
+ return $bgColor;
+}
+
sub Aqicn_i18n_de($) {
my $value = shift;
my %i18nde = (
- 'Good' => 'Gut',
- 'Moderate' => 'Moderat',
- 'Unhealthy for Sensitive Groups' => 'Ungesund für empfindliche Personengruppen',
- 'Unhealthy' => 'Ungesund',
- 'Very Unhealthy' => 'Sehr ungesund',
- 'Hazardous' => 'Gefährlich'
+ 1 => 'Gut',
+ 2 => 'Moderat',
+ 3 => 'Ungesund für empfindliche Personengruppen',
+ 4 => 'Ungesund',
+ 5 => 'Sehr ungesund',
+ 6 => 'Gefährlich'
);
return $i18nde{$value};
}
+sub Aqicn_i18n_en($) {
+
+ my $value = shift;
+
+
+ my %i18nen = (
+ 1 => 'Good',
+ 2 => 'Moderate',
+ 3 => 'Unhealthy for Sensitive Groups',
+ 4 => 'Unhealthy',
+ 5 => 'Very Unhealthy',
+ 6 => 'Hazardous'
+ );
+
+ return $i18nen{$value};
+}
+
+
@@ -610,70 +645,22 @@ sub Aqicn_i18n_de($) {
=pod
=item device
-=item summary Modul to retrieves data from a Tesla Powerwall 2AC
-=item summary_DE
+=item summary
+=item summary_DE
=begin html
-Tesla Powerwall 2 AC
+
- Aqicn - Retrieves data from a Tesla Powerwall 2AC System
-
- With this module it is possible to read the data from a Tesla Powerwall 2AC and to set it as reading.
-
-
- Define
-
- define <name> Aqicn <HOST>
-
- Example:
-
- define myPowerWall Aqicn 192.168.1.34
-
-
- This statement creates a Device with the name myPowerWall and the Host IP 192.168.1.34.
- After the device has been created, the current data of Powerwall is automatically read from the device.
-
-
-
- Readings
-
- - actionQueue - information about the entries in the action queue
- - aggregates-* - readings of the /api/meters/aggregates response
- - batteryLevel - battery level in percent
- - batteryPower - battery capacity in kWh
- - powerwalls-* - readings of the /api/powerwalls response
- - registration-* - readings of the /api/customer/registration response
- - siteinfo-* - readings of the /api/site_info response
- - sitemaster-* - readings of the /api/sitemaster response
- - state - information about internel modul processes
- - status-* - readings of the /api/status response
- - statussoe-* - readings of the /api/system_status/soe response
-
-
- get
-
- - aggregates - fetch data from url path /api/meters/aggregates
- - powerwalls - fetch data from url path /api/powerwalls
- - registration - fetch data from url path /api/customer/registration
- - siteinfo - fetch data from url path /api/site_info
- - sitemaster - fetch data from url path /api/sitemaster
- - status - fetch data from url path /api/status
- - statussoe - fetch data from url path /api/system_status/soe
-
-
- Attribute
-
- - interval - interval in seconds for automatically fetch data (default 300)
-
+
=end html
=begin html_DE
-Tesla Powerwall 2 AC
+
=end html_DE
=cut