mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-24 21:37:21 +00:00
Only show entities in energy with energy
device class (#10076)
This commit is contained in:
parent
21e14bd644
commit
abc4816888
@ -51,6 +51,14 @@ export class HaStatisticPicker extends LitElement {
|
||||
@property({ type: Array, attribute: "include-unit-of-measurement" })
|
||||
public includeUnitOfMeasurement?: string[];
|
||||
|
||||
/**
|
||||
* Show only statistics with these device classes.
|
||||
* @type {Array}
|
||||
* @attr include-device-classes
|
||||
*/
|
||||
@property({ type: Array, attribute: "include-device-classes" })
|
||||
public includeDeviceClasses?: string[];
|
||||
|
||||
/**
|
||||
* Show only statistics on entities.
|
||||
* @type {Boolean}
|
||||
@ -116,6 +124,7 @@ export class HaStatisticPicker extends LitElement {
|
||||
(
|
||||
statisticIds: StatisticsMetaData[],
|
||||
includeUnitOfMeasurement?: string[],
|
||||
includeDeviceClasses?: string[],
|
||||
entitiesOnly?: boolean
|
||||
): Array<{ id: string; name: string; state?: HassEntity }> => {
|
||||
if (!statisticIds.length) {
|
||||
@ -148,11 +157,18 @@ export class HaStatisticPicker extends LitElement {
|
||||
}
|
||||
return;
|
||||
}
|
||||
output.push({
|
||||
id: meta.statistic_id,
|
||||
name: computeStateName(entityState),
|
||||
state: entityState,
|
||||
});
|
||||
if (
|
||||
!includeDeviceClasses ||
|
||||
includeDeviceClasses.includes(
|
||||
entityState!.attributes.device_class || ""
|
||||
)
|
||||
) {
|
||||
output.push({
|
||||
id: meta.statistic_id,
|
||||
name: computeStateName(entityState),
|
||||
state: entityState,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (!output.length) {
|
||||
@ -203,6 +219,7 @@ export class HaStatisticPicker extends LitElement {
|
||||
(this.comboBox as any).items = this._getStatistics(
|
||||
this.statisticIds!,
|
||||
this.includeUnitOfMeasurement,
|
||||
this.includeDeviceClasses,
|
||||
this.entitiesOnly
|
||||
);
|
||||
} else {
|
||||
@ -210,6 +227,7 @@ export class HaStatisticPicker extends LitElement {
|
||||
(this.comboBox as any).items = this._getStatistics(
|
||||
this.statisticIds!,
|
||||
this.includeUnitOfMeasurement,
|
||||
this.includeDeviceClasses,
|
||||
this.entitiesOnly
|
||||
);
|
||||
});
|
||||
|
@ -4,7 +4,6 @@ import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import { computeStateName } from "../../../../common/entity/compute_state_name";
|
||||
import "../../../../components/entity/ha-statistic-picker";
|
||||
import "../../../../components/ha-card";
|
||||
import "../../../../components/ha-settings-row";
|
||||
import {
|
||||
|
@ -15,6 +15,7 @@ import "@material/mwc-button/mwc-button";
|
||||
import "../../../../components/entity/ha-statistic-picker";
|
||||
|
||||
const energyUnits = ["kWh"];
|
||||
const energyDeviceClasses = ["energy"];
|
||||
|
||||
@customElement("dialog-energy-battery-settings")
|
||||
export class DialogEnergyBatterySettings
|
||||
@ -65,6 +66,7 @@ export class DialogEnergyBatterySettings
|
||||
<ha-statistic-picker
|
||||
.hass=${this.hass}
|
||||
.includeUnitOfMeasurement=${energyUnits}
|
||||
.includeDeviceClasses=${energyDeviceClasses}
|
||||
.value=${this._source.stat_energy_to}
|
||||
.label=${`Energy going in to the battery (kWh)`}
|
||||
entities-only
|
||||
@ -74,6 +76,7 @@ export class DialogEnergyBatterySettings
|
||||
<ha-statistic-picker
|
||||
.hass=${this.hass}
|
||||
.includeUnitOfMeasurement=${energyUnits}
|
||||
.includeDeviceClasses=${energyDeviceClasses}
|
||||
.value=${this._source.stat_energy_from}
|
||||
.label=${`Energy coming out of the battery (kWh)`}
|
||||
entities-only
|
||||
|
@ -15,6 +15,7 @@ import "../../../../components/ha-formfield";
|
||||
import "../../../../components/entity/ha-entity-picker";
|
||||
|
||||
const energyUnits = ["kWh"];
|
||||
const energyDeviceClasses = ["energy"];
|
||||
|
||||
@customElement("dialog-energy-device-settings")
|
||||
export class DialogEnergyDeviceSettings
|
||||
@ -67,6 +68,7 @@ export class DialogEnergyDeviceSettings
|
||||
<ha-statistic-picker
|
||||
.hass=${this.hass}
|
||||
.includeUnitOfMeasurement=${energyUnits}
|
||||
.includeDeviceClasses=${energyDeviceClasses}
|
||||
.label=${`Device consumption energy (kWh)`}
|
||||
entities-only
|
||||
@value-changed=${this._statisticChanged}
|
||||
|
@ -21,6 +21,7 @@ import type { HaRadio } from "../../../../components/ha-radio";
|
||||
import "../../../../components/entity/ha-entity-picker";
|
||||
|
||||
const energyUnits = ["kWh"];
|
||||
const energyDeviceClasses = ["energy"];
|
||||
|
||||
@customElement("dialog-energy-grid-flow-settings")
|
||||
export class DialogEnergyGridFlowSettings
|
||||
@ -94,6 +95,7 @@ export class DialogEnergyGridFlowSettings
|
||||
<ha-statistic-picker
|
||||
.hass=${this.hass}
|
||||
.includeUnitOfMeasurement=${energyUnits}
|
||||
.includeDeviceClasses=${energyDeviceClasses}
|
||||
.value=${this._source[
|
||||
this._params.direction === "from"
|
||||
? "stat_energy_from"
|
||||
|
@ -23,6 +23,7 @@ import { ConfigEntry, getConfigEntries } from "../../../../data/config_entries";
|
||||
import { brandsUrl } from "../../../../util/brands-url";
|
||||
|
||||
const energyUnits = ["kWh"];
|
||||
const energyDeviceClasses = ["energy"];
|
||||
|
||||
@customElement("dialog-energy-solar-settings")
|
||||
export class DialogEnergySolarSettings
|
||||
@ -79,6 +80,7 @@ export class DialogEnergySolarSettings
|
||||
<ha-statistic-picker
|
||||
.hass=${this.hass}
|
||||
.includeUnitOfMeasurement=${energyUnits}
|
||||
.includeDeviceClasses=${energyDeviceClasses}
|
||||
.value=${this._source.stat_energy_from}
|
||||
.label=${`Solar production energy (kWh)`}
|
||||
entities-only
|
||||
|
Loading…
x
Reference in New Issue
Block a user