mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Fix air pressure uom in weather cards (#1346)
* Fix aire pressure uom in weather cards * Feedback * Lint
This commit is contained in:
parent
7bfc01b02c
commit
be7900cd87
@ -104,7 +104,7 @@ class HaWeatherCard extends
|
||||
<template is="dom-if" if="[[_showValue(stateObj.attributes.pressure)]]">
|
||||
<div>
|
||||
[[localize('ui.card.weather.attributes.air_pressure')]]:
|
||||
[[stateObj.attributes.pressure]] hPa
|
||||
[[stateObj.attributes.pressure]] [[getUnit('air_pressure')]]
|
||||
</div>
|
||||
</template>
|
||||
<template is="dom-if" if="[[_showValue(stateObj.attributes.humidity)]]">
|
||||
@ -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) {
|
||||
|
@ -56,7 +56,7 @@ class MoreInfoWeather extends LocalizeMixin(PolymerElement) {
|
||||
<div class="flex">
|
||||
<iron-icon icon="hass:gauge"></iron-icon>
|
||||
<div class="main">[[localize('ui.card.weather.attributes.air_pressure')]]</div>
|
||||
<div>[[stateObj.attributes.pressure]] hPa</div>
|
||||
<div>[[stateObj.attributes.pressure]] [[getUnit('air_pressure')]]</div>
|
||||
</div>
|
||||
</template>
|
||||
<template is="dom-if" if="[[stateObj.attributes.humidity]]">
|
||||
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user