mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-13 12:26:35 +00:00
parent
21e4bc4ee4
commit
74e0779d38
@ -84,7 +84,8 @@ class HaWeatherCard extends
|
||||
}
|
||||
|
||||
.attributes,
|
||||
.templow {
|
||||
.templow,
|
||||
.precipitation { {
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
</style>
|
||||
@ -100,19 +101,19 @@ class HaWeatherCard extends
|
||||
</div>
|
||||
</div>
|
||||
<div class="attributes">
|
||||
<template is="dom-if" if="[[stateObj.attributes.pressure]]">
|
||||
<template is="dom-if" if="[[_showValue(stateObj.attributes.pressure)]]">
|
||||
<div>
|
||||
[[localize('ui.card.weather.attributes.air_pressure')]]:
|
||||
[[stateObj.attributes.pressure]] hPa
|
||||
</div>
|
||||
</template>
|
||||
<template is="dom-if" if="[[stateObj.attributes.humidity]]">
|
||||
<template is="dom-if" if="[[_showValue(stateObj.attributes.humidity)]]">
|
||||
<div>
|
||||
[[localize('ui.card.weather.attributes.humidity')]]:
|
||||
[[stateObj.attributes.humidity]] %
|
||||
</div>
|
||||
</template>
|
||||
<template is="dom-if" if="[[stateObj.attributes.humidity]]">
|
||||
<template is="dom-if" if="[[_showValue(stateObj.attributes.humidity)]]">
|
||||
<div>
|
||||
[[localize('ui.card.weather.attributes.wind_speed')]]:
|
||||
[[getWind(stateObj.attributes.wind_speed, stateObj.attributes.wind_bearing, localize)]]
|
||||
@ -134,9 +135,12 @@ class HaWeatherCard extends
|
||||
</div>
|
||||
</template>
|
||||
<div class="temp">[[item.temperature]] [[getUnit('temperature')]]</div>
|
||||
<template is="dom-if" if="[[item.templow]]">
|
||||
<template is="dom-if" if="[[_showValue(item.templow)]]">
|
||||
<div class="templow">[[item.templow]] [[getUnit('temperature')]]</div>
|
||||
</template>
|
||||
<template is="dom-if" if="[[_showValue(item.precipitation)]]">
|
||||
<div class="precipitation">[[item.precipitation]] [[getUnit('precipitation')]]</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
@ -194,8 +198,11 @@ class HaWeatherCard extends
|
||||
return forecast && forecast.slice(0, 5);
|
||||
}
|
||||
|
||||
getUnit(unit) {
|
||||
return this.hass.config.core.unit_system[unit] || '';
|
||||
getUnit(measure) {
|
||||
if (measure === 'precipitation') {
|
||||
return this.getUnit('length') === 'km' ? 'mm' : 'in';
|
||||
}
|
||||
return this.hass.config.core.unit_system[measure] || '';
|
||||
}
|
||||
|
||||
computeState(state, localize) {
|
||||
@ -226,6 +233,10 @@ class HaWeatherCard extends
|
||||
return `${speed} ${this.getUnit('length')}/h`;
|
||||
}
|
||||
|
||||
_showValue(item) {
|
||||
return typeof item !== 'undefined' && item !== null;
|
||||
}
|
||||
|
||||
computeDateTime(data) {
|
||||
const date = new Date(data);
|
||||
const provider = this.stateObj.attributes.attribution;
|
||||
|
Loading…
x
Reference in New Issue
Block a user