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