mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 03:06:41 +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)]]">
|
<template is="dom-if" if="[[_showValue(stateObj.attributes.pressure)]]">
|
||||||
<div>
|
<div>
|
||||||
[[localize('ui.card.weather.attributes.air_pressure')]]:
|
[[localize('ui.card.weather.attributes.air_pressure')]]:
|
||||||
[[stateObj.attributes.pressure]] hPa
|
[[stateObj.attributes.pressure]] [[getUnit('air_pressure')]]
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template is="dom-if" if="[[_showValue(stateObj.attributes.humidity)]]">
|
<template is="dom-if" if="[[_showValue(stateObj.attributes.humidity)]]">
|
||||||
@ -203,10 +203,17 @@ class HaWeatherCard extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
getUnit(measure) {
|
getUnit(measure) {
|
||||||
if (measure === 'precipitation') {
|
const lengthUnit = this.hass.config.core.unit_system.length;
|
||||||
return this.getUnit('length') === 'km' ? 'mm' : 'in';
|
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) {
|
computeState(state, localize) {
|
||||||
|
@ -56,7 +56,7 @@ class MoreInfoWeather extends LocalizeMixin(PolymerElement) {
|
|||||||
<div class="flex">
|
<div class="flex">
|
||||||
<iron-icon icon="hass:gauge"></iron-icon>
|
<iron-icon icon="hass:gauge"></iron-icon>
|
||||||
<div class="main">[[localize('ui.card.weather.attributes.air_pressure')]]</div>
|
<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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template is="dom-if" if="[[stateObj.attributes.humidity]]">
|
<template is="dom-if" if="[[stateObj.attributes.humidity]]">
|
||||||
@ -155,8 +155,18 @@ class MoreInfoWeather extends LocalizeMixin(PolymerElement) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getUnit(unit) {
|
getUnit(measure) {
|
||||||
return this.hass.config.core.unit_system[unit] || '';
|
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) {
|
windBearingToText(degree) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user