dnguyen800 / air-visual-card

A Lovelace card showing air quality data from airvisual.com. Requires the AirVisual component.
MIT License
100 stars 35 forks source link

AirVisual Descriptions Updated #48

Closed ChrisRomp closed 2 years ago

ChrisRomp commented 2 years ago

HA Core recently updated the AirVisual component state descriptions to use keys to facilitate translation. This means that the output of the state is now (for example) unhealthy_sensitive instead of Unhealthy for Sensitive Groups.

Ref: home-assistant/core/pull/53133

As a workaround, this AirVisual Card configuration can be changed in Lovelace so the air_pollution_level parameter is mapped to the sensor.u_s_air_quality_index sensor since you already have an array called APLDescription with these values (ref).

I'm unsure if you want to fix this in code to translate the state keys, or just update the docs and/or remove the air_pollution_level parameter altogether and just use air_quality_index instead.

dnguyen800 commented 2 years ago

Thanks for letting me know. I'll look into making the change soon.

dnguyen800 commented 2 years ago

I added the workaround but would like to use the translated states of these sensors eventually. I'll keep the issue open until I find a resolution.

@ChrisRomp , do you know how to pull the translated value instead of the key?

ChrisRomp commented 2 years ago

They've switched to using keys to facilitate translation/localization.

ChrisRomp commented 2 years ago

Oh sorry I misread your question. I don't know how to pull the translated value from the front-end, no.

Swampen commented 2 years ago

Managed to getting the translated state values after a lot of digging. Calling hass.localize() and passing the translation key based on the component translation: sensor.en.json Explanation of how you can find the translation key can be found here: frontend-translations

dnguyen800 commented 2 years ago

Thank you for figuring this out and providing links. I will also update the code to translate the pollutant label.