Skip to content

Commit 545565b

Browse files
committed
workaround for issue #48
1 parent 2676fdd commit 545565b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

dist/air-visual-card.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff 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
};

0 commit comments

Comments
 (0)