File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -255,6 +255,7 @@ class AirVisualCard extends HTMLElement {
255255 'so2' : 'ppb' ,
256256 }
257257 const mainPollutantValue = {
258+ 'p2' : 'PM2.5' ,
258259 'pm25' : 'PM2.5' ,
259260 'pm10' : 'PM10' ,
260261 'o3' : 'Ozone' ,
@@ -295,7 +296,9 @@ class AirVisualCard extends HTMLElement {
295296 if ( typeof hass . states [ mainPollutantSensor . config ] != "undefined" ) {
296297 if ( typeof hass . states [ mainPollutantSensor . config ] . attributes [ 'pollutant_unit' ] != "undefined" ) {
297298 pollutantUnit = hass . states [ mainPollutantSensor . config ] . attributes [ 'pollutant_unit' ] ;
298- mainPollutant = hass . states [ mainPollutantSensor . config ] . state ;
299+ // workaround related to Github issue #48. Using hard-coded translation in dictionary mainPollutantValue.
300+ // mainPollutant = hass.states[mainPollutantSensor.config].state;
301+ mainPollutant = mainPollutantValue [ hass . states [ mainPollutantSensor . config ] . state ] ;
299302 } else if ( typeof hass . states [ mainPollutantSensor . config ] . attributes [ 'dominentpol' ] != "undefined" ) {
300303 pollutantUnit = pollutantUnitValue [ hass . states [ mainPollutantSensor . config ] . attributes [ 'dominentpol' ] ] ;
301304 mainPollutant = mainPollutantValue [ hass . states [ mainPollutantSensor . config ] . attributes [ 'dominentpol' ] ] ;
@@ -313,7 +316,10 @@ class AirVisualCard extends HTMLElement {
313316 if ( ! isNaN ( aplParse ) ) {
314317 apl = APLdescription [ getAQI ( ) ] ;
315318 } else {
316- apl = hass . states [ aplSensor . config ] . state ;
319+ // Commenting this out as workaround for Github issue #48. The sensor.u_s_air_pollution_level uses keys for translation so text doesn't look nice.
320+ // Relying on hard-coded English translation defined in APLdescription variable
321+ // apl = hass.states[aplSensor.config].state;
322+ apl = APLdescription [ getAQI ( ) ] ;
317323 }
318324 }
319325 } ;
You can’t perform that action at this time.
0 commit comments