diff --git a/src/cards/ha-weather-card.js b/src/cards/ha-weather-card.js index aaa58babf9..093c41a771 100644 --- a/src/cards/ha-weather-card.js +++ b/src/cards/ha-weather-card.js @@ -104,7 +104,7 @@ class HaWeatherCard extends [[localize('ui.card.weather.attributes.air_pressure')]]: - [[stateObj.attributes.pressure]] hPa + [[stateObj.attributes.pressure]] [[getUnit('air_pressure')]] @@ -203,10 +203,17 @@ class HaWeatherCard extends } getUnit(measure) { - if (measure === 'precipitation') { - return this.getUnit('length') === 'km' ? 'mm' : 'in'; + const lengthUnit = this.hass.config.core.unit_system.length; + switch (measure) { + case 'air_pressure': + return lengthUnit === 'km' ? 'hPa' : 'inHg'; + case 'length': + return lengthUnit; + case 'precipitation': + return lengthUnit === 'km' ? 'mm' : 'in'; + default: + return this.hass.config.core.unit_system[measure] || ''; } - return this.hass.config.core.unit_system[measure] || ''; } computeState(state, localize) { diff --git a/src/dialogs/more-info/controls/more-info-weather.js b/src/dialogs/more-info/controls/more-info-weather.js index d273a55653..e783c53f45 100644 --- a/src/dialogs/more-info/controls/more-info-weather.js +++ b/src/dialogs/more-info/controls/more-info-weather.js @@ -56,7 +56,7 @@ class MoreInfoWeather extends LocalizeMixin(PolymerElement) { [[localize('ui.card.weather.attributes.air_pressure')]] - [[stateObj.attributes.pressure]] hPa + [[stateObj.attributes.pressure]] [[getUnit('air_pressure')]] @@ -155,8 +155,18 @@ class MoreInfoWeather extends LocalizeMixin(PolymerElement) { ); } - getUnit(unit) { - return this.hass.config.core.unit_system[unit] || ''; + getUnit(measure) { + const lengthUnit = this.hass.config.core.unit_system.length; + switch (measure) { + case 'air_pressure': + return lengthUnit === 'km' ? 'hPa' : 'inHg'; + case 'length': + return lengthUnit; + case 'precipitation': + return lengthUnit === 'km' ? 'mm' : 'in'; + default: + return this.hass.config.core.unit_system[measure] || ''; + } } windBearingToText(degree) {