mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-26 22:37:21 +00:00
Weather Card: Ability to choose Secondary Attribute (#5820)
This commit is contained in:
parent
6d0823328d
commit
c861ee025e
@ -200,7 +200,20 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="attribute">
|
<div class="attribute">
|
||||||
${getSecondaryWeatherAttribute(this.hass, stateObj)}
|
${this._config.secondary_info_attribute !== undefined
|
||||||
|
? html`
|
||||||
|
${this.hass!.localize(
|
||||||
|
`ui.card.weather.attributes.${this._config.secondary_info_attribute}`
|
||||||
|
)}
|
||||||
|
${stateObj.attributes[
|
||||||
|
this._config.secondary_info_attribute
|
||||||
|
]}
|
||||||
|
${getWeatherUnit(
|
||||||
|
this.hass,
|
||||||
|
this._config.secondary_info_attribute
|
||||||
|
)}
|
||||||
|
`
|
||||||
|
: getSecondaryWeatherAttribute(this.hass, stateObj)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -275,4 +275,5 @@ export interface WeatherForecastCardConfig extends LovelaceCardConfig {
|
|||||||
entity: string;
|
entity: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
show_forecast?: boolean;
|
show_forecast?: boolean;
|
||||||
|
secondary_info_attribute?: string;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ const cardConfigStruct = struct({
|
|||||||
name: "string?",
|
name: "string?",
|
||||||
theme: "string?",
|
theme: "string?",
|
||||||
show_forecast: "boolean?",
|
show_forecast: "boolean?",
|
||||||
|
secondary_info_attribute: "string?",
|
||||||
});
|
});
|
||||||
|
|
||||||
const includeDomains = ["weather"];
|
const includeDomains = ["weather"];
|
||||||
@ -54,6 +55,10 @@ export class HuiWeatherForecastCardEditor extends LitElement
|
|||||||
return this._config!.show_forecast || true;
|
return this._config!.show_forecast || true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get _secondary_info_attribute(): string {
|
||||||
|
return this._config!.secondary_info_attribute || "";
|
||||||
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
if (!this.hass || !this._config) {
|
if (!this.hass || !this._config) {
|
||||||
return html``;
|
return html``;
|
||||||
@ -93,12 +98,26 @@ export class HuiWeatherForecastCardEditor extends LitElement
|
|||||||
@value-changed=${this._valueChanged}
|
@value-changed=${this._valueChanged}
|
||||||
></hui-theme-select-editor>
|
></hui-theme-select-editor>
|
||||||
</div>
|
</div>
|
||||||
<ha-switch
|
<div class="side-by-side">
|
||||||
.checked=${this._config!.show_forecast !== false}
|
<paper-input
|
||||||
.configValue=${"show_forecast"}
|
.label="${this.hass.localize(
|
||||||
@change=${this._valueChanged}
|
"ui.panel.lovelace.editor.card.generic.secondary_info_attribute"
|
||||||
>Show forecast</ha-switch
|
)} (${this.hass.localize(
|
||||||
>
|
"ui.panel.lovelace.editor.card.config.optional"
|
||||||
|
)})"
|
||||||
|
.value=${this._secondary_info_attribute}
|
||||||
|
.configValue=${"secondary_info_attribute"}
|
||||||
|
@value-changed=${this._valueChanged}
|
||||||
|
></paper-input>
|
||||||
|
<ha-switch
|
||||||
|
.checked=${this._config!.show_forecast !== false}
|
||||||
|
.configValue=${"show_forecast"}
|
||||||
|
@change=${this._valueChanged}
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.lovelace.editor.card.weather.show_forecast"
|
||||||
|
)}</ha-switch
|
||||||
|
>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
@ -1841,7 +1841,8 @@
|
|||||||
"no_theme": "No theme",
|
"no_theme": "No theme",
|
||||||
"unit": "Unit",
|
"unit": "Unit",
|
||||||
"url": "Url",
|
"url": "Url",
|
||||||
"state": "State"
|
"state": "State",
|
||||||
|
"secondary_info_attribute": "Secondary Info Attribute"
|
||||||
},
|
},
|
||||||
"map": {
|
"map": {
|
||||||
"name": "Map",
|
"name": "Map",
|
||||||
@ -1902,7 +1903,8 @@
|
|||||||
},
|
},
|
||||||
"weather-forecast": {
|
"weather-forecast": {
|
||||||
"name": "Weather Forecast",
|
"name": "Weather Forecast",
|
||||||
"description": "The Weather Forecast card displays the weather. Very useful to include on interfaces that people display on the wall."
|
"description": "The Weather Forecast card displays the weather. Very useful to include on interfaces that people display on the wall.",
|
||||||
|
"show_forecast": "Show Forecast"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"view": {
|
"view": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user