mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-09 02:49:51 +00:00
Compare commits
96 Commits
copilot/al
...
20251103.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
561122f03d | ||
|
|
95311be034 | ||
|
|
1eda44a102 | ||
|
|
d76781eb91 | ||
|
|
82d44e051f | ||
|
|
fdc9f5a3b7 | ||
|
|
ee6c82aba9 | ||
|
|
11d3f5c2ba | ||
|
|
feb68ce373 | ||
|
|
7f9a9de157 | ||
|
|
8e1b6a3d3b | ||
|
|
6e6e5a53e2 | ||
|
|
0408734ec5 | ||
|
|
317519fc08 | ||
|
|
843d79eab4 | ||
|
|
165a757f06 | ||
|
|
ea8b730142 | ||
|
|
e88c97d625 | ||
|
|
7560988b76 | ||
|
|
eecd8077b6 | ||
|
|
cbab5c3f7b | ||
|
|
a5d27c8bb8 | ||
|
|
a6a340b5db | ||
|
|
8f5875c30f | ||
|
|
517cd49f35 | ||
|
|
25d9fc94b2 | ||
|
|
7b188759e3 | ||
|
|
76772d1098 | ||
|
|
6052745ca0 | ||
|
|
89b9780345 | ||
|
|
a607edca96 | ||
|
|
52eb3d8063 | ||
|
|
3e749ec085 | ||
|
|
ee2ec00069 | ||
|
|
0aa2941868 | ||
|
|
46cd1d5156 | ||
|
|
07a5c41fd4 | ||
|
|
4ad3c553d5 | ||
|
|
d40cc448a5 | ||
|
|
e2f3f9d348 | ||
|
|
98d44950f8 | ||
|
|
8ae9edb1ef | ||
|
|
84c4396c13 | ||
|
|
2b937a30e3 | ||
|
|
b7815bfd86 | ||
|
|
d94fa03411 | ||
|
|
0a7007ef9e | ||
|
|
dd12136dee | ||
|
|
6e2f89fe3d | ||
|
|
092085b9af | ||
|
|
1c06eb8661 | ||
|
|
c7e87b06b5 | ||
|
|
38c738c199 | ||
|
|
e899587307 | ||
|
|
c9feb0b75f | ||
|
|
10718c35d1 | ||
|
|
4dc6a37bad | ||
|
|
ac49fc7aba | ||
|
|
e4f008800b | ||
|
|
0b0ffd7bab | ||
|
|
dfa77526a2 | ||
|
|
9a3bd6c613 | ||
|
|
1161de5746 | ||
|
|
9df8e20391 | ||
|
|
11047a9c95 | ||
|
|
18fa66f61c | ||
|
|
758a048f34 | ||
|
|
ee0fc360b0 | ||
|
|
4012f95ec1 | ||
|
|
0336ce4606 | ||
|
|
9ba36ab7e2 | ||
|
|
fe7a08a1b0 | ||
|
|
87a8f9cedc | ||
|
|
01df7e20ca | ||
|
|
d181219522 | ||
|
|
6ae24b8135 | ||
|
|
8e009f24f9 | ||
|
|
53031f44ac | ||
|
|
af5a988457 | ||
|
|
bab0391a19 | ||
|
|
444123c47e | ||
|
|
f123d34046 | ||
|
|
1b40f99f68 | ||
|
|
b314b3ed2b | ||
|
|
59b8932969 | ||
|
|
107af753ec | ||
|
|
1f0acb3046 | ||
|
|
431e533929 | ||
|
|
02c845cbc6 | ||
|
|
628111ed20 | ||
|
|
e825a9c02f | ||
|
|
7a35bddf36 | ||
|
|
ad69270af8 | ||
|
|
404edf9483 | ||
|
|
a166b4e9b6 | ||
|
|
7a285f11db |
@@ -16,9 +16,9 @@ import {
|
|||||||
} from "../../../../src/common/auth/token_storage";
|
} from "../../../../src/common/auth/token_storage";
|
||||||
import { atLeastVersion } from "../../../../src/common/config/version";
|
import { atLeastVersion } from "../../../../src/common/config/version";
|
||||||
import { toggleAttribute } from "../../../../src/common/dom/toggle_attribute";
|
import { toggleAttribute } from "../../../../src/common/dom/toggle_attribute";
|
||||||
|
import "../../../../src/components/ha-button";
|
||||||
import "../../../../src/components/ha-icon";
|
import "../../../../src/components/ha-icon";
|
||||||
import "../../../../src/components/ha-list";
|
import "../../../../src/components/ha-list";
|
||||||
import "../../../../src/components/ha-button";
|
|
||||||
import "../../../../src/components/ha-list-item";
|
import "../../../../src/components/ha-list-item";
|
||||||
import "../../../../src/components/ha-svg-icon";
|
import "../../../../src/components/ha-svg-icon";
|
||||||
import {
|
import {
|
||||||
@@ -28,7 +28,6 @@ import {
|
|||||||
import { isStrategyDashboard } from "../../../../src/data/lovelace/config/types";
|
import { isStrategyDashboard } from "../../../../src/data/lovelace/config/types";
|
||||||
import type { LovelaceViewConfig } from "../../../../src/data/lovelace/config/view";
|
import type { LovelaceViewConfig } from "../../../../src/data/lovelace/config/view";
|
||||||
import "../../../../src/layouts/hass-loading-screen";
|
import "../../../../src/layouts/hass-loading-screen";
|
||||||
import { generateDefaultViewConfig } from "../../../../src/panels/lovelace/common/generate-lovelace-config";
|
|
||||||
import "./hc-layout";
|
import "./hc-layout";
|
||||||
|
|
||||||
@customElement("hc-cast")
|
@customElement("hc-cast")
|
||||||
@@ -96,7 +95,9 @@ class HcCast extends LitElement {
|
|||||||
<ha-list @action=${this._handlePickView} activatable>
|
<ha-list @action=${this._handlePickView} activatable>
|
||||||
${(
|
${(
|
||||||
this.lovelaceViews ?? [
|
this.lovelaceViews ?? [
|
||||||
generateDefaultViewConfig({}, {}, {}, {}, () => ""),
|
{
|
||||||
|
title: "Home",
|
||||||
|
},
|
||||||
]
|
]
|
||||||
).map(
|
).map(
|
||||||
(view, idx) => html`
|
(view, idx) => html`
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ const SENSOR_DEVICE_CLASSES = [
|
|||||||
"pm1",
|
"pm1",
|
||||||
"pm10",
|
"pm10",
|
||||||
"pm25",
|
"pm25",
|
||||||
|
"pm4",
|
||||||
"power_factor",
|
"power_factor",
|
||||||
"power",
|
"power",
|
||||||
"precipitation",
|
"precipitation",
|
||||||
|
|||||||
@@ -235,5 +235,8 @@
|
|||||||
"tslib": "2.8.1",
|
"tslib": "2.8.1",
|
||||||
"@material/mwc-list@^0.27.0": "patch:@material/mwc-list@npm%3A0.27.0#~/.yarn/patches/@material-mwc-list-npm-0.27.0-5344fc9de4.patch"
|
"@material/mwc-list@^0.27.0": "patch:@material/mwc-list@npm%3A0.27.0#~/.yarn/patches/@material-mwc-list-npm-0.27.0-5344fc9de4.patch"
|
||||||
},
|
},
|
||||||
"packageManager": "yarn@4.10.3"
|
"packageManager": "yarn@4.10.3",
|
||||||
|
"volta": {
|
||||||
|
"node": "22.21.1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "home-assistant-frontend"
|
name = "home-assistant-frontend"
|
||||||
version = "20250924.0"
|
version = "20251103.0"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
license-files = ["LICENSE*"]
|
license-files = ["LICENSE*"]
|
||||||
description = "The Home Assistant frontend"
|
description = "The Home Assistant frontend"
|
||||||
|
|||||||
@@ -214,6 +214,7 @@ const FIXED_DOMAIN_ATTRIBUTE_STATES = {
|
|||||||
"pm1",
|
"pm1",
|
||||||
"pm10",
|
"pm10",
|
||||||
"pm25",
|
"pm25",
|
||||||
|
"pm4",
|
||||||
"power_factor",
|
"power_factor",
|
||||||
"power",
|
"power",
|
||||||
"pressure",
|
"pressure",
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ export const MIN_TIME_BETWEEN_UPDATES = 60 * 5 * 1000;
|
|||||||
const LEGEND_OVERFLOW_LIMIT = 10;
|
const LEGEND_OVERFLOW_LIMIT = 10;
|
||||||
const LEGEND_OVERFLOW_LIMIT_MOBILE = 6;
|
const LEGEND_OVERFLOW_LIMIT_MOBILE = 6;
|
||||||
const DOUBLE_TAP_TIME = 300;
|
const DOUBLE_TAP_TIME = 300;
|
||||||
|
const RESIZE_ANIMATION_DURATION = 250;
|
||||||
|
|
||||||
export type CustomLegendOption = ECOption["legend"] & {
|
export type CustomLegendOption = ECOption["legend"] & {
|
||||||
type: "custom";
|
type: "custom";
|
||||||
@@ -205,6 +206,15 @@ export class HaChartBase extends LitElement {
|
|||||||
}
|
}
|
||||||
if (changedProps.has("options")) {
|
if (changedProps.has("options")) {
|
||||||
chartOptions = { ...chartOptions, ...this._createOptions() };
|
chartOptions = { ...chartOptions, ...this._createOptions() };
|
||||||
|
if (
|
||||||
|
this._compareCustomLegendOptions(
|
||||||
|
changedProps.get("options"),
|
||||||
|
this.options
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
// custom legend changes may require a resize to layout properly
|
||||||
|
this._shouldResizeChart = true;
|
||||||
|
}
|
||||||
} else if (this._isTouchDevice && changedProps.has("_isZoomed")) {
|
} else if (this._isTouchDevice && changedProps.has("_isZoomed")) {
|
||||||
chartOptions.dataZoom = this._getDataZoomConfig();
|
chartOptions.dataZoom = this._getDataZoomConfig();
|
||||||
}
|
}
|
||||||
@@ -296,7 +306,7 @@ export class HaChartBase extends LitElement {
|
|||||||
itemStyle = {
|
itemStyle = {
|
||||||
color: dataset?.color as string,
|
color: dataset?.color as string,
|
||||||
...(dataset?.itemStyle as { borderColor?: string }),
|
...(dataset?.itemStyle as { borderColor?: string }),
|
||||||
itemStyle,
|
...itemStyle,
|
||||||
};
|
};
|
||||||
const color = itemStyle?.color as string;
|
const color = itemStyle?.color as string;
|
||||||
const borderColor = itemStyle?.borderColor as string;
|
const borderColor = itemStyle?.borderColor as string;
|
||||||
@@ -508,6 +518,7 @@ export class HaChartBase extends LitElement {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
this.requestUpdate("_hiddenDatasets");
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getDataZoomConfig(): DataZoomComponentOption | undefined {
|
private _getDataZoomConfig(): DataZoomComponentOption | undefined {
|
||||||
@@ -641,6 +652,13 @@ export class HaChartBase extends LitElement {
|
|||||||
textBorderWidth: 2,
|
textBorderWidth: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
pie: {
|
||||||
|
label: {
|
||||||
|
color: style.getPropertyValue("--primary-text-color"),
|
||||||
|
textBorderColor: style.getPropertyValue("--primary-background-color"),
|
||||||
|
textBorderWidth: 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
sankey: {
|
sankey: {
|
||||||
label: {
|
label: {
|
||||||
color: style.getPropertyValue("--primary-text-color"),
|
color: style.getPropertyValue("--primary-text-color"),
|
||||||
@@ -958,11 +976,31 @@ export class HaChartBase extends LitElement {
|
|||||||
|
|
||||||
private _handleChartRenderFinished = () => {
|
private _handleChartRenderFinished = () => {
|
||||||
if (this._shouldResizeChart) {
|
if (this._shouldResizeChart) {
|
||||||
this.chart?.resize();
|
this.chart?.resize({
|
||||||
|
animation: this._reducedMotion
|
||||||
|
? undefined
|
||||||
|
: { duration: RESIZE_ANIMATION_DURATION },
|
||||||
|
});
|
||||||
this._shouldResizeChart = false;
|
this._shouldResizeChart = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private _compareCustomLegendOptions(
|
||||||
|
oldOptions: ECOption | undefined,
|
||||||
|
newOptions: ECOption | undefined
|
||||||
|
): boolean {
|
||||||
|
const oldLegends = ensureArray(
|
||||||
|
oldOptions?.legend || []
|
||||||
|
) as LegendComponentOption[];
|
||||||
|
const newLegends = ensureArray(
|
||||||
|
newOptions?.legend || []
|
||||||
|
) as LegendComponentOption[];
|
||||||
|
return (
|
||||||
|
oldLegends.some((l) => l.show && l.type === "custom") !==
|
||||||
|
newLegends.some((l) => l.show && l.type === "custom")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
static styles = css`
|
static styles = css`
|
||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
|
|||||||
@@ -87,6 +87,8 @@ export class StateHistoryChartLine extends LitElement {
|
|||||||
|
|
||||||
private _previousYAxisLabelValue = 0;
|
private _previousYAxisLabelValue = 0;
|
||||||
|
|
||||||
|
private _yAxisMaximumFractionDigits = 0;
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
return html`
|
return html`
|
||||||
<ha-chart-base
|
<ha-chart-base
|
||||||
@@ -757,8 +759,12 @@ export class StateHistoryChartLine extends LitElement {
|
|||||||
Math.log10(Math.abs(value - this._previousYAxisLabelValue || 1))
|
Math.log10(Math.abs(value - this._previousYAxisLabelValue || 1))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
this._yAxisMaximumFractionDigits = Math.max(
|
||||||
|
this._yAxisMaximumFractionDigits,
|
||||||
|
maximumFractionDigits
|
||||||
|
);
|
||||||
const label = formatNumber(value, this.hass.locale, {
|
const label = formatNumber(value, this.hass.locale, {
|
||||||
maximumFractionDigits,
|
maximumFractionDigits: this._yAxisMaximumFractionDigits,
|
||||||
});
|
});
|
||||||
const width = measureTextWidth(label, 12) + 5;
|
const width = measureTextWidth(label, 12) + 5;
|
||||||
if (width > this._yWidth) {
|
if (width > this._yWidth) {
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ class HaEntitiesPicker extends LitElement {
|
|||||||
.createDomains=${this.createDomains}
|
.createDomains=${this.createDomains}
|
||||||
.required=${this.required && !currentEntities.length}
|
.required=${this.required && !currentEntities.length}
|
||||||
@value-changed=${this._addEntity}
|
@value-changed=${this._addEntity}
|
||||||
add-button
|
.addButton=${currentEntities.length > 0}
|
||||||
></ha-entity-picker>
|
></ha-entity-picker>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ export class HaEntityNamePicker extends LitElement {
|
|||||||
private _toValue = memoizeOne(
|
private _toValue = memoizeOne(
|
||||||
(items: EntityNameItem[]): typeof this.value => {
|
(items: EntityNameItem[]): typeof this.value => {
|
||||||
if (items.length === 0) {
|
if (items.length === 0) {
|
||||||
return "";
|
return undefined;
|
||||||
}
|
}
|
||||||
if (items.length === 1) {
|
if (items.length === 1) {
|
||||||
const item = items[0];
|
const item = items[0];
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ export class HaButton extends Button {
|
|||||||
line-height: 1;
|
line-height: 1;
|
||||||
|
|
||||||
transition: background-color 0.15s ease-in-out;
|
transition: background-color 0.15s ease-in-out;
|
||||||
|
text-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
:host([size="small"]) .button {
|
:host([size="small"]) .button {
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ export class HaForm extends LitElement implements HaFormElement {
|
|||||||
.value=${getValue(this.data, item)}
|
.value=${getValue(this.data, item)}
|
||||||
.label=${this._computeLabel(item, this.data)}
|
.label=${this._computeLabel(item, this.data)}
|
||||||
.disabled=${item.disabled || this.disabled || false}
|
.disabled=${item.disabled || this.disabled || false}
|
||||||
.placeholder=${item.required ? "" : item.default}
|
.placeholder=${item.required ? undefined : item.default}
|
||||||
.helper=${this._computeHelper(item)}
|
.helper=${this._computeHelper(item)}
|
||||||
.localizeValue=${this.localizeValue}
|
.localizeValue=${this.localizeValue}
|
||||||
.required=${item.required || false}
|
.required=${item.required || false}
|
||||||
|
|||||||
@@ -16,14 +16,10 @@ import memoizeOne from "memoize-one";
|
|||||||
import { computeCssColor } from "../../common/color/compute-color";
|
import { computeCssColor } from "../../common/color/compute-color";
|
||||||
import { hex2rgb } from "../../common/color/convert-color";
|
import { hex2rgb } from "../../common/color/convert-color";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import { slugify } from "../../common/string/slugify";
|
import { computeDeviceNameDisplay } from "../../common/entity/compute_device_name";
|
||||||
import {
|
|
||||||
computeDeviceName,
|
|
||||||
computeDeviceNameDisplay,
|
|
||||||
} from "../../common/entity/compute_device_name";
|
|
||||||
import { computeDomain } from "../../common/entity/compute_domain";
|
import { computeDomain } from "../../common/entity/compute_domain";
|
||||||
import { computeEntityName } from "../../common/entity/compute_entity_name";
|
import { computeStateName } from "../../common/entity/compute_state_name";
|
||||||
import { getEntityContext } from "../../common/entity/context/get_entity_context";
|
import { slugify } from "../../common/string/slugify";
|
||||||
import { getConfigEntry } from "../../data/config_entries";
|
import { getConfigEntry } from "../../data/config_entries";
|
||||||
import { labelsContext } from "../../data/context";
|
import { labelsContext } from "../../data/context";
|
||||||
import { domainToName } from "../../data/integration";
|
import { domainToName } from "../../data/integration";
|
||||||
@@ -172,23 +168,10 @@ export class HaTargetPickerValueChip extends LitElement {
|
|||||||
if (type === "entity") {
|
if (type === "entity") {
|
||||||
this._setDomainName(computeDomain(itemId));
|
this._setDomainName(computeDomain(itemId));
|
||||||
|
|
||||||
const stateObject = this.hass.states[itemId];
|
const stateObj = this.hass.states[itemId];
|
||||||
const entityName = computeEntityName(
|
|
||||||
stateObject,
|
|
||||||
this.hass.entities,
|
|
||||||
this.hass.devices
|
|
||||||
);
|
|
||||||
const { device } = getEntityContext(
|
|
||||||
stateObject,
|
|
||||||
this.hass.entities,
|
|
||||||
this.hass.devices,
|
|
||||||
this.hass.areas,
|
|
||||||
this.hass.floors
|
|
||||||
);
|
|
||||||
const deviceName = device ? computeDeviceName(device) : undefined;
|
|
||||||
return {
|
return {
|
||||||
name: entityName || deviceName || itemId,
|
name: computeStateName(stateObj) || itemId,
|
||||||
stateObject,
|
stateObject: stateObj,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { isComponentLoaded } from "../common/config/is_component_loaded";
|
||||||
|
import { atLeastVersion } from "../common/config/version";
|
||||||
import type { HomeAssistant } from "../types";
|
import type { HomeAssistant } from "../types";
|
||||||
|
|
||||||
export interface LogProvider {
|
export interface LogProvider {
|
||||||
@@ -8,4 +10,8 @@ export interface LogProvider {
|
|||||||
export const fetchErrorLog = (hass: HomeAssistant) =>
|
export const fetchErrorLog = (hass: HomeAssistant) =>
|
||||||
hass.callApi<string>("GET", "error_log");
|
hass.callApi<string>("GET", "error_log");
|
||||||
|
|
||||||
export const getErrorLogDownloadUrl = "/api/error_log";
|
export const getErrorLogDownloadUrl = (hass: HomeAssistant) =>
|
||||||
|
isComponentLoaded(hass, "hassio") &&
|
||||||
|
atLeastVersion(hass.config.version, 2025, 10)
|
||||||
|
? "/api/hassio/core/logs/latest"
|
||||||
|
: "/api/error_log";
|
||||||
|
|||||||
@@ -97,6 +97,9 @@ export const ENTITY_COMPONENT_ICONS: Record<string, ComponentIcons> = {
|
|||||||
pm25: {
|
pm25: {
|
||||||
default: "mdi:molecule",
|
default: "mdi:molecule",
|
||||||
},
|
},
|
||||||
|
pm4: {
|
||||||
|
default: "mdi:molecule",
|
||||||
|
},
|
||||||
power: {
|
power: {
|
||||||
default: "mdi:flash",
|
default: "mdi:flash",
|
||||||
},
|
},
|
||||||
@@ -674,6 +677,9 @@ export const ENTITY_COMPONENT_ICONS: Record<string, ComponentIcons> = {
|
|||||||
pm25: {
|
pm25: {
|
||||||
default: "mdi:molecule",
|
default: "mdi:molecule",
|
||||||
},
|
},
|
||||||
|
pm4: {
|
||||||
|
default: "mdi:molecule",
|
||||||
|
},
|
||||||
power: {
|
power: {
|
||||||
default: "mdi:flash",
|
default: "mdi:flash",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
getFloors,
|
getFloors,
|
||||||
} from "../../lovelace/strategies/areas/helpers/areas-strategy-helper";
|
} from "../../lovelace/strategies/areas/helpers/areas-strategy-helper";
|
||||||
import { getHomeStructure } from "../../lovelace/strategies/home/helpers/home-structure";
|
import { getHomeStructure } from "../../lovelace/strategies/home/helpers/home-structure";
|
||||||
|
import { floorDefaultIcon } from "../../../components/ha-floor-icon";
|
||||||
|
|
||||||
export interface ClimateViewStrategyConfig {
|
export interface ClimateViewStrategyConfig {
|
||||||
type: "climate";
|
type: "climate";
|
||||||
@@ -152,6 +153,7 @@ export class ClimateViewStrategy extends ReactiveElement {
|
|||||||
floorCount > 1
|
floorCount > 1
|
||||||
? floor.name
|
? floor.name
|
||||||
: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
||||||
|
icon: floor.icon || floorDefaultIcon(floor),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1137,11 +1137,11 @@ class DialogAddAutomationElement
|
|||||||
}
|
}
|
||||||
.groups .selected {
|
.groups .selected {
|
||||||
background-color: var(--ha-color-fill-primary-normal-active);
|
background-color: var(--ha-color-fill-primary-normal-active);
|
||||||
--md-list-item-label-text-color: var(--primary-color);
|
--md-list-item-label-text-color: var(--ha-color-on-primary-normal);
|
||||||
--icon-primary-color: var(--primary-color);
|
--icon-primary-color: var(--ha-color-on-primary-normal);
|
||||||
}
|
}
|
||||||
.groups .selected ha-svg-icon {
|
.groups .selected ha-svg-icon {
|
||||||
color: var(--primary-color);
|
color: var(--ha-color-on-primary-normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
.collection-title {
|
.collection-title {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
mdiContentCopy,
|
mdiContentCopy,
|
||||||
mdiContentCut,
|
mdiContentCut,
|
||||||
mdiDelete,
|
mdiDelete,
|
||||||
|
mdiIdentifier,
|
||||||
mdiPlayCircleOutline,
|
mdiPlayCircleOutline,
|
||||||
mdiPlaylistEdit,
|
mdiPlaylistEdit,
|
||||||
mdiPlusCircleMultipleOutline,
|
mdiPlusCircleMultipleOutline,
|
||||||
@@ -40,6 +41,8 @@ export default class HaAutomationSidebarTrigger extends LitElement {
|
|||||||
@property({ type: Number, attribute: "sidebar-key" })
|
@property({ type: Number, attribute: "sidebar-key" })
|
||||||
public sidebarKey?: number;
|
public sidebarKey?: number;
|
||||||
|
|
||||||
|
@state() private _requestShowId = false;
|
||||||
|
|
||||||
@state() private _warnings?: string[];
|
@state() private _warnings?: string[];
|
||||||
|
|
||||||
@query(".sidebar-editor")
|
@query(".sidebar-editor")
|
||||||
@@ -47,6 +50,7 @@ export default class HaAutomationSidebarTrigger extends LitElement {
|
|||||||
|
|
||||||
protected willUpdate(changedProperties) {
|
protected willUpdate(changedProperties) {
|
||||||
if (changedProperties.has("config")) {
|
if (changedProperties.has("config")) {
|
||||||
|
this._requestShowId = false;
|
||||||
this._warnings = undefined;
|
this._warnings = undefined;
|
||||||
if (this.config) {
|
if (this.config) {
|
||||||
this.yamlMode = this.config.yamlMode;
|
this.yamlMode = this.config.yamlMode;
|
||||||
@@ -101,6 +105,24 @@ export default class HaAutomationSidebarTrigger extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
|
|
||||||
|
${!this.yamlMode &&
|
||||||
|
!("id" in this.config.config) &&
|
||||||
|
!this._requestShowId
|
||||||
|
? html`<ha-md-menu-item
|
||||||
|
slot="menu-items"
|
||||||
|
.clickAction=${this._showTriggerId}
|
||||||
|
.disabled=${this.disabled || type === "list"}
|
||||||
|
>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiIdentifier}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.triggers.edit_id"
|
||||||
|
)}
|
||||||
|
<span class="shortcut-placeholder ${isMac ? "mac" : ""}"></span>
|
||||||
|
</div>
|
||||||
|
</ha-md-menu-item>`
|
||||||
|
: nothing}
|
||||||
|
|
||||||
<ha-md-divider
|
<ha-md-divider
|
||||||
slot="menu-items"
|
slot="menu-items"
|
||||||
role="separator"
|
role="separator"
|
||||||
@@ -250,6 +272,7 @@ export default class HaAutomationSidebarTrigger extends LitElement {
|
|||||||
@value-changed=${this._valueChangedSidebar}
|
@value-changed=${this._valueChangedSidebar}
|
||||||
@yaml-changed=${this._yamlChangedSidebar}
|
@yaml-changed=${this._yamlChangedSidebar}
|
||||||
.uiSupported=${this.config.uiSupported}
|
.uiSupported=${this.config.uiSupported}
|
||||||
|
.showId=${this._requestShowId}
|
||||||
.yamlMode=${this.yamlMode}
|
.yamlMode=${this.yamlMode}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
@ui-mode-not-available=${this._handleUiModeNotAvailable}
|
@ui-mode-not-available=${this._handleUiModeNotAvailable}
|
||||||
@@ -292,6 +315,10 @@ export default class HaAutomationSidebarTrigger extends LitElement {
|
|||||||
fireEvent(this, "toggle-yaml-mode");
|
fireEvent(this, "toggle-yaml-mode");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private _showTriggerId = () => {
|
||||||
|
this._requestShowId = true;
|
||||||
|
};
|
||||||
|
|
||||||
static styles = [sidebarEditorStyles, overflowStyles];
|
static styles = [sidebarEditorStyles, overflowStyles];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ export default class HaAutomationTriggerEditor extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean, attribute: "sidebar" }) public inSidebar = false;
|
@property({ type: Boolean, attribute: "sidebar" }) public inSidebar = false;
|
||||||
|
|
||||||
|
@property({ type: Boolean, attribute: "show-id" }) public showId = false;
|
||||||
|
|
||||||
@query("ha-yaml-editor") public yamlEditor?: HaYamlEditor;
|
@query("ha-yaml-editor") public yamlEditor?: HaYamlEditor;
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
@@ -36,6 +38,8 @@ export default class HaAutomationTriggerEditor extends LitElement {
|
|||||||
|
|
||||||
const yamlMode = this.yamlMode || !this.uiSupported;
|
const yamlMode = this.yamlMode || !this.uiSupported;
|
||||||
|
|
||||||
|
const showId = "id" in this.trigger || this.showId;
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div
|
<div
|
||||||
class=${classMap({
|
class=${classMap({
|
||||||
@@ -70,20 +74,15 @@ export default class HaAutomationTriggerEditor extends LitElement {
|
|||||||
></ha-yaml-editor>
|
></ha-yaml-editor>
|
||||||
`
|
`
|
||||||
: html`
|
: html`
|
||||||
${!isTriggerList(this.trigger)
|
${showId && !isTriggerList(this.trigger)
|
||||||
? html`
|
? html`
|
||||||
<ha-textfield
|
<ha-textfield
|
||||||
.label=${`${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.triggers.id"
|
"ui.panel.config.automation.editor.triggers.id"
|
||||||
)} (${this.hass.localize(
|
)}
|
||||||
"ui.panel.config.automation.editor.triggers.optional"
|
|
||||||
)})`}
|
|
||||||
.value=${this.trigger.id || ""}
|
.value=${this.trigger.id || ""}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
@change=${this._idChanged}
|
@change=${this._idChanged}
|
||||||
.helper=${this.hass.localize(
|
|
||||||
"ui.panel.config.automation.editor.triggers.id_helper"
|
|
||||||
)}
|
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
`
|
`
|
||||||
: nothing}
|
: nothing}
|
||||||
|
|||||||
@@ -245,18 +245,20 @@ export class HaStateTrigger extends LitElement implements TriggerElement {
|
|||||||
newTrigger.to,
|
newTrigger.to,
|
||||||
newTrigger.attribute
|
newTrigger.attribute
|
||||||
);
|
);
|
||||||
|
if (Array.isArray(newTrigger.to) && newTrigger.to.length === 0) {
|
||||||
|
delete newTrigger.to;
|
||||||
|
}
|
||||||
newTrigger.from = this._applyAnyStateExclusive(
|
newTrigger.from = this._applyAnyStateExclusive(
|
||||||
newTrigger.from,
|
newTrigger.from,
|
||||||
newTrigger.attribute
|
newTrigger.attribute
|
||||||
);
|
);
|
||||||
|
if (Array.isArray(newTrigger.from) && newTrigger.from.length === 0) {
|
||||||
|
delete newTrigger.from;
|
||||||
|
}
|
||||||
|
|
||||||
Object.keys(newTrigger).forEach((key) => {
|
Object.keys(newTrigger).forEach((key) => {
|
||||||
const val = newTrigger[key];
|
const val = newTrigger[key];
|
||||||
if (
|
if (val === undefined || val === "") {
|
||||||
val === undefined ||
|
|
||||||
val === "" ||
|
|
||||||
(Array.isArray(val) && val.length === 0)
|
|
||||||
) {
|
|
||||||
delete newTrigger[key];
|
delete newTrigger[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -125,8 +125,6 @@ class HaConfigBackupBackups extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
@query("#overflow-menu") private _overflowMenu?: HaMdMenu;
|
@query("#overflow-menu") private _overflowMenu?: HaMdMenu;
|
||||||
|
|
||||||
private _overflowBackup?: BackupContent;
|
|
||||||
|
|
||||||
public connectedCallback() {
|
public connectedCallback() {
|
||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
window.addEventListener("location-changed", this._locationChanged);
|
window.addEventListener("location-changed", this._locationChanged);
|
||||||
@@ -262,7 +260,7 @@ class HaConfigBackupBackups extends SubscribeMixin(LitElement) {
|
|||||||
type: "overflow-menu",
|
type: "overflow-menu",
|
||||||
template: (backup) => html`
|
template: (backup) => html`
|
||||||
<ha-icon-button
|
<ha-icon-button
|
||||||
.selected=${backup}
|
.backup=${backup}
|
||||||
.label=${this.hass.localize("ui.common.overflow_menu")}
|
.label=${this.hass.localize("ui.common.overflow_menu")}
|
||||||
.path=${mdiDotsVertical}
|
.path=${mdiDotsVertical}
|
||||||
@click=${this._toggleOverflowMenu}
|
@click=${this._toggleOverflowMenu}
|
||||||
@@ -294,7 +292,6 @@ class HaConfigBackupBackups extends SubscribeMixin(LitElement) {
|
|||||||
this._overflowMenu.close();
|
this._overflowMenu.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._overflowBackup = ev.target.selected;
|
|
||||||
this._overflowMenu.anchorElement = ev.target;
|
this._overflowMenu.anchorElement = ev.target;
|
||||||
this._overflowMenu.show();
|
this._overflowMenu.show();
|
||||||
};
|
};
|
||||||
@@ -572,15 +569,17 @@ class HaConfigBackupBackups extends SubscribeMixin(LitElement) {
|
|||||||
navigate(`/config/backup/details/${id}`);
|
navigate(`/config/backup/details/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _downloadBackup(): Promise<void> {
|
private async _downloadBackup(ev): Promise<void> {
|
||||||
if (!this._overflowBackup) {
|
const backup = ev.parentElement.anchorElement.backup;
|
||||||
|
if (!backup) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
downloadBackup(this.hass, this, this._overflowBackup, this.config);
|
downloadBackup(this.hass, this, backup, this.config);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _deleteBackup(): Promise<void> {
|
private async _deleteBackup(ev): Promise<void> {
|
||||||
if (!this._overflowBackup) {
|
const backup = ev.parentElement.anchorElement.backup;
|
||||||
|
if (!backup) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,11 +595,9 @@ class HaConfigBackupBackups extends SubscribeMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await deleteBackup(this.hass, this._overflowBackup.backup_id);
|
await deleteBackup(this.hass, backup.backup_id);
|
||||||
if (this._selected.includes(this._overflowBackup.backup_id)) {
|
if (this._selected.includes(backup.backup_id)) {
|
||||||
this._selected = this._selected.filter(
|
this._selected = this._selected.filter((id) => id !== backup.backup_id);
|
||||||
(id) => id !== this._overflowBackup!.backup_id
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
showAlertDialog(this, {
|
showAlertDialog(this, {
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ export class HaDeviceEntitiesCard extends LitElement {
|
|||||||
addEntitiesToLovelaceView(
|
addEntitiesToLovelaceView(
|
||||||
this,
|
this,
|
||||||
this.hass,
|
this.hass,
|
||||||
computeCards(this.hass.states, entities, {
|
computeCards(this.hass, entities, {
|
||||||
title: this.deviceName,
|
title: this.deviceName,
|
||||||
}),
|
}),
|
||||||
computeSection(entities, {
|
computeSection(entities, {
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ import { fireEvent } from "../../../../common/dom/fire_event";
|
|||||||
import { computeDeviceNameDisplay } from "../../../../common/entity/compute_device_name";
|
import { computeDeviceNameDisplay } from "../../../../common/entity/compute_device_name";
|
||||||
import "../../../../components/ha-alert";
|
import "../../../../components/ha-alert";
|
||||||
import "../../../../components/ha-area-picker";
|
import "../../../../components/ha-area-picker";
|
||||||
import "../../../../components/ha-wa-dialog";
|
import "../../../../components/ha-dialog";
|
||||||
import "../../../../components/ha-dialog-footer";
|
|
||||||
import "../../../../components/ha-button";
|
import "../../../../components/ha-button";
|
||||||
import "../../../../components/ha-labels-picker";
|
import "../../../../components/ha-labels-picker";
|
||||||
import type { HaSwitch } from "../../../../components/ha-switch";
|
import type { HaSwitch } from "../../../../components/ha-switch";
|
||||||
@@ -20,8 +19,6 @@ import type { DeviceRegistryDetailDialogParams } from "./show-dialog-device-regi
|
|||||||
class DialogDeviceRegistryDetail extends LitElement {
|
class DialogDeviceRegistryDetail extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
@state() private _open = false;
|
|
||||||
|
|
||||||
@state() private _nameByUser!: string;
|
@state() private _nameByUser!: string;
|
||||||
|
|
||||||
@state() private _error?: string;
|
@state() private _error?: string;
|
||||||
@@ -45,15 +42,10 @@ class DialogDeviceRegistryDetail extends LitElement {
|
|||||||
this._areaId = this._params.device.area_id || "";
|
this._areaId = this._params.device.area_id || "";
|
||||||
this._labels = this._params.device.labels || [];
|
this._labels = this._params.device.labels || [];
|
||||||
this._disabledBy = this._params.device.disabled_by;
|
this._disabledBy = this._params.device.disabled_by;
|
||||||
this._open = true;
|
|
||||||
await this.updateComplete;
|
await this.updateComplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
public closeDialog(): void {
|
public closeDialog(): void {
|
||||||
this._open = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private _dialogClosed(): void {
|
|
||||||
this._error = "";
|
this._error = "";
|
||||||
this._params = undefined;
|
this._params = undefined;
|
||||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||||
@@ -65,12 +57,10 @@ class DialogDeviceRegistryDetail extends LitElement {
|
|||||||
}
|
}
|
||||||
const device = this._params.device;
|
const device = this._params.device;
|
||||||
return html`
|
return html`
|
||||||
<ha-wa-dialog
|
<ha-dialog
|
||||||
.hass=${this.hass}
|
open
|
||||||
.open=${this._open}
|
@closed=${this.closeDialog}
|
||||||
header-title=${computeDeviceNameDisplay(device, this.hass)}
|
.heading=${computeDeviceNameDisplay(device, this.hass)}
|
||||||
prevent-scrim-close
|
|
||||||
@closed=${this._dialogClosed}
|
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
${this._error
|
${this._error
|
||||||
@@ -78,7 +68,6 @@ class DialogDeviceRegistryDetail extends LitElement {
|
|||||||
: ""}
|
: ""}
|
||||||
<div class="form">
|
<div class="form">
|
||||||
<ha-textfield
|
<ha-textfield
|
||||||
autofocus
|
|
||||||
.value=${this._nameByUser}
|
.value=${this._nameByUser}
|
||||||
@input=${this._nameChanged}
|
@input=${this._nameChanged}
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
@@ -86,6 +75,7 @@ class DialogDeviceRegistryDetail extends LitElement {
|
|||||||
)}
|
)}
|
||||||
.placeholder=${device.name || ""}
|
.placeholder=${device.name || ""}
|
||||||
.disabled=${this._submitting}
|
.disabled=${this._submitting}
|
||||||
|
dialogInitialFocus
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
<ha-area-picker
|
<ha-area-picker
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -141,25 +131,22 @@ class DialogDeviceRegistryDetail extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<ha-button
|
||||||
<ha-dialog-footer slot="footer">
|
slot="secondaryAction"
|
||||||
<ha-button
|
@click=${this.closeDialog}
|
||||||
slot="secondaryAction"
|
.disabled=${this._submitting}
|
||||||
@click=${this.closeDialog}
|
appearance="plain"
|
||||||
.disabled=${this._submitting}
|
>
|
||||||
appearance="plain"
|
${this.hass.localize("ui.common.cancel")}
|
||||||
>
|
</ha-button>
|
||||||
${this.hass.localize("ui.common.cancel")}
|
<ha-button
|
||||||
</ha-button>
|
slot="primaryAction"
|
||||||
<ha-button
|
@click=${this._updateEntry}
|
||||||
slot="primaryAction"
|
.disabled=${this._submitting}
|
||||||
@click=${this._updateEntry}
|
>
|
||||||
.disabled=${this._submitting}
|
${this.hass.localize("ui.dialogs.device-registry-detail.update")}
|
||||||
>
|
</ha-button>
|
||||||
${this.hass.localize("ui.dialogs.device-registry-detail.update")}
|
</ha-dialog>
|
||||||
</ha-button>
|
|
||||||
</ha-dialog-footer>
|
|
||||||
</ha-wa-dialog>
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -790,7 +790,10 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
|||||||
);
|
);
|
||||||
const timeString = new Date().toISOString().replace(/:/g, "-");
|
const timeString = new Date().toISOString().replace(/:/g, "-");
|
||||||
const logFileName = `home-assistant_${integration}_${timeString}.log`;
|
const logFileName = `home-assistant_${integration}_${timeString}.log`;
|
||||||
const signedUrl = await getSignedPath(this.hass, getErrorLogDownloadUrl);
|
const signedUrl = await getSignedPath(
|
||||||
|
this.hass,
|
||||||
|
getErrorLogDownloadUrl(this.hass)
|
||||||
|
);
|
||||||
fileDownload(signedUrl.path, logFileName);
|
fileDownload(signedUrl.path, logFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class DialogLabelDetail
|
|||||||
this.hass,
|
this.hass,
|
||||||
this._params.entry
|
this._params.entry
|
||||||
? this._params.entry.name || this._params.entry.label_id
|
? this._params.entry.name || this._params.entry.label_id
|
||||||
: this.hass!.localize("ui.panel.config.labels.detail.new_label")
|
: this.hass!.localize("ui.dialogs.label-detail.new_label")
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
@@ -95,11 +95,9 @@ class DialogLabelDetail
|
|||||||
.value=${this._name}
|
.value=${this._name}
|
||||||
.configValue=${"name"}
|
.configValue=${"name"}
|
||||||
@input=${this._input}
|
@input=${this._input}
|
||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize("ui.dialogs.label-detail.name")}
|
||||||
"ui.panel.config.labels.detail.name"
|
|
||||||
)}
|
|
||||||
.validationMessage=${this.hass!.localize(
|
.validationMessage=${this.hass!.localize(
|
||||||
"ui.panel.config.labels.detail.required_error_msg"
|
"ui.dialogs.label-detail.required_error_msg"
|
||||||
)}
|
)}
|
||||||
required
|
required
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
@@ -108,25 +106,21 @@ class DialogLabelDetail
|
|||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.configValue=${"icon"}
|
.configValue=${"icon"}
|
||||||
@value-changed=${this._valueChanged}
|
@value-changed=${this._valueChanged}
|
||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize("ui.dialogs.label-detail.icon")}
|
||||||
"ui.panel.config.labels.detail.icon"
|
|
||||||
)}
|
|
||||||
></ha-icon-picker>
|
></ha-icon-picker>
|
||||||
<ha-color-picker
|
<ha-color-picker
|
||||||
.value=${this._color}
|
.value=${this._color}
|
||||||
.configValue=${"color"}
|
.configValue=${"color"}
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@value-changed=${this._valueChanged}
|
@value-changed=${this._valueChanged}
|
||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize("ui.dialogs.label-detail.color")}
|
||||||
"ui.panel.config.labels.detail.color"
|
|
||||||
)}
|
|
||||||
></ha-color-picker>
|
></ha-color-picker>
|
||||||
<ha-textarea
|
<ha-textarea
|
||||||
.value=${this._description}
|
.value=${this._description}
|
||||||
.configValue=${"description"}
|
.configValue=${"description"}
|
||||||
@input=${this._input}
|
@input=${this._input}
|
||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize(
|
||||||
"ui.panel.config.labels.detail.description"
|
"ui.dialogs.label-detail.description"
|
||||||
)}
|
)}
|
||||||
></ha-textarea>
|
></ha-textarea>
|
||||||
</div>
|
</div>
|
||||||
@@ -140,7 +134,7 @@ class DialogLabelDetail
|
|||||||
@click=${this._deleteEntry}
|
@click=${this._deleteEntry}
|
||||||
.disabled=${this._submitting}
|
.disabled=${this._submitting}
|
||||||
>
|
>
|
||||||
${this.hass!.localize("ui.panel.config.labels.detail.delete")}
|
${this.hass!.localize("ui.common.delete")}
|
||||||
</ha-button>
|
</ha-button>
|
||||||
`
|
`
|
||||||
: nothing}
|
: nothing}
|
||||||
@@ -150,8 +144,8 @@ class DialogLabelDetail
|
|||||||
.disabled=${this._submitting || !this._name}
|
.disabled=${this._submitting || !this._name}
|
||||||
>
|
>
|
||||||
${this._params.entry
|
${this._params.entry
|
||||||
? this.hass!.localize("ui.panel.config.labels.detail.update")
|
? this.hass!.localize("ui.common.update")
|
||||||
: this.hass!.localize("ui.panel.config.labels.detail.create")}
|
: this.hass!.localize("ui.common.create")}
|
||||||
</ha-button>
|
</ha-button>
|
||||||
</ha-dialog>
|
</ha-dialog>
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ class ErrorLogCard extends LitElement {
|
|||||||
const downloadUrl =
|
const downloadUrl =
|
||||||
this.provider && this.provider !== "core"
|
this.provider && this.provider !== "core"
|
||||||
? getHassioLogDownloadUrl(this.provider)
|
? getHassioLogDownloadUrl(this.provider)
|
||||||
: getErrorLogDownloadUrl;
|
: getErrorLogDownloadUrl(this.hass);
|
||||||
const logFileName =
|
const logFileName =
|
||||||
this.provider && this.provider !== "core"
|
this.provider && this.provider !== "core"
|
||||||
? `${this.provider}_${timeString}.log`
|
? `${this.provider}_${timeString}.log`
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ import { mdiDotsVertical, mdiDownload, mdiRefresh, mdiText } from "@mdi/js";
|
|||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
|
||||||
import { atLeastVersion } from "../../../common/config/version";
|
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
import type { LocalizeFunc } from "../../../common/translations/localize";
|
import type { LocalizeFunc } from "../../../common/translations/localize";
|
||||||
import "../../../components/buttons/ha-call-service-button";
|
import "../../../components/buttons/ha-call-service-button";
|
||||||
@@ -15,7 +13,6 @@ import "../../../components/ha-list-item";
|
|||||||
import "../../../components/ha-spinner";
|
import "../../../components/ha-spinner";
|
||||||
import { getSignedPath } from "../../../data/auth";
|
import { getSignedPath } from "../../../data/auth";
|
||||||
import { getErrorLogDownloadUrl } from "../../../data/error_log";
|
import { getErrorLogDownloadUrl } from "../../../data/error_log";
|
||||||
import { coreLatestLogsUrl } from "../../../data/hassio/supervisor";
|
|
||||||
import { domainToName } from "../../../data/integration";
|
import { domainToName } from "../../../data/integration";
|
||||||
import type { LoggedError } from "../../../data/system_log";
|
import type { LoggedError } from "../../../data/system_log";
|
||||||
import {
|
import {
|
||||||
@@ -231,11 +228,7 @@ export class SystemLogCard extends LitElement {
|
|||||||
|
|
||||||
private async _downloadLogs() {
|
private async _downloadLogs() {
|
||||||
const timeString = new Date().toISOString().replace(/:/g, "-");
|
const timeString = new Date().toISOString().replace(/:/g, "-");
|
||||||
const downloadUrl =
|
const downloadUrl = getErrorLogDownloadUrl(this.hass);
|
||||||
isComponentLoaded(this.hass, "hassio") &&
|
|
||||||
atLeastVersion(this.hass.config.version, 2025, 10)
|
|
||||||
? coreLatestLogsUrl
|
|
||||||
: getErrorLogDownloadUrl;
|
|
||||||
const logFileName = `home-assistant_${timeString}.log`;
|
const logFileName = `home-assistant_${timeString}.log`;
|
||||||
const signedUrl = await getSignedPath(this.hass, downloadUrl);
|
const signedUrl = await getSignedPath(this.hass, downloadUrl);
|
||||||
fileDownload(signedUrl.path, logFileName);
|
fileDownload(signedUrl.path, logFileName);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
generateEntityFilter,
|
generateEntityFilter,
|
||||||
type EntityFilter,
|
type EntityFilter,
|
||||||
} from "../../../common/entity/entity_filter";
|
} from "../../../common/entity/entity_filter";
|
||||||
|
import { floorDefaultIcon } from "../../../components/ha-floor-icon";
|
||||||
import type { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
import type { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||||
import type { LovelaceSectionRawConfig } from "../../../data/lovelace/config/section";
|
import type { LovelaceSectionRawConfig } from "../../../data/lovelace/config/section";
|
||||||
import type { LovelaceViewConfig } from "../../../data/lovelace/config/view";
|
import type { LovelaceViewConfig } from "../../../data/lovelace/config/view";
|
||||||
@@ -98,6 +99,7 @@ export class LightViewStrategy extends ReactiveElement {
|
|||||||
floorCount > 1
|
floorCount > 1
|
||||||
? floor.name
|
? floor.name
|
||||||
: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
||||||
|
icon: floor.icon || floorDefaultIcon(floor),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class HuiHistoryChartCardFeature
|
|||||||
}
|
}
|
||||||
if (!this._coordinates) {
|
if (!this._coordinates) {
|
||||||
return html`
|
return html`
|
||||||
<div class="container">
|
<div class="container loading">
|
||||||
<ha-spinner size="small"></ha-spinner>
|
<ha-spinner size="small"></ha-spinner>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
@@ -153,6 +153,14 @@ class HuiHistoryChartCardFeature
|
|||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
pointer-events: none !important;
|
pointer-events: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.container.loading {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
hui-graph-base {
|
hui-graph-base {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
--accent-color: var(--feature-color);
|
--accent-color: var(--feature-color);
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ import { measureTextWidth } from "../../../../util/text";
|
|||||||
import "../../../../components/ha-icon-button";
|
import "../../../../components/ha-icon-button";
|
||||||
import { storage } from "../../../../common/decorators/storage";
|
import { storage } from "../../../../common/decorators/storage";
|
||||||
import { listenMediaQuery } from "../../../../common/dom/media_query";
|
import { listenMediaQuery } from "../../../../common/dom/media_query";
|
||||||
|
import { getEnergyColor } from "./common/color";
|
||||||
|
import type { CustomLegendOption } from "../../../../components/chart/ha-chart-base";
|
||||||
|
|
||||||
@customElement("hui-energy-devices-graph-card")
|
@customElement("hui-energy-devices-graph-card")
|
||||||
export class HuiEnergyDevicesGraphCard
|
export class HuiEnergyDevicesGraphCard
|
||||||
@@ -49,6 +51,8 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
|
|
||||||
@state() private _data?: EnergyData;
|
@state() private _data?: EnergyData;
|
||||||
|
|
||||||
|
@state() private _legendData: NonNullable<CustomLegendOption["data"]> = [];
|
||||||
|
|
||||||
@state()
|
@state()
|
||||||
@storage({
|
@storage({
|
||||||
key: "energy-devices-graph-chart-type",
|
key: "energy-devices-graph-chart-type",
|
||||||
@@ -57,6 +61,14 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
})
|
})
|
||||||
private _chartType: "bar" | "pie" = "bar";
|
private _chartType: "bar" | "pie" = "bar";
|
||||||
|
|
||||||
|
@state()
|
||||||
|
@storage({
|
||||||
|
key: "energy-devices-pie-hidden-stats",
|
||||||
|
state: true,
|
||||||
|
subscribe: false,
|
||||||
|
})
|
||||||
|
private _hiddenStats: string[] = [];
|
||||||
|
|
||||||
@state() private _isMobile = false;
|
@state() private _isMobile = false;
|
||||||
|
|
||||||
private _compoundStats: string[] = [];
|
private _compoundStats: string[] = [];
|
||||||
@@ -121,10 +133,16 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
<ha-chart-base
|
<ha-chart-base
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.data=${this._chartData}
|
.data=${this._chartData}
|
||||||
.options=${this._createOptions(this._chartData, this._chartType)}
|
.options=${this._createOptions(
|
||||||
.height=${`${Math.max(300, (this._chartData[0]?.data?.length || 0) * 28 + 50)}px`}
|
this._chartData,
|
||||||
@chart-click=${this._handleChartClick}
|
this._chartType,
|
||||||
|
this._legendData
|
||||||
|
)}
|
||||||
|
.height=${`${Math.max(300, (this._legendData?.length || 0) * 28 + 50)}px`}
|
||||||
.extraComponents=${[PieChart]}
|
.extraComponents=${[PieChart]}
|
||||||
|
@chart-click=${this._handleChartClick}
|
||||||
|
@dataset-hidden=${this._datasetHidden}
|
||||||
|
@dataset-unhidden=${this._datasetUnhidden}
|
||||||
></ha-chart-base>
|
></ha-chart-base>
|
||||||
</div>
|
</div>
|
||||||
</ha-card>
|
</ha-card>
|
||||||
@@ -145,7 +163,8 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
private _createOptions = memoizeOne(
|
private _createOptions = memoizeOne(
|
||||||
(
|
(
|
||||||
data: (BarSeriesOption | PieSeriesOption)[],
|
data: (BarSeriesOption | PieSeriesOption)[],
|
||||||
chartType: "bar" | "pie"
|
chartType: "bar" | "pie",
|
||||||
|
legendData: typeof this._legendData
|
||||||
): ECOption => {
|
): ECOption => {
|
||||||
const options: ECOption = {
|
const options: ECOption = {
|
||||||
grid: {
|
grid: {
|
||||||
@@ -161,6 +180,7 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
},
|
},
|
||||||
xAxis: { show: false },
|
xAxis: { show: false },
|
||||||
yAxis: { show: false },
|
yAxis: { show: false },
|
||||||
|
legend: { type: "custom", show: false },
|
||||||
};
|
};
|
||||||
if (chartType === "bar") {
|
if (chartType === "bar") {
|
||||||
options.xAxis = {
|
options.xAxis = {
|
||||||
@@ -191,6 +211,18 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
options.legend = {
|
||||||
|
type: "custom",
|
||||||
|
show: true,
|
||||||
|
data: legendData,
|
||||||
|
selected: legendData
|
||||||
|
.filter((d) => d.id && this._hiddenStats.includes(d.id))
|
||||||
|
.reduce((acc, d) => {
|
||||||
|
acc[d.id!] = false;
|
||||||
|
return acc;
|
||||||
|
}, {}),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
@@ -354,23 +386,12 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
chartData.sort((a: any, b: any) => b.value[0] - a.value[0]);
|
|
||||||
if (compareData) {
|
|
||||||
datasets[1].data = chartData.map((d) =>
|
|
||||||
chartDataCompare.find((d2) => (d2 as any).id === d.id)
|
|
||||||
) as typeof chartDataCompare;
|
|
||||||
}
|
|
||||||
|
|
||||||
datasets.forEach((dataset) => {
|
|
||||||
dataset.data!.length = Math.min(
|
|
||||||
this._config?.max_devices || Infinity,
|
|
||||||
dataset.data!.length
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (this._chartType === "pie") {
|
if (this._chartType === "pie") {
|
||||||
const { summedData } = getSummedData(energyData);
|
const { summedData, compareSummedData } = getSummedData(energyData);
|
||||||
const { consumption } = computeConsumptionData(summedData);
|
const { consumption, compareConsumption } = computeConsumptionData(
|
||||||
|
summedData,
|
||||||
|
compareSummedData
|
||||||
|
);
|
||||||
const totalUsed = consumption.total.used_total;
|
const totalUsed = consumption.total.used_total;
|
||||||
const showUntracked =
|
const showUntracked =
|
||||||
"from_grid" in summedData ||
|
"from_grid" in summedData ||
|
||||||
@@ -380,6 +401,47 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
? totalUsed -
|
? totalUsed -
|
||||||
chartData.reduce((acc: number, d: any) => acc + d.value[0], 0)
|
chartData.reduce((acc: number, d: any) => acc + d.value[0], 0)
|
||||||
: 0;
|
: 0;
|
||||||
|
if (untracked > 0) {
|
||||||
|
const color = getEnergyColor(
|
||||||
|
computedStyle,
|
||||||
|
this.hass.themes.darkMode,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
"--history-unknown-color"
|
||||||
|
);
|
||||||
|
chartData.push({
|
||||||
|
id: "untracked",
|
||||||
|
value: [untracked, "untracked"] as any,
|
||||||
|
name: this.hass.localize(
|
||||||
|
"ui.panel.lovelace.cards.energy.energy_devices_graph.untracked_consumption"
|
||||||
|
),
|
||||||
|
itemStyle: {
|
||||||
|
color: color + "7F",
|
||||||
|
borderColor: color,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (compareData) {
|
||||||
|
const compareUntracked =
|
||||||
|
compareConsumption!.total.used_total -
|
||||||
|
chartDataCompare.reduce(
|
||||||
|
(acc: number, d: any) => acc + d.value[0],
|
||||||
|
0
|
||||||
|
);
|
||||||
|
if (compareUntracked > 0) {
|
||||||
|
chartDataCompare.push({
|
||||||
|
id: "untracked",
|
||||||
|
value: [compareUntracked, "untracked"] as any,
|
||||||
|
name: this.hass.localize(
|
||||||
|
"ui.panel.lovelace.cards.energy.energy_devices_graph.untracked_consumption"
|
||||||
|
),
|
||||||
|
itemStyle: {
|
||||||
|
color: color + "32",
|
||||||
|
borderColor: color + "7F",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
datasets.push({
|
datasets.push({
|
||||||
type: "pie",
|
type: "pie",
|
||||||
radius: ["0%", compareData ? "30%" : "40%"],
|
radius: ["0%", compareData ? "30%" : "40%"],
|
||||||
@@ -401,17 +463,36 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
color: "rgba(0, 0, 0, 0)",
|
color: "rgba(0, 0, 0, 0)",
|
||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
formatter: () =>
|
show: false,
|
||||||
untracked > 0
|
|
||||||
? this.hass.localize(
|
|
||||||
"ui.panel.lovelace.cards.energy.energy_devices_graph.includes_untracked",
|
|
||||||
{ num: formatNumber(untracked, this.hass.locale) }
|
|
||||||
)
|
|
||||||
: "",
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chartData.sort((a: any, b: any) => b.value[0] - a.value[0]);
|
||||||
|
if (
|
||||||
|
this._config?.max_devices &&
|
||||||
|
chartData.length > this._config.max_devices
|
||||||
|
) {
|
||||||
|
chartData.splice(this._config.max_devices);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._legendData = chartData.map((d) => ({
|
||||||
|
...d,
|
||||||
|
name: this._getDeviceName(d.name),
|
||||||
|
}));
|
||||||
|
// filter out hidden stats in place
|
||||||
|
for (let i = chartData.length - 1; i >= 0; i--) {
|
||||||
|
if (this._hiddenStats.includes((chartData[i] as any).id)) {
|
||||||
|
chartData.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (compareData) {
|
||||||
|
datasets[1].data = chartData.map((d) =>
|
||||||
|
chartDataCompare.find((d2) => (d2 as any).id === d.id)
|
||||||
|
) as typeof chartDataCompare;
|
||||||
|
}
|
||||||
|
|
||||||
this._chartData = datasets;
|
this._chartData = datasets;
|
||||||
await this.updateComplete;
|
await this.updateComplete;
|
||||||
}
|
}
|
||||||
@@ -440,6 +521,18 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
this._getStatistics(this._data!);
|
this._getStatistics(this._data!);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _datasetHidden(ev: CustomEvent<{ id: string }>) {
|
||||||
|
this._hiddenStats = [...this._hiddenStats, ev.detail.id];
|
||||||
|
this._getStatistics(this._data!);
|
||||||
|
}
|
||||||
|
|
||||||
|
private _datasetUnhidden(ev: CustomEvent<{ id: string }>) {
|
||||||
|
this._hiddenStats = this._hiddenStats.filter(
|
||||||
|
(stat) => stat !== ev.detail.id
|
||||||
|
);
|
||||||
|
this._getStatistics(this._data!);
|
||||||
|
}
|
||||||
|
|
||||||
static styles = css`
|
static styles = css`
|
||||||
.card-header {
|
.card-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
|
|||||||
class=${classMap({
|
class=${classMap({
|
||||||
"is-grid": this.layout === "grid",
|
"is-grid": this.layout === "grid",
|
||||||
"is-panel": this.layout === "panel",
|
"is-panel": this.layout === "panel",
|
||||||
|
"has-title": !!this._config.title,
|
||||||
})}
|
})}
|
||||||
.narrow=${this._narrow}
|
.narrow=${this._narrow}
|
||||||
.events=${this._events}
|
.events=${this._events}
|
||||||
@@ -229,6 +230,7 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
|
|||||||
padding: 0 8px 8px;
|
padding: 0 8px 8px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
@@ -239,15 +241,25 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
|
|||||||
padding-left: 8px;
|
padding-left: 8px;
|
||||||
padding-inline-start: 8px;
|
padding-inline-start: 8px;
|
||||||
direction: var(--direction);
|
direction: var(--direction);
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
ha-full-calendar {
|
ha-full-calendar {
|
||||||
--calendar-height: 400px;
|
--calendar-height: 400px;
|
||||||
|
height: var(--calendar-height);
|
||||||
}
|
}
|
||||||
|
|
||||||
ha-full-calendar.is-grid,
|
ha-full-calendar.is-grid,
|
||||||
ha-full-calendar.is-panel {
|
ha-full-calendar.is-panel {
|
||||||
height: calc(100% - 16px);
|
--calendar-height: calc(100% - 16px);
|
||||||
|
}
|
||||||
|
|
||||||
|
ha-full-calendar.is-grid.has-title,
|
||||||
|
ha-full-calendar.is-panel.has-title {
|
||||||
|
--calendar-height: calc(
|
||||||
|
100% - var(--ha-card-header-font-size, var(--ha-font-size-2xl)) - 22px
|
||||||
|
);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { PropertyValues, TemplateResult } from "lit";
|
import type { PropertyValues, TemplateResult } from "lit";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, state } from "lit/decorators";
|
||||||
import { DOMAINS_TOGGLE } from "../../../common/const";
|
import { DOMAINS_TOGGLE } from "../../../common/const";
|
||||||
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
|
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
|
||||||
import { computeDomain } from "../../../common/entity/compute_domain";
|
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||||
@@ -20,11 +20,9 @@ import type {
|
|||||||
import type {
|
import type {
|
||||||
LovelaceCard,
|
LovelaceCard,
|
||||||
LovelaceCardEditor,
|
LovelaceCardEditor,
|
||||||
LovelaceGridOptions,
|
|
||||||
LovelaceHeaderFooter,
|
LovelaceHeaderFooter,
|
||||||
} from "../types";
|
} from "../types";
|
||||||
import type { EntitiesCardConfig } from "./types";
|
import type { EntitiesCardConfig } from "./types";
|
||||||
import { haStyleScrollbar } from "../../../resources/styles";
|
|
||||||
|
|
||||||
export const computeShowHeaderToggle = <
|
export const computeShowHeaderToggle = <
|
||||||
T extends EntityConfig | LovelaceRowConfig,
|
T extends EntityConfig | LovelaceRowConfig,
|
||||||
@@ -77,8 +75,6 @@ class HuiEntitiesCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
private _hass?: HomeAssistant;
|
private _hass?: HomeAssistant;
|
||||||
|
|
||||||
@property({ attribute: false }) public layout?: string;
|
|
||||||
|
|
||||||
private _configEntities?: LovelaceRowConfig[];
|
private _configEntities?: LovelaceRowConfig[];
|
||||||
|
|
||||||
private _showHeaderToggle?: boolean;
|
private _showHeaderToggle?: boolean;
|
||||||
@@ -143,14 +139,6 @@ class HuiEntitiesCard extends LitElement implements LovelaceCard {
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getGridOptions(): LovelaceGridOptions {
|
|
||||||
return {
|
|
||||||
columns: 12,
|
|
||||||
min_columns: 6,
|
|
||||||
min_rows: this._config?.title || this._showHeaderToggle ? 3 : 2,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public setConfig(config: EntitiesCardConfig): void {
|
public setConfig(config: EntitiesCardConfig): void {
|
||||||
if (!config.entities || !Array.isArray(config.entities)) {
|
if (!config.entities || !Array.isArray(config.entities)) {
|
||||||
throw new Error("Entities must be specified");
|
throw new Error("Entities must be specified");
|
||||||
@@ -245,7 +233,7 @@ class HuiEntitiesCard extends LitElement implements LovelaceCard {
|
|||||||
`}
|
`}
|
||||||
</h1>
|
</h1>
|
||||||
`}
|
`}
|
||||||
<div id="states" class="card-content ha-scrollbar">
|
<div id="states" class="card-content">
|
||||||
${this._configEntities!.map((entityConf) =>
|
${this._configEntities!.map((entityConf) =>
|
||||||
this._renderEntity(entityConf)
|
this._renderEntity(entityConf)
|
||||||
)}
|
)}
|
||||||
@@ -258,73 +246,69 @@ class HuiEntitiesCard extends LitElement implements LovelaceCard {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
static styles = [
|
static styles = css`
|
||||||
haStyleScrollbar,
|
ha-card {
|
||||||
css`
|
height: 100%;
|
||||||
ha-card {
|
display: flex;
|
||||||
height: 100%;
|
flex-direction: column;
|
||||||
display: flex;
|
justify-content: space-between;
|
||||||
flex-direction: column;
|
}
|
||||||
justify-content: space-between;
|
.card-header {
|
||||||
}
|
display: flex;
|
||||||
.card-header {
|
justify-content: space-between;
|
||||||
display: flex;
|
}
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-header .name {
|
.card-header .name {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
#states {
|
#states {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: var(--entities-card-row-gap, var(--card-row-gap, 8px));
|
gap: var(--entities-card-row-gap, var(--card-row-gap, 8px));
|
||||||
overflow-y: auto;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#states > div > * {
|
#states > div > * {
|
||||||
overflow: clip visible;
|
overflow: clip visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
#states > div {
|
#states > div {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon {
|
.icon {
|
||||||
padding: 0px 18px 0px 8px;
|
padding: 0px 18px 0px 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
border-top-left-radius: var(
|
border-top-left-radius: var(
|
||||||
--ha-card-border-radius,
|
--ha-card-border-radius,
|
||||||
var(--ha-border-radius-lg)
|
var(--ha-border-radius-lg)
|
||||||
);
|
);
|
||||||
border-top-right-radius: var(
|
border-top-right-radius: var(
|
||||||
--ha-card-border-radius,
|
--ha-card-border-radius,
|
||||||
var(--ha-border-radius-lg)
|
var(--ha-border-radius-lg)
|
||||||
);
|
);
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.footer {
|
.footer {
|
||||||
border-bottom-left-radius: var(
|
border-bottom-left-radius: var(
|
||||||
--ha-card-border-radius,
|
--ha-card-border-radius,
|
||||||
var(--ha-border-radius-lg)
|
var(--ha-border-radius-lg)
|
||||||
);
|
);
|
||||||
border-bottom-right-radius: var(
|
border-bottom-right-radius: var(
|
||||||
--ha-card-border-radius,
|
--ha-card-border-radius,
|
||||||
var(--ha-border-radius-lg)
|
var(--ha-border-radius-lg)
|
||||||
);
|
);
|
||||||
margin-top: -16px;
|
margin-top: -16px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
`,
|
`;
|
||||||
];
|
|
||||||
|
|
||||||
private _renderEntity(entityConf: LovelaceRowConfig): TemplateResult {
|
private _renderEntity(entityConf: LovelaceRowConfig): TemplateResult {
|
||||||
const element = createRowElement(
|
const element = createRowElement(
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { classMap } from "lit/directives/class-map";
|
|||||||
import { ifDefined } from "lit/directives/if-defined";
|
import { ifDefined } from "lit/directives/if-defined";
|
||||||
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
|
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
|
||||||
import { computeDomain } from "../../../common/entity/compute_domain";
|
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
|
||||||
import "../../../components/entity/state-badge";
|
import "../../../components/entity/state-badge";
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import "../../../components/ha-icon";
|
import "../../../components/ha-icon";
|
||||||
@@ -19,6 +18,7 @@ import type {
|
|||||||
import { SENSOR_DEVICE_CLASS_TIMESTAMP } from "../../../data/sensor";
|
import { SENSOR_DEVICE_CLASS_TIMESTAMP } from "../../../data/sensor";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import { actionHandler } from "../common/directives/action-handler-directive";
|
import { actionHandler } from "../common/directives/action-handler-directive";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
import { findEntities } from "../common/find-entities";
|
import { findEntities } from "../common/find-entities";
|
||||||
import { handleAction } from "../common/handle-action";
|
import { handleAction } from "../common/handle-action";
|
||||||
import { hasAction, hasAnyAction } from "../common/has-action";
|
import { hasAction, hasAnyAction } from "../common/has-action";
|
||||||
@@ -252,7 +252,11 @@ export class HuiGlanceCard extends LitElement implements LovelaceCard {
|
|||||||
</div>`;
|
</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const name = entityConf.name ?? computeStateName(stateObj);
|
const name = computeLovelaceEntityName(
|
||||||
|
this.hass!,
|
||||||
|
stateObj,
|
||||||
|
entityConf.name
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -3,25 +3,27 @@ import { LitElement, css, html, nothing } from "lit";
|
|||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||||
|
import { createSearchParam } from "../../../common/url/search-params";
|
||||||
import "../../../components/chart/state-history-charts";
|
import "../../../components/chart/state-history-charts";
|
||||||
import "../../../components/ha-alert";
|
import "../../../components/ha-alert";
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import "../../../components/ha-icon-next";
|
import "../../../components/ha-icon-next";
|
||||||
import {
|
import {
|
||||||
computeHistory,
|
computeHistory,
|
||||||
subscribeHistoryStatesTimeWindow,
|
|
||||||
type HistoryResult,
|
|
||||||
convertStatisticsToHistory,
|
convertStatisticsToHistory,
|
||||||
mergeHistoryResults,
|
mergeHistoryResults,
|
||||||
|
subscribeHistoryStatesTimeWindow,
|
||||||
|
type HistoryResult,
|
||||||
} from "../../../data/history";
|
} from "../../../data/history";
|
||||||
|
import { fetchStatistics } from "../../../data/recorder";
|
||||||
import { getSensorNumericDeviceClasses } from "../../../data/sensor";
|
import { getSensorNumericDeviceClasses } from "../../../data/sensor";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
import { hasConfigOrEntitiesChanged } from "../common/has-changed";
|
import { hasConfigOrEntitiesChanged } from "../common/has-changed";
|
||||||
import { processConfigEntities } from "../common/process-config-entities";
|
import { processConfigEntities } from "../common/process-config-entities";
|
||||||
|
import type { EntityConfig } from "../entity-rows/types";
|
||||||
import type { LovelaceCard, LovelaceGridOptions } from "../types";
|
import type { LovelaceCard, LovelaceGridOptions } from "../types";
|
||||||
import type { HistoryGraphCardConfig } from "./types";
|
import type { HistoryGraphCardConfig } from "./types";
|
||||||
import { createSearchParam } from "../../../common/url/search-params";
|
|
||||||
import { fetchStatistics } from "../../../data/recorder";
|
|
||||||
|
|
||||||
export const DEFAULT_HOURS_TO_SHOW = 24;
|
export const DEFAULT_HOURS_TO_SHOW = 24;
|
||||||
|
|
||||||
@@ -51,6 +53,8 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
private _entityIds: string[] = [];
|
private _entityIds: string[] = [];
|
||||||
|
|
||||||
|
private _entities: EntityConfig[] = [];
|
||||||
|
|
||||||
private _hoursToShow = DEFAULT_HOURS_TO_SHOW;
|
private _hoursToShow = DEFAULT_HOURS_TO_SHOW;
|
||||||
|
|
||||||
private _interval?: number;
|
private _interval?: number;
|
||||||
@@ -80,21 +84,35 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard {
|
|||||||
throw new Error("You must include at least one entity");
|
throw new Error("You must include at least one entity");
|
||||||
}
|
}
|
||||||
|
|
||||||
const configEntities = config.entities
|
this._entities = config.entities
|
||||||
? processConfigEntities(config.entities)
|
? processConfigEntities(config.entities)
|
||||||
: [];
|
: [];
|
||||||
|
this._entityIds = this._entities.map((entity) => entity.entity);
|
||||||
this._entityIds = [];
|
|
||||||
configEntities.forEach((entity) => {
|
|
||||||
this._entityIds.push(entity.entity);
|
|
||||||
if (entity.name) {
|
|
||||||
this._names[entity.entity] = entity.name;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this._hoursToShow = config.hours_to_show || DEFAULT_HOURS_TO_SHOW;
|
this._hoursToShow = config.hours_to_show || DEFAULT_HOURS_TO_SHOW;
|
||||||
|
|
||||||
this._config = config;
|
this._config = config;
|
||||||
|
this._computeNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _computeNames() {
|
||||||
|
if (!this.hass || !this._config) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._names = {};
|
||||||
|
this._entities.forEach((entity) => {
|
||||||
|
const stateObj = this.hass!.states[entity.entity];
|
||||||
|
this._names[entity.entity] = stateObj
|
||||||
|
? computeLovelaceEntityName(this.hass!, stateObj, entity.name)
|
||||||
|
: entity.entity;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public willUpdate(changedProps: PropertyValues) {
|
||||||
|
super.willUpdate(changedProps);
|
||||||
|
if (changedProps.has("hass")) {
|
||||||
|
this._computeNames();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public connectedCallback() {
|
public connectedCallback() {
|
||||||
|
|||||||
@@ -35,20 +35,12 @@ import {
|
|||||||
hasConfigOrEntitiesChanged,
|
hasConfigOrEntitiesChanged,
|
||||||
} from "../common/has-changed";
|
} from "../common/has-changed";
|
||||||
import { processConfigEntities } from "../common/process-config-entities";
|
import { processConfigEntities } from "../common/process-config-entities";
|
||||||
import type { EntityConfig } from "../entity-rows/types";
|
|
||||||
import type { LovelaceCard, LovelaceGridOptions } from "../types";
|
import type { LovelaceCard, LovelaceGridOptions } from "../types";
|
||||||
import type { MapCardConfig } from "./types";
|
import type { MapCardConfig, MapEntityConfig } from "./types";
|
||||||
|
|
||||||
export const DEFAULT_HOURS_TO_SHOW = 0;
|
export const DEFAULT_HOURS_TO_SHOW = 0;
|
||||||
export const DEFAULT_ZOOM = 14;
|
export const DEFAULT_ZOOM = 14;
|
||||||
|
|
||||||
interface MapEntityConfig extends EntityConfig {
|
|
||||||
label_mode?: "state" | "attribute" | "name";
|
|
||||||
attribute?: string;
|
|
||||||
unit?: string;
|
|
||||||
focus?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface GeoEntity {
|
interface GeoEntity {
|
||||||
entity_id: string;
|
entity_id: string;
|
||||||
label_mode?: "state" | "attribute" | "name" | "icon";
|
label_mode?: "state" | "attribute" | "name" | "icon";
|
||||||
|
|||||||
@@ -20,14 +20,15 @@ import {
|
|||||||
} from "../../../data/recorder";
|
} from "../../../data/recorder";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import { computeCardSize } from "../common/compute-card-size";
|
import { computeCardSize } from "../common/compute-card-size";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
import { findEntities } from "../common/find-entities";
|
import { findEntities } from "../common/find-entities";
|
||||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||||
import { createHeaderFooterElement } from "../create-element/create-header-footer-element";
|
import { createHeaderFooterElement } from "../create-element/create-header-footer-element";
|
||||||
import type {
|
import type {
|
||||||
LovelaceCard,
|
LovelaceCard,
|
||||||
LovelaceCardEditor,
|
LovelaceCardEditor,
|
||||||
LovelaceHeaderFooter,
|
|
||||||
LovelaceGridOptions,
|
LovelaceGridOptions,
|
||||||
|
LovelaceHeaderFooter,
|
||||||
} from "../types";
|
} from "../types";
|
||||||
import type { HuiErrorCard } from "./hui-error-card";
|
import type { HuiErrorCard } from "./hui-error-card";
|
||||||
import type { EntityCardConfig, StatisticCardConfig } from "./types";
|
import type { EntityCardConfig, StatisticCardConfig } from "./types";
|
||||||
@@ -180,7 +181,9 @@ export class HuiStatisticCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
const stateObj = this.hass.states[this._config.entity];
|
const stateObj = this.hass.states[this._config.entity];
|
||||||
const name =
|
const name =
|
||||||
this._config.name ||
|
(this._config.name
|
||||||
|
? computeLovelaceEntityName(this.hass, stateObj, this._config.name)
|
||||||
|
: "") ||
|
||||||
getStatisticLabel(this.hass, this._config.entity, this._metadata);
|
getStatisticLabel(this.hass, this._config.entity, this._metadata);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
|
import { differenceInDays, subHours } from "date-fns";
|
||||||
import type { HassEntity, UnsubscribeFunc } from "home-assistant-js-websocket";
|
import type { HassEntity, UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||||
import { subHours, differenceInDays } from "date-fns";
|
|
||||||
import type { PropertyValues } from "lit";
|
import type { PropertyValues } from "lit";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import { getEnergyDataCollection } from "../../../data/energy";
|
import { getEnergyDataCollection } from "../../../data/energy";
|
||||||
import {
|
|
||||||
getSuggestedMax,
|
|
||||||
getSuggestedPeriod,
|
|
||||||
} from "./energy/common/energy-chart-options";
|
|
||||||
import type {
|
import type {
|
||||||
Statistics,
|
Statistics,
|
||||||
StatisticsMetaData,
|
StatisticsMetaData,
|
||||||
@@ -21,10 +17,16 @@ import {
|
|||||||
getStatisticMetadata,
|
getStatisticMetadata,
|
||||||
} from "../../../data/recorder";
|
} from "../../../data/recorder";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
import { findEntities } from "../common/find-entities";
|
import { findEntities } from "../common/find-entities";
|
||||||
import { hasConfigOrEntitiesChanged } from "../common/has-changed";
|
import { hasConfigOrEntitiesChanged } from "../common/has-changed";
|
||||||
import { processConfigEntities } from "../common/process-config-entities";
|
import { processConfigEntities } from "../common/process-config-entities";
|
||||||
|
import type { EntityConfig } from "../entity-rows/types";
|
||||||
import type { LovelaceCard, LovelaceGridOptions } from "../types";
|
import type { LovelaceCard, LovelaceGridOptions } from "../types";
|
||||||
|
import {
|
||||||
|
getSuggestedMax,
|
||||||
|
getSuggestedPeriod,
|
||||||
|
} from "./energy/common/energy-chart-options";
|
||||||
import type { StatisticsGraphCardConfig } from "./types";
|
import type { StatisticsGraphCardConfig } from "./types";
|
||||||
|
|
||||||
export const DEFAULT_DAYS_TO_SHOW = 30;
|
export const DEFAULT_DAYS_TO_SHOW = 30;
|
||||||
@@ -67,7 +69,9 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
@state() private _unit?: string;
|
@state() private _unit?: string;
|
||||||
|
|
||||||
private _entities: string[] = [];
|
private _entities: EntityConfig[] = [];
|
||||||
|
|
||||||
|
private _entityIds: string[] = [];
|
||||||
|
|
||||||
private _names: Record<string, string> = {};
|
private _names: Record<string, string> = {};
|
||||||
|
|
||||||
@@ -148,17 +152,10 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
|
|||||||
throw new Error("You must include at least one entity");
|
throw new Error("You must include at least one entity");
|
||||||
}
|
}
|
||||||
|
|
||||||
const configEntities = config.entities
|
this._entities = config.entities
|
||||||
? processConfigEntities(config.entities, false)
|
? processConfigEntities(config.entities, false)
|
||||||
: [];
|
: [];
|
||||||
|
this._entityIds = this._entities.map((ent) => ent.entity);
|
||||||
this._entities = [];
|
|
||||||
configEntities.forEach((entity) => {
|
|
||||||
this._entities.push(entity.entity);
|
|
||||||
if (entity.name) {
|
|
||||||
this._names[entity.entity] = entity.name;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (typeof config.stat_types === "string") {
|
if (typeof config.stat_types === "string") {
|
||||||
this._statTypes = [config.stat_types];
|
this._statTypes = [config.stat_types];
|
||||||
@@ -168,6 +165,20 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
|
|||||||
this._statTypes = config.stat_types;
|
this._statTypes = config.stat_types;
|
||||||
}
|
}
|
||||||
this._config = config;
|
this._config = config;
|
||||||
|
this._computeNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _computeNames() {
|
||||||
|
if (!this.hass || !this._config) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._names = {};
|
||||||
|
this._entities.forEach((config) => {
|
||||||
|
const stateObj = this.hass!.states[config.entity];
|
||||||
|
this._names[config.entity] = stateObj
|
||||||
|
? computeLovelaceEntityName(this.hass!, stateObj, config.name)
|
||||||
|
: config.entity;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected shouldUpdate(changedProps: PropertyValues): boolean {
|
protected shouldUpdate(changedProps: PropertyValues): boolean {
|
||||||
@@ -209,6 +220,10 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (changedProps.has("hass")) {
|
||||||
|
this._computeNames();
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
changedProps.has("_config") &&
|
changedProps.has("_config") &&
|
||||||
oldConfig?.entities !== this._config.entities
|
oldConfig?.entities !== this._config.entities
|
||||||
@@ -232,7 +247,7 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
|
|||||||
clearInterval(this._interval);
|
clearInterval(this._interval);
|
||||||
this._interval = 0; // block concurrent calls
|
this._interval = 0; // block concurrent calls
|
||||||
if (fetchMetadata) {
|
if (fetchMetadata) {
|
||||||
await this._getStatisticsMetaData(this._entities);
|
await this._getStatisticsMetaData(this._entityIds);
|
||||||
}
|
}
|
||||||
await this._getStatistics();
|
await this._getStatistics();
|
||||||
// statistics are created every hour
|
// statistics are created every hour
|
||||||
@@ -344,7 +359,7 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!unitClass && this._metadata) {
|
if (!unitClass && this._metadata) {
|
||||||
const metadata = this._metadata[this._entities[0]];
|
const metadata = this._metadata[this._entityIds[0]];
|
||||||
unitClass = metadata?.unit_class;
|
unitClass = metadata?.unit_class;
|
||||||
this._unit = unitClass
|
this._unit = unitClass
|
||||||
? getDisplayUnit(this.hass!, metadata.statistic_id, metadata) ||
|
? getDisplayUnit(this.hass!, metadata.statistic_id, metadata) ||
|
||||||
@@ -356,14 +371,15 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
|
|||||||
this.hass!,
|
this.hass!,
|
||||||
startDate,
|
startDate,
|
||||||
endDate,
|
endDate,
|
||||||
this._entities,
|
this._entityIds,
|
||||||
this._period,
|
this._period,
|
||||||
unitconfig,
|
unitconfig,
|
||||||
this._statTypes
|
this._statTypes
|
||||||
);
|
);
|
||||||
|
|
||||||
this._statistics = {};
|
this._statistics = {};
|
||||||
this._entities.forEach((id) => {
|
this._entities.forEach((entity) => {
|
||||||
|
const id = entity.entity;
|
||||||
if (id in statistics) {
|
if (id in statistics) {
|
||||||
this._statistics![id] = statistics[id];
|
this._statistics![id] = statistics[id];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import type { EnergySourceByType } from "../../../data/energy";
|
|||||||
import type { ActionConfig } from "../../../data/lovelace/config/action";
|
import type { ActionConfig } from "../../../data/lovelace/config/action";
|
||||||
import type { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
import type { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||||
import type { Statistic, StatisticType } from "../../../data/recorder";
|
import type { Statistic, StatisticType } from "../../../data/recorder";
|
||||||
|
import type { MediaSelectorValue } from "../../../data/selector";
|
||||||
import type { TimeFormat } from "../../../data/translation";
|
import type { TimeFormat } from "../../../data/translation";
|
||||||
import type { ForecastType } from "../../../data/weather";
|
import type { ForecastType } from "../../../data/weather";
|
||||||
import type {
|
import type {
|
||||||
@@ -29,7 +30,6 @@ import type {
|
|||||||
import type { LovelaceHeaderFooterConfig } from "../header-footer/types";
|
import type { LovelaceHeaderFooterConfig } from "../header-footer/types";
|
||||||
import type { LovelaceHeadingBadgeConfig } from "../heading-badges/types";
|
import type { LovelaceHeadingBadgeConfig } from "../heading-badges/types";
|
||||||
import type { HomeSummary } from "../strategies/home/helpers/home-summaries";
|
import type { HomeSummary } from "../strategies/home/helpers/home-summaries";
|
||||||
import type { MediaSelectorValue } from "../../../data/selector";
|
|
||||||
|
|
||||||
export type AlarmPanelCardConfigState =
|
export type AlarmPanelCardConfigState =
|
||||||
| "arm_away"
|
| "arm_away"
|
||||||
@@ -347,7 +347,15 @@ export interface LogbookCardConfig extends LovelaceCardConfig {
|
|||||||
theme?: string;
|
theme?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GeoLocationSourceConfig {
|
export interface MapEntityConfig extends EntityConfig {
|
||||||
|
label_mode?: "state" | "attribute" | "name";
|
||||||
|
attribute?: string;
|
||||||
|
unit?: string;
|
||||||
|
focus?: boolean;
|
||||||
|
name?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GeoLocationSourceConfig {
|
||||||
source: string;
|
source: string;
|
||||||
label_mode?: "name" | "state" | "attribute" | "icon";
|
label_mode?: "name" | "state" | "attribute" | "icon";
|
||||||
attribute?: string;
|
attribute?: string;
|
||||||
@@ -362,7 +370,7 @@ export interface MapCardConfig extends LovelaceCardConfig {
|
|||||||
auto_fit?: boolean;
|
auto_fit?: boolean;
|
||||||
fit_zones?: boolean;
|
fit_zones?: boolean;
|
||||||
default_zoom?: number;
|
default_zoom?: number;
|
||||||
entities?: (EntityConfig | string)[];
|
entities?: (MapEntityConfig | string)[];
|
||||||
hours_to_show?: number;
|
hours_to_show?: number;
|
||||||
geo_location_sources?: (GeoLocationSourceConfig | string)[];
|
geo_location_sources?: (GeoLocationSourceConfig | string)[];
|
||||||
dark_mode?: boolean;
|
dark_mode?: boolean;
|
||||||
@@ -434,7 +442,7 @@ export interface StatisticsGraphCardConfig extends EnergyCardBaseConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface StatisticCardConfig extends LovelaceCardConfig {
|
export interface StatisticCardConfig extends LovelaceCardConfig {
|
||||||
name?: string;
|
name?: string | EntityNameItem | EntityNameItem[];
|
||||||
entities: (EntityConfig | string)[];
|
entities: (EntityConfig | string)[];
|
||||||
period:
|
period:
|
||||||
| {
|
| {
|
||||||
|
|||||||
@@ -1,28 +1,29 @@
|
|||||||
import type { HassEntity } from "home-assistant-js-websocket";
|
import type { HassEntity } from "home-assistant-js-websocket";
|
||||||
import {
|
|
||||||
DEFAULT_ENTITY_NAME,
|
|
||||||
type EntityNameItem,
|
|
||||||
} from "../../../../common/entity/compute_entity_name_display";
|
|
||||||
import type { HomeAssistant } from "../../../../types";
|
|
||||||
import { ensureArray } from "../../../../common/array/ensure-array";
|
import { ensureArray } from "../../../../common/array/ensure-array";
|
||||||
|
import type { EntityNameItem } from "../../../../common/entity/compute_entity_name_display";
|
||||||
|
import { computeStateName } from "../../../../common/entity/compute_state_name";
|
||||||
|
import type { HomeAssistant } from "../../../../types";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the display name for an entity in Lovelace (cards and badges).
|
* Computes the display name for an entity in Lovelace (cards and badges).
|
||||||
*
|
*
|
||||||
* @param hass - The Home Assistant instance
|
* @param hass - The Home Assistant instance
|
||||||
* @param stateObj - The entity state object
|
* @param stateObj - The entity state object
|
||||||
* @param nameConfig - The name configuration (string for override, or EntityNameItem[] for structured naming)
|
* @param config - The name configuration (string for override, or EntityNameItem[] for structured naming)
|
||||||
* @returns The computed entity name
|
* @returns The computed entity name
|
||||||
*/
|
*/
|
||||||
export const computeLovelaceEntityName = (
|
export const computeLovelaceEntityName = (
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
stateObj: HassEntity | undefined,
|
stateObj: HassEntity | undefined,
|
||||||
nameConfig: string | EntityNameItem | EntityNameItem[] | undefined
|
config: string | EntityNameItem | EntityNameItem[] | undefined
|
||||||
): string => {
|
): string => {
|
||||||
if (typeof nameConfig === "string") {
|
// If no config is provided, fall back to the default state name
|
||||||
return nameConfig;
|
if (!config) {
|
||||||
|
return stateObj ? computeStateName(stateObj) : "";
|
||||||
|
}
|
||||||
|
if (typeof config === "string") {
|
||||||
|
return config;
|
||||||
}
|
}
|
||||||
const config = nameConfig || DEFAULT_ENTITY_NAME;
|
|
||||||
if (stateObj) {
|
if (stateObj) {
|
||||||
return hass.formatEntityName(stateObj, config);
|
return hass.formatEntityName(stateObj, config);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { HassEntities, HassEntity } from "home-assistant-js-websocket";
|
import type { HassEntities, HassEntity } from "home-assistant-js-websocket";
|
||||||
import { SENSOR_ENTITIES, ASSIST_ENTITIES } from "../../../common/const";
|
import { ASSIST_ENTITIES, SENSOR_ENTITIES } from "../../../common/const";
|
||||||
import { computeDomain } from "../../../common/entity/compute_domain";
|
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||||
import { computeStateDomain } from "../../../common/entity/compute_state_domain";
|
import { computeStateDomain } from "../../../common/entity/compute_state_domain";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
import { computeStateName } from "../../../common/entity/compute_state_name";
|
||||||
@@ -14,12 +14,14 @@ import type {
|
|||||||
GridSourceTypeEnergyPreference,
|
GridSourceTypeEnergyPreference,
|
||||||
} from "../../../data/energy";
|
} from "../../../data/energy";
|
||||||
import { domainToName } from "../../../data/integration";
|
import { domainToName } from "../../../data/integration";
|
||||||
|
import type { LovelaceBadgeConfig } from "../../../data/lovelace/config/badge";
|
||||||
import type { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
import type { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||||
import type { LovelaceSectionConfig } from "../../../data/lovelace/config/section";
|
import type { LovelaceSectionConfig } from "../../../data/lovelace/config/section";
|
||||||
import type { LovelaceViewConfig } from "../../../data/lovelace/config/view";
|
import type { LovelaceViewConfig } from "../../../data/lovelace/config/view";
|
||||||
import { computeUserInitials } from "../../../data/user";
|
import { computeUserInitials } from "../../../data/user";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import { HELPER_DOMAINS } from "../../config/helpers/const";
|
import { HELPER_DOMAINS } from "../../config/helpers/const";
|
||||||
|
import type { EntityBadgeConfig } from "../badges/types";
|
||||||
import type {
|
import type {
|
||||||
AlarmPanelCardConfig,
|
AlarmPanelCardConfig,
|
||||||
EntitiesCardConfig,
|
EntitiesCardConfig,
|
||||||
@@ -31,8 +33,7 @@ import type {
|
|||||||
} from "../cards/types";
|
} from "../cards/types";
|
||||||
import type { EntityConfig } from "../entity-rows/types";
|
import type { EntityConfig } from "../entity-rows/types";
|
||||||
import type { ButtonsHeaderFooterConfig } from "../header-footer/types";
|
import type { ButtonsHeaderFooterConfig } from "../header-footer/types";
|
||||||
import type { LovelaceBadgeConfig } from "../../../data/lovelace/config/badge";
|
import { computeLovelaceEntityName } from "./entity/compute-lovelace-entity-name";
|
||||||
import type { EntityBadgeConfig } from "../badges/types";
|
|
||||||
|
|
||||||
const HIDE_DOMAIN = new Set([
|
const HIDE_DOMAIN = new Set([
|
||||||
"ai_task",
|
"ai_task",
|
||||||
@@ -125,13 +126,13 @@ export const computeSection = (
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const computeCards = (
|
export const computeCards = (
|
||||||
states: HassEntities,
|
hass: HomeAssistant,
|
||||||
entityIds: string[],
|
entityIds: string[],
|
||||||
entityCardOptions: Partial<EntitiesCardConfig>,
|
entityCardOptions: Partial<EntitiesCardConfig>,
|
||||||
renderFooterEntities = true
|
renderFooterEntities = true
|
||||||
): LovelaceCardConfig[] => {
|
): LovelaceCardConfig[] => {
|
||||||
const cards: LovelaceCardConfig[] = [];
|
const cards: LovelaceCardConfig[] = [];
|
||||||
|
const states = hass.states;
|
||||||
// For entity card
|
// For entity card
|
||||||
const entitiesConf: (string | EntityConfig)[] = [];
|
const entitiesConf: (string | EntityConfig)[] = [];
|
||||||
|
|
||||||
@@ -270,19 +271,23 @@ export const computeCards = (
|
|||||||
? states[a]
|
? states[a]
|
||||||
? computeStateName(states[a])
|
? computeStateName(states[a])
|
||||||
: ""
|
: ""
|
||||||
: a.name || "",
|
: states[a.entity]
|
||||||
|
? computeLovelaceEntityName(hass, states[a.entity], a.name)
|
||||||
|
: "",
|
||||||
typeof b === "string"
|
typeof b === "string"
|
||||||
? states[b]
|
? states[b]
|
||||||
? computeStateName(states[b])
|
? computeStateName(states[b])
|
||||||
: ""
|
: ""
|
||||||
: b.name || ""
|
: states[b.entity]
|
||||||
|
? computeLovelaceEntityName(hass, states[b.entity], b.name)
|
||||||
|
: ""
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// If we ended up with footer entities but no normal entities,
|
// If we ended up with footer entities but no normal entities,
|
||||||
// render the footer entities as normal entities.
|
// render the footer entities as normal entities.
|
||||||
if (entitiesConf.length === 0 && footerEntities.length > 0) {
|
if (entitiesConf.length === 0 && footerEntities.length > 0) {
|
||||||
return computeCards(states, entityIds, entityCardOptions, false);
|
return computeCards(hass, entityIds, entityCardOptions, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entitiesConf.length > 0 || footerEntities.length > 0) {
|
if (entitiesConf.length > 0 || footerEntities.length > 0) {
|
||||||
@@ -360,14 +365,14 @@ const computeDefaultViewStates = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const generateViewConfig = (
|
export const generateViewConfig = (
|
||||||
localize: LocalizeFunc,
|
hass: HomeAssistant,
|
||||||
path: string,
|
path: string,
|
||||||
title: string | undefined,
|
title: string | undefined,
|
||||||
icon: string | undefined,
|
icon: string | undefined,
|
||||||
entities: HassEntities
|
entities: HassEntities
|
||||||
): LovelaceViewConfig => {
|
): LovelaceViewConfig => {
|
||||||
const ungroupedEntitites: Record<string, string[]> = {};
|
const ungroupedEntitites: Record<string, string[]> = {};
|
||||||
|
const { localize } = hass;
|
||||||
// Organize ungrouped entities in ungrouped things
|
// Organize ungrouped entities in ungrouped things
|
||||||
for (const entityId of Object.keys(entities)) {
|
for (const entityId of Object.keys(entities)) {
|
||||||
const state = entities[entityId];
|
const state = entities[entityId];
|
||||||
@@ -470,7 +475,7 @@ export const generateViewConfig = (
|
|||||||
.forEach((domain) => {
|
.forEach((domain) => {
|
||||||
cards.push(
|
cards.push(
|
||||||
...computeCards(
|
...computeCards(
|
||||||
entities,
|
hass,
|
||||||
ungroupedEntitites[domain].sort((a, b) =>
|
ungroupedEntitites[domain].sort((a, b) =>
|
||||||
stringCompare(
|
stringCompare(
|
||||||
computeStateName(entities[a]),
|
computeStateName(entities[a]),
|
||||||
@@ -498,16 +503,17 @@ export const generateViewConfig = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const generateDefaultViewConfig = (
|
export const generateDefaultViewConfig = (
|
||||||
areaEntries: HomeAssistant["areas"],
|
hass: HomeAssistant,
|
||||||
deviceEntries: HomeAssistant["devices"],
|
|
||||||
entityEntries: HomeAssistant["entities"],
|
|
||||||
entities: HassEntities,
|
|
||||||
localize: LocalizeFunc,
|
localize: LocalizeFunc,
|
||||||
energyPrefs?: EnergyPreferences,
|
energyPrefs?: EnergyPreferences,
|
||||||
areasPrefs?: AreasDisplayValue,
|
areasPrefs?: AreasDisplayValue,
|
||||||
hideEntitiesWithoutAreas?: boolean,
|
hideEntitiesWithoutAreas?: boolean,
|
||||||
hideEnergy?: boolean
|
hideEnergy?: boolean
|
||||||
): LovelaceViewConfig => {
|
): LovelaceViewConfig => {
|
||||||
|
const entities = hass.states;
|
||||||
|
const areaEntries = hass.areas;
|
||||||
|
const deviceEntries = hass.devices;
|
||||||
|
const entityEntries = hass.entities;
|
||||||
const states = computeDefaultViewStates(entities, entityEntries);
|
const states = computeDefaultViewStates(entities, entityEntries);
|
||||||
const path = "default_view";
|
const path = "default_view";
|
||||||
const title = "Home";
|
const title = "Home";
|
||||||
@@ -549,7 +555,7 @@ export const generateDefaultViewConfig = (
|
|||||||
|
|
||||||
for (const groupEntity of splittedByGroups.groups) {
|
for (const groupEntity of splittedByGroups.groups) {
|
||||||
groupCards.push(
|
groupCards.push(
|
||||||
...computeCards(entities, groupEntity.attributes.entity_id, {
|
...computeCards(hass, groupEntity.attributes.entity_id, {
|
||||||
title: computeStateName(groupEntity),
|
title: computeStateName(groupEntity),
|
||||||
show_header_toggle: groupEntity.attributes.control !== "hidden",
|
show_header_toggle: groupEntity.attributes.control !== "hidden",
|
||||||
})
|
})
|
||||||
@@ -557,7 +563,7 @@ export const generateDefaultViewConfig = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
const config = generateViewConfig(
|
const config = generateViewConfig(
|
||||||
localize,
|
hass,
|
||||||
path,
|
path,
|
||||||
title,
|
title,
|
||||||
icon,
|
icon,
|
||||||
@@ -575,7 +581,7 @@ export const generateDefaultViewConfig = (
|
|||||||
const area = areaEntries[areaId];
|
const area = areaEntries[areaId];
|
||||||
areaCards.push(
|
areaCards.push(
|
||||||
...computeCards(
|
...computeCards(
|
||||||
entities,
|
hass,
|
||||||
areaEntities.map((entity) => entity.entity_id),
|
areaEntities.map((entity) => entity.entity_id),
|
||||||
{
|
{
|
||||||
title: area.name,
|
title: area.name,
|
||||||
@@ -601,7 +607,7 @@ export const generateDefaultViewConfig = (
|
|||||||
const device = deviceEntries[deviceId];
|
const device = deviceEntries[deviceId];
|
||||||
deviceCards.push(
|
deviceCards.push(
|
||||||
...computeCards(
|
...computeCards(
|
||||||
entities,
|
hass,
|
||||||
deviceEntities.map((entity) => entity.entity_id),
|
deviceEntities.map((entity) => entity.entity_id),
|
||||||
{
|
{
|
||||||
title:
|
title:
|
||||||
|
|||||||
@@ -2,8 +2,12 @@
|
|||||||
import { isValidEntityId } from "../../../common/entity/valid_entity_id";
|
import { isValidEntityId } from "../../../common/entity/valid_entity_id";
|
||||||
import type { EntityConfig, LovelaceRowConfig } from "../entity-rows/types";
|
import type { EntityConfig, LovelaceRowConfig } from "../entity-rows/types";
|
||||||
|
|
||||||
|
interface BaseEntityConfig {
|
||||||
|
type: string;
|
||||||
|
entity: string;
|
||||||
|
}
|
||||||
export const processConfigEntities = <
|
export const processConfigEntities = <
|
||||||
T extends EntityConfig | LovelaceRowConfig,
|
T extends BaseEntityConfig | LovelaceRowConfig,
|
||||||
>(
|
>(
|
||||||
entities: (T | string)[],
|
entities: (T | string)[],
|
||||||
checkEntityId = true
|
checkEntityId = true
|
||||||
|
|||||||
@@ -45,14 +45,13 @@ export class HuiEntityEditor extends LitElement {
|
|||||||
this.hass.devices
|
this.hass.devices
|
||||||
);
|
);
|
||||||
|
|
||||||
const name = this.hass.formatEntityName(
|
|
||||||
stateObj,
|
|
||||||
useDeviceName ? { type: "device" } : { type: "entity" }
|
|
||||||
);
|
|
||||||
|
|
||||||
const isRTL = computeRTL(this.hass);
|
const isRTL = computeRTL(this.hass);
|
||||||
|
|
||||||
const primary = item.name || name || item.entity;
|
const primary =
|
||||||
|
this.hass.formatEntityName(
|
||||||
|
stateObj,
|
||||||
|
useDeviceName ? { type: "device" } : { type: "entity" }
|
||||||
|
) || item.entity;
|
||||||
|
|
||||||
const secondary = this.hass.formatEntityName(
|
const secondary = this.hass.formatEntityName(
|
||||||
stateObj,
|
stateObj,
|
||||||
|
|||||||
@@ -4,19 +4,19 @@ import { customElement, property } from "lit/decorators";
|
|||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
import { ifDefined } from "lit/directives/if-defined";
|
import { ifDefined } from "lit/directives/if-defined";
|
||||||
import { DOMAINS_INPUT_ROW } from "../../../common/const";
|
import { DOMAINS_INPUT_ROW } from "../../../common/const";
|
||||||
|
import { stopPropagation } from "../../../common/dom/stop_propagation";
|
||||||
import { toggleAttribute } from "../../../common/dom/toggle_attribute";
|
import { toggleAttribute } from "../../../common/dom/toggle_attribute";
|
||||||
import { computeDomain } from "../../../common/entity/compute_domain";
|
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
|
||||||
import "../../../components/entity/state-badge";
|
import "../../../components/entity/state-badge";
|
||||||
import "../../../components/ha-relative-time";
|
import "../../../components/ha-relative-time";
|
||||||
import type { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
import type { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import type { EntitiesCardEntityConfig } from "../cards/types";
|
import type { EntitiesCardEntityConfig } from "../cards/types";
|
||||||
import { actionHandler } from "../common/directives/action-handler-directive";
|
import { actionHandler } from "../common/directives/action-handler-directive";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
import { handleAction } from "../common/handle-action";
|
import { handleAction } from "../common/handle-action";
|
||||||
import { hasAction, hasAnyAction } from "../common/has-action";
|
import { hasAction, hasAnyAction } from "../common/has-action";
|
||||||
import { createEntityNotFoundWarning } from "./hui-warning";
|
import { createEntityNotFoundWarning } from "./hui-warning";
|
||||||
import { stopPropagation } from "../../../common/dom/stop_propagation";
|
|
||||||
|
|
||||||
@customElement("hui-generic-entity-row")
|
@customElement("hui-generic-entity-row")
|
||||||
export class HuiGenericEntityRow extends LitElement {
|
export class HuiGenericEntityRow extends LitElement {
|
||||||
@@ -59,7 +59,11 @@ export class HuiGenericEntityRow extends LitElement {
|
|||||||
const pointer = hasAnyAction(this.config);
|
const pointer = hasAnyAction(this.config);
|
||||||
|
|
||||||
const hasSecondary = this.secondaryText || this.config.secondary_info;
|
const hasSecondary = this.secondaryText || this.config.secondary_info;
|
||||||
const name = this.config.name ?? computeStateName(stateObj);
|
const name = computeLovelaceEntityName(
|
||||||
|
this.hass,
|
||||||
|
stateObj,
|
||||||
|
this.config.name
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div
|
<div
|
||||||
@@ -87,7 +91,7 @@ export class HuiGenericEntityRow extends LitElement {
|
|||||||
class="info ${classMap({ "text-content": !hasSecondary })}"
|
class="info ${classMap({ "text-content": !hasSecondary })}"
|
||||||
.title=${name}
|
.title=${name}
|
||||||
>
|
>
|
||||||
${this.config.name || computeStateName(stateObj)}
|
${name}
|
||||||
${hasSecondary
|
${hasSecondary
|
||||||
? html`
|
? html`
|
||||||
<div class="secondary">
|
<div class="secondary">
|
||||||
|
|||||||
@@ -296,11 +296,7 @@ export class HuiCreateDialogCard
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _suggestCards(): void {
|
private _suggestCards(): void {
|
||||||
const cardConfig = computeCards(
|
const cardConfig = computeCards(this.hass, this._selectedEntities, {});
|
||||||
this.hass.states,
|
|
||||||
this._selectedEntities,
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
|
|
||||||
let sectionOptions: Partial<LovelaceSectionConfig> = {};
|
let sectionOptions: Partial<LovelaceSectionConfig> = {};
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import type { HomeAssistant } from "../../../../types";
|
|||||||
import { showSaveSuccessToast } from "../../../../util/toast-saved-success";
|
import { showSaveSuccessToast } from "../../../../util/toast-saved-success";
|
||||||
import "../../cards/hui-card";
|
import "../../cards/hui-card";
|
||||||
import "../../sections/hui-section";
|
import "../../sections/hui-section";
|
||||||
|
import { getViewType } from "../../views/get-view-type";
|
||||||
import { addCards, addSection } from "../config-util";
|
import { addCards, addSection } from "../config-util";
|
||||||
import type { LovelaceContainerPath } from "../lovelace-path";
|
import type { LovelaceContainerPath } from "../lovelace-path";
|
||||||
import { parseLovelaceContainerPath } from "../lovelace-path";
|
import { parseLovelaceContainerPath } from "../lovelace-path";
|
||||||
@@ -66,7 +67,9 @@ export class HuiDialogSuggestCard extends LitElement {
|
|||||||
const { viewIndex } = parseLovelaceContainerPath(this._params.path);
|
const { viewIndex } = parseLovelaceContainerPath(this._params.path);
|
||||||
const viewConfig = this._params!.lovelaceConfig.views[viewIndex];
|
const viewConfig = this._params!.lovelaceConfig.views[viewIndex];
|
||||||
|
|
||||||
return !isStrategyView(viewConfig) && viewConfig.type === "sections";
|
return (
|
||||||
|
!isStrategyView(viewConfig) && getViewType(viewConfig) === "sections"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _renderPreview() {
|
private _renderPreview() {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { customElement, property, state } from "lit/decorators";
|
|||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { array, assert, assign, object, optional, string } from "superstruct";
|
import { array, assert, assign, object, optional, string } from "superstruct";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { DEFAULT_ENTITY_NAME } from "../../../../common/entity/compute_entity_name_display";
|
|
||||||
import { supportsFeature } from "../../../../common/entity/supports-feature";
|
import { supportsFeature } from "../../../../common/entity/supports-feature";
|
||||||
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
||||||
import "../../../../components/ha-form/ha-form";
|
import "../../../../components/ha-form/ha-form";
|
||||||
@@ -65,9 +64,7 @@ export class HuiAlarmPanelCardEditor
|
|||||||
{
|
{
|
||||||
name: "name",
|
name: "name",
|
||||||
selector: {
|
selector: {
|
||||||
entity_name: {
|
entity_name: {},
|
||||||
default_name: DEFAULT_ENTITY_NAME,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
context: { entity: "entity" },
|
context: { entity: "entity" },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { customElement, property, state } from "lit/decorators";
|
|||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { assert, assign, boolean, object, optional, string } from "superstruct";
|
import { assert, assign, boolean, object, optional, string } from "superstruct";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { DEFAULT_ENTITY_NAME } from "../../../../common/entity/compute_entity_name_display";
|
|
||||||
import "../../../../components/ha-form/ha-form";
|
import "../../../../components/ha-form/ha-form";
|
||||||
import type {
|
import type {
|
||||||
HaFormSchema,
|
HaFormSchema,
|
||||||
@@ -73,7 +72,7 @@ export class HuiButtonCardEditor
|
|||||||
{
|
{
|
||||||
name: "name",
|
name: "name",
|
||||||
selector: {
|
selector: {
|
||||||
entity_name: { default_name: DEFAULT_ENTITY_NAME },
|
entity_name: {},
|
||||||
},
|
},
|
||||||
context: { entity: "entity" },
|
context: { entity: "entity" },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import {
|
|||||||
string,
|
string,
|
||||||
union,
|
union,
|
||||||
} from "superstruct";
|
} from "superstruct";
|
||||||
import { DEFAULT_ENTITY_NAME } from "../../../../common/entity/compute_entity_name_display";
|
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
||||||
import "../../../../components/ha-form/ha-form";
|
import "../../../../components/ha-form/ha-form";
|
||||||
@@ -86,9 +85,7 @@ export class HuiEntityBadgeEditor
|
|||||||
{
|
{
|
||||||
name: "name",
|
name: "name",
|
||||||
selector: {
|
selector: {
|
||||||
entity_name: {
|
entity_name: {},
|
||||||
default_name: DEFAULT_ENTITY_NAME,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
context: { entity: "entity" },
|
context: { entity: "entity" },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { assert, assign, boolean, object, optional, string } from "superstruct";
|
import { assert, assign, boolean, object, optional, string } from "superstruct";
|
||||||
import { DEFAULT_ENTITY_NAME } from "../../../../common/entity/compute_entity_name_display";
|
|
||||||
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
||||||
import type { HaFormSchema } from "../../../../components/ha-form/types";
|
import type { HaFormSchema } from "../../../../components/ha-form/types";
|
||||||
import { headerFooterConfigStructs } from "../../header-footer/structs";
|
import { headerFooterConfigStructs } from "../../header-footer/structs";
|
||||||
@@ -26,9 +25,7 @@ const SCHEMA = [
|
|||||||
{
|
{
|
||||||
name: "name",
|
name: "name",
|
||||||
selector: {
|
selector: {
|
||||||
entity_name: {
|
entity_name: {},
|
||||||
default_name: DEFAULT_ENTITY_NAME,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
context: { entity: "entity" },
|
context: { entity: "entity" },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import {
|
|||||||
string,
|
string,
|
||||||
} from "superstruct";
|
} from "superstruct";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { DEFAULT_ENTITY_NAME } from "../../../../common/entity/compute_entity_name_display";
|
|
||||||
import "../../../../components/ha-form/ha-form";
|
import "../../../../components/ha-form/ha-form";
|
||||||
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
||||||
import { NON_NUMERIC_ATTRIBUTES } from "../../../../data/entity_attributes";
|
import { NON_NUMERIC_ATTRIBUTES } from "../../../../data/entity_attributes";
|
||||||
@@ -102,9 +101,7 @@ export class HuiGaugeCardEditor
|
|||||||
{
|
{
|
||||||
name: "name",
|
name: "name",
|
||||||
selector: {
|
selector: {
|
||||||
entity_name: {
|
entity_name: {},
|
||||||
default_name: DEFAULT_ENTITY_NAME,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
context: { entity: "entity" },
|
context: { entity: "entity" },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -46,20 +46,18 @@ export class HuiGenericEntityRowEditor
|
|||||||
return [
|
return [
|
||||||
{ name: "entity", required: true, selector: { entity: {} } },
|
{ name: "entity", required: true, selector: { entity: {} } },
|
||||||
{
|
{
|
||||||
type: "grid",
|
name: "name",
|
||||||
name: "",
|
selector: { entity_name: {} },
|
||||||
schema: [
|
context: { entity: "entity" },
|
||||||
{ name: "name", selector: { text: {} } },
|
},
|
||||||
{
|
{
|
||||||
name: "icon",
|
name: "icon",
|
||||||
selector: {
|
selector: {
|
||||||
icon: {},
|
icon: {},
|
||||||
},
|
},
|
||||||
context: {
|
context: {
|
||||||
icon_entity: "entity",
|
icon_entity: "entity",
|
||||||
},
|
},
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "secondary_info",
|
name: "secondary_info",
|
||||||
|
|||||||
@@ -11,20 +11,20 @@ import {
|
|||||||
string,
|
string,
|
||||||
union,
|
union,
|
||||||
} from "superstruct";
|
} from "superstruct";
|
||||||
|
import type { HASSDomEvent } from "../../../../common/dom/fire_event";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import "../../../../components/ha-form/ha-form";
|
import "../../../../components/ha-form/ha-form";
|
||||||
import "../hui-sub-element-editor";
|
|
||||||
import type { EditDetailElementEvent, SubElementEditorConfig } from "../types";
|
|
||||||
import type { HASSDomEvent } from "../../../../common/dom/fire_event";
|
|
||||||
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
||||||
import type { HomeAssistant } from "../../../../types";
|
import type { HomeAssistant } from "../../../../types";
|
||||||
import type { ConfigEntity, GlanceCardConfig } from "../../cards/types";
|
import type { ConfigEntity, GlanceCardConfig } from "../../cards/types";
|
||||||
import "../../components/hui-entity-editor";
|
import "../../components/hui-entity-editor";
|
||||||
|
import type { EntityConfig } from "../../entity-rows/types";
|
||||||
import type { LovelaceCardEditor } from "../../types";
|
import type { LovelaceCardEditor } from "../../types";
|
||||||
|
import "../hui-sub-element-editor";
|
||||||
import { processEditorEntities } from "../process-editor-entities";
|
import { processEditorEntities } from "../process-editor-entities";
|
||||||
import { baseLovelaceCardConfig } from "../structs/base-card-struct";
|
import { baseLovelaceCardConfig } from "../structs/base-card-struct";
|
||||||
import { entitiesConfigStruct } from "../structs/entities-struct";
|
import { entitiesConfigStruct } from "../structs/entities-struct";
|
||||||
import type { EntityConfig } from "../../entity-rows/types";
|
import type { EditDetailElementEvent, SubElementEditorConfig } from "../types";
|
||||||
|
|
||||||
const cardConfigStruct = assign(
|
const cardConfigStruct = assign(
|
||||||
baseLovelaceCardConfig,
|
baseLovelaceCardConfig,
|
||||||
@@ -42,11 +42,17 @@ const cardConfigStruct = assign(
|
|||||||
|
|
||||||
const SUB_SCHEMA = [
|
const SUB_SCHEMA = [
|
||||||
{ name: "entity", selector: { entity: {} }, required: true },
|
{ name: "entity", selector: { entity: {} }, required: true },
|
||||||
|
{
|
||||||
|
name: "name",
|
||||||
|
selector: { entity_name: {} },
|
||||||
|
context: {
|
||||||
|
entity: "entity",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: "grid",
|
type: "grid",
|
||||||
name: "",
|
name: "",
|
||||||
schema: [
|
schema: [
|
||||||
{ name: "name", selector: { text: {} } },
|
|
||||||
{
|
{
|
||||||
name: "icon",
|
name: "icon",
|
||||||
selector: {
|
selector: {
|
||||||
|
|||||||
@@ -45,7 +45,13 @@ const cardConfigStruct = assign(
|
|||||||
|
|
||||||
const SUB_SCHEMA = [
|
const SUB_SCHEMA = [
|
||||||
{ name: "entity", selector: { entity: {} }, required: true },
|
{ name: "entity", selector: { entity: {} }, required: true },
|
||||||
{ name: "name", selector: { text: {} } },
|
{
|
||||||
|
name: "name",
|
||||||
|
selector: { entity_name: {} },
|
||||||
|
context: {
|
||||||
|
entity: "entity",
|
||||||
|
},
|
||||||
|
},
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
@customElement("hui-history-graph-card-editor")
|
@customElement("hui-history-graph-card-editor")
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import {
|
|||||||
} from "superstruct";
|
} from "superstruct";
|
||||||
import type { HASSDomEvent } from "../../../../common/dom/fire_event";
|
import type { HASSDomEvent } from "../../../../common/dom/fire_event";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { DEFAULT_ENTITY_NAME } from "../../../../common/entity/compute_entity_name_display";
|
|
||||||
import "../../../../components/ha-expansion-panel";
|
import "../../../../components/ha-expansion-panel";
|
||||||
import "../../../../components/ha-form/ha-form";
|
import "../../../../components/ha-form/ha-form";
|
||||||
import type {
|
import type {
|
||||||
@@ -61,9 +60,7 @@ const SCHEMA = [
|
|||||||
{
|
{
|
||||||
name: "name",
|
name: "name",
|
||||||
selector: {
|
selector: {
|
||||||
entity_name: {
|
entity_name: {},
|
||||||
default_name: DEFAULT_ENTITY_NAME,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
context: { entity: "entity" },
|
context: { entity: "entity" },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
|
import { mdiGestureTap } from "@mdi/js";
|
||||||
import type { CSSResultGroup } from "lit";
|
import type { CSSResultGroup } from "lit";
|
||||||
import { html, LitElement, nothing } from "lit";
|
import { html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { assert, assign, object, optional, string } from "superstruct";
|
import { assert, assign, object, optional, string } from "superstruct";
|
||||||
import { mdiGestureTap } from "@mdi/js";
|
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { DEFAULT_ENTITY_NAME } from "../../../../common/entity/compute_entity_name_display";
|
|
||||||
import "../../../../components/ha-form/ha-form";
|
import "../../../../components/ha-form/ha-form";
|
||||||
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
||||||
import type { HomeAssistant } from "../../../../types";
|
import type { HomeAssistant } from "../../../../types";
|
||||||
@@ -37,9 +36,7 @@ const SCHEMA = [
|
|||||||
{
|
{
|
||||||
name: "name",
|
name: "name",
|
||||||
selector: {
|
selector: {
|
||||||
entity_name: {
|
entity_name: {},
|
||||||
default_name: DEFAULT_ENTITY_NAME,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
context: { entity: "entity" },
|
context: { entity: "entity" },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { mdiPalette } from "@mdi/js";
|
|||||||
import type { CSSResultGroup } from "lit";
|
import type { CSSResultGroup } from "lit";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
|
import memoizeOne from "memoize-one";
|
||||||
import {
|
import {
|
||||||
array,
|
array,
|
||||||
assert,
|
assert,
|
||||||
@@ -13,19 +14,19 @@ import {
|
|||||||
string,
|
string,
|
||||||
union,
|
union,
|
||||||
} from "superstruct";
|
} from "superstruct";
|
||||||
import memoizeOne from "memoize-one";
|
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { hasLocation } from "../../../../common/entity/has_location";
|
|
||||||
import { computeDomain } from "../../../../common/entity/compute_domain";
|
import { computeDomain } from "../../../../common/entity/compute_domain";
|
||||||
|
import { hasLocation } from "../../../../common/entity/has_location";
|
||||||
|
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
||||||
import "../../../../components/ha-form/ha-form";
|
import "../../../../components/ha-form/ha-form";
|
||||||
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
||||||
import type { SelectSelector } from "../../../../data/selector";
|
|
||||||
import "../../../../components/ha-formfield";
|
import "../../../../components/ha-formfield";
|
||||||
import "../../../../components/ha-switch";
|
|
||||||
import "../../../../components/ha-selector/ha-selector-select";
|
import "../../../../components/ha-selector/ha-selector-select";
|
||||||
|
import "../../../../components/ha-switch";
|
||||||
|
import type { SelectSelector } from "../../../../data/selector";
|
||||||
import type { HomeAssistant, ValueChangedEvent } from "../../../../types";
|
import type { HomeAssistant, ValueChangedEvent } from "../../../../types";
|
||||||
import { DEFAULT_HOURS_TO_SHOW, DEFAULT_ZOOM } from "../../cards/hui-map-card";
|
import { DEFAULT_HOURS_TO_SHOW, DEFAULT_ZOOM } from "../../cards/hui-map-card";
|
||||||
import type { MapCardConfig } from "../../cards/types";
|
import type { MapCardConfig, MapEntityConfig } from "../../cards/types";
|
||||||
import "../../components/hui-entity-editor";
|
import "../../components/hui-entity-editor";
|
||||||
import type { EntityConfig } from "../../entity-rows/types";
|
import type { EntityConfig } from "../../entity-rows/types";
|
||||||
import type { LovelaceCardEditor } from "../../types";
|
import type { LovelaceCardEditor } from "../../types";
|
||||||
@@ -33,7 +34,6 @@ import { processEditorEntities } from "../process-editor-entities";
|
|||||||
import { baseLovelaceCardConfig } from "../structs/base-card-struct";
|
import { baseLovelaceCardConfig } from "../structs/base-card-struct";
|
||||||
import type { EntitiesEditorEvent } from "../types";
|
import type { EntitiesEditorEvent } from "../types";
|
||||||
import { configElementStyle } from "./config-elements-style";
|
import { configElementStyle } from "./config-elements-style";
|
||||||
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
|
||||||
|
|
||||||
export const mapEntitiesConfigStruct = union([
|
export const mapEntitiesConfigStruct = union([
|
||||||
object({
|
object({
|
||||||
@@ -223,7 +223,9 @@ export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
private _entitiesValueChanged(ev: EntitiesEditorEvent): void {
|
private _entitiesValueChanged(
|
||||||
|
ev: EntitiesEditorEvent<MapEntityConfig>
|
||||||
|
): void {
|
||||||
if (ev.detail && ev.detail.entities) {
|
if (ev.detail && ev.detail.entities) {
|
||||||
this._config = { ...this._config!, entities: ev.detail.entities };
|
this._config = { ...this._config!, entities: ev.detail.entities };
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { html, LitElement, nothing } from "lit";
|
|||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { assert, assign, object, optional, string } from "superstruct";
|
import { assert, assign, object, optional, string } from "superstruct";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { DEFAULT_ENTITY_NAME } from "../../../../common/entity/compute_entity_name_display";
|
|
||||||
import "../../../../components/ha-form/ha-form";
|
import "../../../../components/ha-form/ha-form";
|
||||||
import type {
|
import type {
|
||||||
HaFormSchema,
|
HaFormSchema,
|
||||||
@@ -33,9 +32,7 @@ const SCHEMA = [
|
|||||||
{
|
{
|
||||||
name: "name",
|
name: "name",
|
||||||
selector: {
|
selector: {
|
||||||
entity_name: {
|
entity_name: {},
|
||||||
default_name: DEFAULT_ENTITY_NAME,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
context: { entity: "entity" },
|
context: { entity: "entity" },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import memoizeOne from "memoize-one";
|
|
||||||
import { mdiGestureTap } from "@mdi/js";
|
import { mdiGestureTap } from "@mdi/js";
|
||||||
import type { CSSResultGroup } from "lit";
|
import type { CSSResultGroup } from "lit";
|
||||||
import { html, LitElement, nothing } from "lit";
|
import { html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
|
import memoizeOne from "memoize-one";
|
||||||
import {
|
import {
|
||||||
assert,
|
assert,
|
||||||
assign,
|
assign,
|
||||||
@@ -15,7 +15,6 @@ import {
|
|||||||
} from "superstruct";
|
} from "superstruct";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { computeDomain } from "../../../../common/entity/compute_domain";
|
import { computeDomain } from "../../../../common/entity/compute_domain";
|
||||||
import { DEFAULT_ENTITY_NAME } from "../../../../common/entity/compute_entity_name_display";
|
|
||||||
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
||||||
import "../../../../components/ha-form/ha-form";
|
import "../../../../components/ha-form/ha-form";
|
||||||
import type {
|
import type {
|
||||||
@@ -71,9 +70,7 @@ export class HuiPictureEntityCardEditor
|
|||||||
{
|
{
|
||||||
name: "name",
|
name: "name",
|
||||||
selector: {
|
selector: {
|
||||||
entity_name: {
|
entity_name: {},
|
||||||
default_name: DEFAULT_ENTITY_NAME,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
context: { entity: "entity" },
|
context: { entity: "entity" },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { html, LitElement, nothing } from "lit";
|
|||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { assert, assign, object, optional, string } from "superstruct";
|
import { assert, assign, object, optional, string } from "superstruct";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { DEFAULT_ENTITY_NAME } from "../../../../common/entity/compute_entity_name_display";
|
|
||||||
import "../../../../components/ha-form/ha-form";
|
import "../../../../components/ha-form/ha-form";
|
||||||
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
||||||
import type { HomeAssistant } from "../../../../types";
|
import type { HomeAssistant } from "../../../../types";
|
||||||
@@ -25,9 +24,7 @@ const SCHEMA = [
|
|||||||
{
|
{
|
||||||
name: "name",
|
name: "name",
|
||||||
selector: {
|
selector: {
|
||||||
entity_name: {
|
entity_name: {},
|
||||||
default_name: DEFAULT_ENTITY_NAME,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
context: { entity: "entity" },
|
context: { entity: "entity" },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import memoizeOne from "memoize-one";
|
|
||||||
import type { CSSResultGroup } from "lit";
|
import type { CSSResultGroup } from "lit";
|
||||||
import { html, LitElement, nothing } from "lit";
|
import { html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
|
import memoizeOne from "memoize-one";
|
||||||
import {
|
import {
|
||||||
assert,
|
assert,
|
||||||
assign,
|
assign,
|
||||||
@@ -12,18 +12,17 @@ import {
|
|||||||
string,
|
string,
|
||||||
union,
|
union,
|
||||||
} from "superstruct";
|
} from "superstruct";
|
||||||
import { DEFAULT_ENTITY_NAME } from "../../../../common/entity/compute_entity_name_display";
|
|
||||||
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
|
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
||||||
import "../../../../components/ha-form/ha-form";
|
import "../../../../components/ha-form/ha-form";
|
||||||
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
import type { SchemaUnion } from "../../../../components/ha-form/types";
|
||||||
import type { HomeAssistant } from "../../../../types";
|
import type { HomeAssistant } from "../../../../types";
|
||||||
|
import { DEFAULT_HOURS_TO_SHOW } from "../../cards/hui-sensor-card";
|
||||||
import type { SensorCardConfig } from "../../cards/types";
|
import type { SensorCardConfig } from "../../cards/types";
|
||||||
import type { LovelaceCardEditor } from "../../types";
|
import type { LovelaceCardEditor } from "../../types";
|
||||||
import { baseLovelaceCardConfig } from "../structs/base-card-struct";
|
import { baseLovelaceCardConfig } from "../structs/base-card-struct";
|
||||||
import { entityNameStruct } from "../structs/entity-name-struct";
|
import { entityNameStruct } from "../structs/entity-name-struct";
|
||||||
import { configElementStyle } from "./config-elements-style";
|
import { configElementStyle } from "./config-elements-style";
|
||||||
import { DEFAULT_HOURS_TO_SHOW } from "../../cards/hui-sensor-card";
|
|
||||||
|
|
||||||
const cardConfigStruct = assign(
|
const cardConfigStruct = assign(
|
||||||
baseLovelaceCardConfig,
|
baseLovelaceCardConfig,
|
||||||
@@ -71,9 +70,7 @@ export class HuiSensorCardEditor
|
|||||||
{
|
{
|
||||||
name: "name",
|
name: "name",
|
||||||
selector: {
|
selector: {
|
||||||
entity_name: {
|
entity_name: {},
|
||||||
default_name: DEFAULT_ENTITY_NAME,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
context: { entity: "entity" },
|
context: { entity: "entity" },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -21,12 +21,13 @@ import type { StatisticCardConfig } from "../../cards/types";
|
|||||||
import { headerFooterConfigStructs } from "../../header-footer/structs";
|
import { headerFooterConfigStructs } from "../../header-footer/structs";
|
||||||
import type { LovelaceCardEditor } from "../../types";
|
import type { LovelaceCardEditor } from "../../types";
|
||||||
import { baseLovelaceCardConfig } from "../structs/base-card-struct";
|
import { baseLovelaceCardConfig } from "../structs/base-card-struct";
|
||||||
|
import { entityNameStruct } from "../structs/entity-name-struct";
|
||||||
|
|
||||||
const cardConfigStruct = assign(
|
const cardConfigStruct = assign(
|
||||||
baseLovelaceCardConfig,
|
baseLovelaceCardConfig,
|
||||||
object({
|
object({
|
||||||
entity: optional(string()),
|
entity: optional(string()),
|
||||||
name: optional(string()),
|
name: optional(entityNameStruct),
|
||||||
icon: optional(string()),
|
icon: optional(string()),
|
||||||
unit: optional(string()),
|
unit: optional(string()),
|
||||||
stat_type: optional(string()),
|
stat_type: optional(string()),
|
||||||
@@ -144,11 +145,15 @@ export class HuiStatisticCardEditor
|
|||||||
}
|
}
|
||||||
: { object: {} },
|
: { object: {} },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "name",
|
||||||
|
selector: { entity_name: {} },
|
||||||
|
context: { entity: "entity" },
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: "grid",
|
type: "grid",
|
||||||
name: "",
|
name: "",
|
||||||
schema: [
|
schema: [
|
||||||
{ name: "name", selector: { text: {} } },
|
|
||||||
{
|
{
|
||||||
name: "icon",
|
name: "icon",
|
||||||
selector: {
|
selector: {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
} from "superstruct";
|
} from "superstruct";
|
||||||
import type { HASSDomEvent } from "../../../../common/dom/fire_event";
|
import type { HASSDomEvent } from "../../../../common/dom/fire_event";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { DEFAULT_ENTITY_NAME } from "../../../../common/entity/compute_entity_name_display";
|
import { computeDomain } from "../../../../common/entity/compute_domain";
|
||||||
import "../../../../components/ha-expansion-panel";
|
import "../../../../components/ha-expansion-panel";
|
||||||
import "../../../../components/ha-form/ha-form";
|
import "../../../../components/ha-form/ha-form";
|
||||||
import type {
|
import type {
|
||||||
@@ -35,7 +35,6 @@ import type { EditDetailElementEvent, EditSubElementEvent } from "../types";
|
|||||||
import { configElementStyle } from "./config-elements-style";
|
import { configElementStyle } from "./config-elements-style";
|
||||||
import "./hui-card-features-editor";
|
import "./hui-card-features-editor";
|
||||||
import type { FeatureType } from "./hui-card-features-editor";
|
import type { FeatureType } from "./hui-card-features-editor";
|
||||||
import { computeDomain } from "../../../../common/entity/compute_domain";
|
|
||||||
|
|
||||||
const COMPATIBLE_FEATURES_TYPES: Record<string, FeatureType[]> = {
|
const COMPATIBLE_FEATURES_TYPES: Record<string, FeatureType[]> = {
|
||||||
climate: [
|
climate: [
|
||||||
@@ -89,9 +88,7 @@ export class HuiThermostatCardEditor
|
|||||||
{
|
{
|
||||||
name: "name",
|
name: "name",
|
||||||
selector: {
|
selector: {
|
||||||
entity_name: {
|
entity_name: {},
|
||||||
default_name: DEFAULT_ENTITY_NAME,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
context: { entity: "entity" },
|
context: { entity: "entity" },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import {
|
|||||||
} from "superstruct";
|
} from "superstruct";
|
||||||
import type { HASSDomEvent } from "../../../../common/dom/fire_event";
|
import type { HASSDomEvent } from "../../../../common/dom/fire_event";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { DEFAULT_ENTITY_NAME } from "../../../../common/entity/compute_entity_name_display";
|
|
||||||
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
||||||
import { orderProperties } from "../../../../common/util/order-properties";
|
import { orderProperties } from "../../../../common/util/order-properties";
|
||||||
import "../../../../components/ha-expansion-panel";
|
import "../../../../components/ha-expansion-panel";
|
||||||
@@ -102,9 +101,7 @@ export class HuiTileCardEditor
|
|||||||
{
|
{
|
||||||
name: "name",
|
name: "name",
|
||||||
selector: {
|
selector: {
|
||||||
entity_name: {
|
entity_name: {},
|
||||||
default_name: DEFAULT_ENTITY_NAME,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
context: { entity: "entity" },
|
context: { entity: "entity" },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import {
|
|||||||
string,
|
string,
|
||||||
} from "superstruct";
|
} from "superstruct";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { DEFAULT_ENTITY_NAME } from "../../../../common/entity/compute_entity_name_display";
|
|
||||||
import { supportsFeature } from "../../../../common/entity/supports-feature";
|
import { supportsFeature } from "../../../../common/entity/supports-feature";
|
||||||
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
||||||
import "../../../../components/ha-form/ha-form";
|
import "../../../../components/ha-form/ha-form";
|
||||||
@@ -153,9 +152,7 @@ export class HuiWeatherForecastCardEditor
|
|||||||
{
|
{
|
||||||
name: "name",
|
name: "name",
|
||||||
selector: {
|
selector: {
|
||||||
entity_name: {
|
entity_name: {},
|
||||||
default_name: DEFAULT_ENTITY_NAME,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
context: { entity: "entity" },
|
context: { entity: "entity" },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import {
|
|||||||
union,
|
union,
|
||||||
} from "superstruct";
|
} from "superstruct";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { DEFAULT_ENTITY_NAME } from "../../../../common/entity/compute_entity_name_display";
|
|
||||||
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
import type { LocalizeFunc } from "../../../../common/translations/localize";
|
||||||
import "../../../../components/ha-expansion-panel";
|
import "../../../../components/ha-expansion-panel";
|
||||||
import "../../../../components/ha-form/ha-form";
|
import "../../../../components/ha-form/ha-form";
|
||||||
@@ -94,9 +93,7 @@ export class HuiHeadingEntityEditor
|
|||||||
{
|
{
|
||||||
name: "name",
|
name: "name",
|
||||||
selector: {
|
selector: {
|
||||||
entity_name: {
|
entity_name: {},
|
||||||
default_name: DEFAULT_ENTITY_NAME,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
context: { entity: "entity" },
|
context: { entity: "entity" },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,11 +4,12 @@ import {
|
|||||||
actionConfigStruct,
|
actionConfigStruct,
|
||||||
actionConfigStructConfirmation,
|
actionConfigStructConfirmation,
|
||||||
} from "./action-struct";
|
} from "./action-struct";
|
||||||
|
import { entityNameStruct } from "./entity-name-struct";
|
||||||
|
|
||||||
export const entitiesConfigStruct = union([
|
export const entitiesConfigStruct = union([
|
||||||
object({
|
object({
|
||||||
entity: string(),
|
entity: string(),
|
||||||
name: optional(string()),
|
name: optional(entityNameStruct),
|
||||||
icon: optional(string()),
|
icon: optional(string()),
|
||||||
image: optional(string()),
|
image: optional(string()),
|
||||||
secondary_info: optional(string()),
|
secondary_info: optional(string()),
|
||||||
|
|||||||
@@ -43,9 +43,10 @@ export interface ConfigError {
|
|||||||
message: string;
|
message: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EntitiesEditorEvent extends CustomEvent {
|
export interface EntitiesEditorEvent<T extends EntityConfig = EntityConfig>
|
||||||
|
extends CustomEvent {
|
||||||
detail: {
|
detail: {
|
||||||
entities?: EntityConfig[];
|
entities?: T[];
|
||||||
item?: any;
|
item?: any;
|
||||||
};
|
};
|
||||||
target: EventTarget | null;
|
target: EventTarget | null;
|
||||||
|
|||||||
@@ -111,11 +111,7 @@ export class HuiUnusedEntities extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _addToLovelaceView(): void {
|
private _addToLovelaceView(): void {
|
||||||
const cardConfig = computeCards(
|
const cardConfig = computeCards(this.hass, this._selectedEntities, {});
|
||||||
this.hass.states,
|
|
||||||
this._selectedEntities,
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
const sectionConfig = computeSection(this._selectedEntities, {});
|
const sectionConfig = computeSection(this._selectedEntities, {});
|
||||||
|
|
||||||
if (this.lovelace.config.views.length === 1) {
|
if (this.lovelace.config.views.length === 1) {
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
|
import { format } from "date-fns";
|
||||||
import type { PropertyValues, TemplateResult } from "lit";
|
import type { PropertyValues, TemplateResult } from "lit";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import "../../../components/ha-date-input";
|
import "../../../components/ha-date-input";
|
||||||
import { format } from "date-fns";
|
import "../../../components/ha-time-input";
|
||||||
import { isUnavailableState, UNAVAILABLE } from "../../../data/entity";
|
|
||||||
import { setDateTimeValue } from "../../../data/datetime";
|
import { setDateTimeValue } from "../../../data/datetime";
|
||||||
|
import { isUnavailableState, UNAVAILABLE } from "../../../data/entity";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||||
import "../components/hui-generic-entity-row";
|
import "../components/hui-generic-entity-row";
|
||||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||||
import type { EntityConfig, LovelaceRow } from "./types";
|
import type { EntityConfig, LovelaceRow } from "./types";
|
||||||
import "../../../components/ha-time-input";
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
|
||||||
|
|
||||||
@customElement("hui-datetime-entity-row")
|
@customElement("hui-datetime-entity-row")
|
||||||
class HuiInputDatetimeEntityRow extends LitElement implements LovelaceRow {
|
class HuiInputDatetimeEntityRow extends LitElement implements LovelaceRow {
|
||||||
@@ -53,6 +53,12 @@ class HuiInputDatetimeEntityRow extends LitElement implements LovelaceRow {
|
|||||||
const time = dateObj ? format(dateObj, "HH:mm:ss") : undefined;
|
const time = dateObj ? format(dateObj, "HH:mm:ss") : undefined;
|
||||||
const date = dateObj ? format(dateObj, "yyyy-MM-dd") : undefined;
|
const date = dateObj ? format(dateObj, "yyyy-MM-dd") : undefined;
|
||||||
|
|
||||||
|
const name = computeLovelaceEntityName(
|
||||||
|
this.hass!,
|
||||||
|
stateObj,
|
||||||
|
this._config.name
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<hui-generic-entity-row
|
<hui-generic-entity-row
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -61,7 +67,7 @@ class HuiInputDatetimeEntityRow extends LitElement implements LovelaceRow {
|
|||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<ha-date-input
|
<ha-date-input
|
||||||
.label=${this._config.name || computeStateName(stateObj)}
|
.label=${name}
|
||||||
.locale=${this.hass.locale}
|
.locale=${this.hass.locale}
|
||||||
.value=${date}
|
.value=${date}
|
||||||
.disabled=${unavailable}
|
.disabled=${unavailable}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import type { PropertyValues } from "lit";
|
import type { PropertyValues } from "lit";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
|
||||||
import "../../../components/ha-date-input";
|
import "../../../components/ha-date-input";
|
||||||
import "../../../components/ha-time-input";
|
import "../../../components/ha-time-input";
|
||||||
import { isUnavailableState, UNKNOWN } from "../../../data/entity";
|
import { isUnavailableState, UNKNOWN } from "../../../data/entity";
|
||||||
@@ -10,6 +9,7 @@ import {
|
|||||||
stateToIsoDateString,
|
stateToIsoDateString,
|
||||||
} from "../../../data/input_datetime";
|
} from "../../../data/input_datetime";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||||
import "../components/hui-generic-entity-row";
|
import "../components/hui-generic-entity-row";
|
||||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||||
@@ -47,7 +47,11 @@ class HuiInputDatetimeEntityRow extends LitElement implements LovelaceRow {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const name = this._config.name || computeStateName(stateObj);
|
const name = computeLovelaceEntityName(
|
||||||
|
this.hass!,
|
||||||
|
stateObj,
|
||||||
|
this._config.name
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<hui-generic-entity-row
|
<hui-generic-entity-row
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import type { PropertyValues } from "lit";
|
|||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { stopPropagation } from "../../../common/dom/stop_propagation";
|
import { stopPropagation } from "../../../common/dom/stop_propagation";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
|
||||||
import "../../../components/ha-list-item";
|
import "../../../components/ha-list-item";
|
||||||
import "../../../components/ha-select";
|
import "../../../components/ha-select";
|
||||||
import { UNAVAILABLE } from "../../../data/entity";
|
import { UNAVAILABLE } from "../../../data/entity";
|
||||||
@@ -11,6 +10,7 @@ import type { InputSelectEntity } from "../../../data/input_select";
|
|||||||
import { setInputSelectOption } from "../../../data/input_select";
|
import { setInputSelectOption } from "../../../data/input_select";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import type { EntitiesCardEntityConfig } from "../cards/types";
|
import type { EntitiesCardEntityConfig } from "../cards/types";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||||
import "../components/hui-generic-entity-row";
|
import "../components/hui-generic-entity-row";
|
||||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||||
@@ -51,6 +51,12 @@ class HuiInputSelectEntityRow extends LitElement implements LovelaceRow {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const name = computeLovelaceEntityName(
|
||||||
|
this.hass!,
|
||||||
|
stateObj,
|
||||||
|
this._config.name
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<hui-generic-entity-row
|
<hui-generic-entity-row
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -58,7 +64,7 @@ class HuiInputSelectEntityRow extends LitElement implements LovelaceRow {
|
|||||||
hide-name
|
hide-name
|
||||||
>
|
>
|
||||||
<ha-select
|
<ha-select
|
||||||
.label=${this._config.name || computeStateName(stateObj)}
|
.label=${name}
|
||||||
.value=${stateObj.state}
|
.value=${stateObj.state}
|
||||||
.options=${stateObj.attributes.options}
|
.options=${stateObj.attributes.options}
|
||||||
.disabled=${
|
.disabled=${
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import type { PropertyValues } from "lit";
|
import type { PropertyValues } from "lit";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
|
||||||
import "../../../components/ha-textfield";
|
import "../../../components/ha-textfield";
|
||||||
import { isUnavailableState, UNAVAILABLE } from "../../../data/entity";
|
import { isUnavailableState, UNAVAILABLE } from "../../../data/entity";
|
||||||
import { setValue } from "../../../data/input_text";
|
import { setValue } from "../../../data/input_text";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||||
import "../components/hui-generic-entity-row";
|
import "../components/hui-generic-entity-row";
|
||||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||||
@@ -43,6 +43,12 @@ class HuiInputTextEntityRow extends LitElement implements LovelaceRow {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const name = computeLovelaceEntityName(
|
||||||
|
this.hass!,
|
||||||
|
stateObj,
|
||||||
|
this._config.name
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<hui-generic-entity-row
|
<hui-generic-entity-row
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -50,7 +56,7 @@ class HuiInputTextEntityRow extends LitElement implements LovelaceRow {
|
|||||||
hide-name
|
hide-name
|
||||||
>
|
>
|
||||||
<ha-textfield
|
<ha-textfield
|
||||||
.label=${this._config.name || computeStateName(stateObj)}
|
.label=${name}
|
||||||
.disabled=${stateObj.state === UNAVAILABLE}
|
.disabled=${stateObj.state === UNAVAILABLE}
|
||||||
.value=${stateObj.state}
|
.value=${stateObj.state}
|
||||||
.minlength=${stateObj.attributes.min}
|
.minlength=${stateObj.attributes.min}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import type { PropertyValues } from "lit";
|
|||||||
import { LitElement, css, html, nothing } from "lit";
|
import { LitElement, css, html, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { stopPropagation } from "../../../common/dom/stop_propagation";
|
import { stopPropagation } from "../../../common/dom/stop_propagation";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
|
||||||
import "../../../components/ha-list-item";
|
import "../../../components/ha-list-item";
|
||||||
import "../../../components/ha-select";
|
import "../../../components/ha-select";
|
||||||
import { UNAVAILABLE } from "../../../data/entity";
|
import { UNAVAILABLE } from "../../../data/entity";
|
||||||
@@ -11,6 +10,7 @@ import type { SelectEntity } from "../../../data/select";
|
|||||||
import { setSelectOption } from "../../../data/select";
|
import { setSelectOption } from "../../../data/select";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import type { EntitiesCardEntityConfig } from "../cards/types";
|
import type { EntitiesCardEntityConfig } from "../cards/types";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||||
import "../components/hui-generic-entity-row";
|
import "../components/hui-generic-entity-row";
|
||||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||||
@@ -51,6 +51,12 @@ class HuiSelectEntityRow extends LitElement implements LovelaceRow {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const name = computeLovelaceEntityName(
|
||||||
|
this.hass!,
|
||||||
|
stateObj,
|
||||||
|
this._config.name
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<hui-generic-entity-row
|
<hui-generic-entity-row
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -58,7 +64,7 @@ class HuiSelectEntityRow extends LitElement implements LovelaceRow {
|
|||||||
hide-name
|
hide-name
|
||||||
>
|
>
|
||||||
<ha-select
|
<ha-select
|
||||||
.label=${this._config.name || computeStateName(stateObj)}
|
.label=${name}
|
||||||
.value=${stateObj.state}
|
.value=${stateObj.state}
|
||||||
.options=${stateObj.attributes.options}
|
.options=${stateObj.attributes.options}
|
||||||
.disabled=${stateObj.state === UNAVAILABLE}
|
.disabled=${stateObj.state === UNAVAILABLE}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import type { PropertyValues } from "lit";
|
import type { PropertyValues } from "lit";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
|
||||||
import "../../../components/ha-textfield";
|
import "../../../components/ha-textfield";
|
||||||
import { isUnavailableState, UNAVAILABLE } from "../../../data/entity";
|
import { isUnavailableState, UNAVAILABLE } from "../../../data/entity";
|
||||||
import type { TextEntity } from "../../../data/text";
|
import type { TextEntity } from "../../../data/text";
|
||||||
@@ -11,6 +10,7 @@ import { hasConfigOrEntityChanged } from "../common/has-changed";
|
|||||||
import "../components/hui-generic-entity-row";
|
import "../components/hui-generic-entity-row";
|
||||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||||
import type { EntityConfig, LovelaceRow } from "./types";
|
import type { EntityConfig, LovelaceRow } from "./types";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
|
|
||||||
@customElement("hui-text-entity-row")
|
@customElement("hui-text-entity-row")
|
||||||
class HuiTextEntityRow extends LitElement implements LovelaceRow {
|
class HuiTextEntityRow extends LitElement implements LovelaceRow {
|
||||||
@@ -46,6 +46,12 @@ class HuiTextEntityRow extends LitElement implements LovelaceRow {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const name = computeLovelaceEntityName(
|
||||||
|
this.hass!,
|
||||||
|
stateObj,
|
||||||
|
this._config.name
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<hui-generic-entity-row
|
<hui-generic-entity-row
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -53,7 +59,7 @@ class HuiTextEntityRow extends LitElement implements LovelaceRow {
|
|||||||
hide-name
|
hide-name
|
||||||
>
|
>
|
||||||
<ha-textfield
|
<ha-textfield
|
||||||
.label=${this._config.name || computeStateName(stateObj)}
|
.label=${name}
|
||||||
.disabled=${stateObj.state === UNAVAILABLE}
|
.disabled=${stateObj.state === UNAVAILABLE}
|
||||||
.value=${stateObj.state}
|
.value=${stateObj.state}
|
||||||
.minlength=${stateObj.attributes.min}
|
.minlength=${stateObj.attributes.min}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { LitElement, css, html, nothing } from "lit";
|
|||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
import { ifDefined } from "lit/directives/if-defined";
|
import { ifDefined } from "lit/directives/if-defined";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
|
||||||
import { isUnavailableState } from "../../../data/entity";
|
import { isUnavailableState } from "../../../data/entity";
|
||||||
import type { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
import type { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
||||||
import type { ForecastEvent, WeatherEntity } from "../../../data/weather";
|
import type { ForecastEvent, WeatherEntity } from "../../../data/weather";
|
||||||
@@ -24,6 +23,7 @@ import { hasConfigOrEntityChanged } from "../common/has-changed";
|
|||||||
import "../components/hui-generic-entity-row";
|
import "../components/hui-generic-entity-row";
|
||||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||||
import type { LovelaceRow } from "./types";
|
import type { LovelaceRow } from "./types";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
|
|
||||||
@customElement("hui-weather-entity-row")
|
@customElement("hui-weather-entity-row")
|
||||||
class HuiWeatherEntityRow extends LitElement implements LovelaceRow {
|
class HuiWeatherEntityRow extends LitElement implements LovelaceRow {
|
||||||
@@ -119,6 +119,12 @@ class HuiWeatherEntityRow extends LitElement implements LovelaceRow {
|
|||||||
const forecastData = getForecast(stateObj.attributes, this._forecastEvent);
|
const forecastData = getForecast(stateObj.attributes, this._forecastEvent);
|
||||||
const forecast = forecastData?.forecast;
|
const forecast = forecastData?.forecast;
|
||||||
|
|
||||||
|
const name = computeLovelaceEntityName(
|
||||||
|
this.hass!,
|
||||||
|
stateObj,
|
||||||
|
this._config.name
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div
|
<div
|
||||||
class="icon-image ${classMap({
|
class="icon-image ${classMap({
|
||||||
@@ -155,7 +161,7 @@ class HuiWeatherEntityRow extends LitElement implements LovelaceRow {
|
|||||||
hasDoubleClick: hasAction(this._config!.double_tap_action),
|
hasDoubleClick: hasAction(this._config!.double_tap_action),
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
${this._config.name || computeStateName(stateObj)}
|
${name}
|
||||||
${hasSecondary
|
${hasSecondary
|
||||||
? html`
|
? html`
|
||||||
<div class="secondary">
|
<div class="secondary">
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import type { EntityNameItem } from "../../../common/entity/compute_entity_name_display";
|
||||||
import type {
|
import type {
|
||||||
ActionConfig,
|
ActionConfig,
|
||||||
ConfirmationRestrictionConfig,
|
ConfirmationRestrictionConfig,
|
||||||
@@ -10,7 +11,7 @@ import type { TimestampRenderingFormat } from "../components/types";
|
|||||||
export interface EntityConfig {
|
export interface EntityConfig {
|
||||||
entity: string;
|
entity: string;
|
||||||
type?: string;
|
type?: string;
|
||||||
name?: string;
|
name?: string | EntityNameItem | EntityNameItem[];
|
||||||
icon?: string;
|
icon?: string;
|
||||||
image?: string;
|
image?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -218,6 +218,9 @@ export class HuiGraphHeaderFooter
|
|||||||
}
|
}
|
||||||
|
|
||||||
static styles = css`
|
static styles = css`
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
ha-spinner {
|
ha-spinner {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: calc(50% - 14px);
|
top: calc(50% - 14px);
|
||||||
|
|||||||
@@ -321,6 +321,8 @@ class HUIRoot extends LitElement {
|
|||||||
.id="button-${index}"
|
.id="button-${index}"
|
||||||
.path=${item.icon}
|
.path=${item.icon}
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
|
.label=${label}
|
||||||
|
hide-title
|
||||||
></ha-icon-button>
|
></ha-icon-button>
|
||||||
${item.subItems
|
${item.subItems
|
||||||
.filter((subItem) => subItem.visible)
|
.filter((subItem) => subItem.visible)
|
||||||
@@ -340,9 +342,6 @@ class HUIRoot extends LitElement {
|
|||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
</ha-button-menu>
|
</ha-button-menu>
|
||||||
<ha-tooltip placement="bottom" .for="button-${index}">
|
|
||||||
${label}
|
|
||||||
</ha-tooltip>
|
|
||||||
`
|
`
|
||||||
: html`
|
: html`
|
||||||
<ha-icon-button
|
<ha-icon-button
|
||||||
@@ -392,12 +391,11 @@ class HUIRoot extends LitElement {
|
|||||||
slot="trigger"
|
slot="trigger"
|
||||||
id="dashboardmenu"
|
id="dashboardmenu"
|
||||||
.path=${mdiDotsVertical}
|
.path=${mdiDotsVertical}
|
||||||
|
.label=${this.hass!.localize("ui.panel.lovelace.editor.menu.open")}
|
||||||
|
hide-title
|
||||||
></ha-icon-button>
|
></ha-icon-button>
|
||||||
${listItems}
|
${listItems}
|
||||||
</ha-button-menu>
|
</ha-button-menu>
|
||||||
<ha-tooltip placement="bottom" for="dashboardmenu">
|
|
||||||
${this.hass!.localize("ui.panel.lovelace.editor.menu.open")}
|
|
||||||
</ha-tooltip>
|
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
return html`${result}`;
|
return html`${result}`;
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ import { css, html, LitElement, nothing } from "lit";
|
|||||||
import { customElement, state } from "lit/decorators";
|
import { customElement, state } from "lit/decorators";
|
||||||
import { DOMAINS_TOGGLE } from "../../../common/const";
|
import { DOMAINS_TOGGLE } from "../../../common/const";
|
||||||
import { computeDomain } from "../../../common/entity/compute_domain";
|
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
|
||||||
import "../../../components/ha-state-icon";
|
|
||||||
import "../../../components/ha-button";
|
import "../../../components/ha-button";
|
||||||
|
import "../../../components/ha-state-icon";
|
||||||
|
import type { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import { actionHandler } from "../common/directives/action-handler-directive";
|
import { actionHandler } from "../common/directives/action-handler-directive";
|
||||||
|
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||||
import { handleAction } from "../common/handle-action";
|
import { handleAction } from "../common/handle-action";
|
||||||
import { hasAction } from "../common/has-action";
|
import { hasAction } from "../common/has-action";
|
||||||
import type { ButtonRowConfig, LovelaceRow } from "../entity-rows/types";
|
import type { ButtonRowConfig, LovelaceRow } from "../entity-rows/types";
|
||||||
import type { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
|
||||||
|
|
||||||
@customElement("hui-button-row")
|
@customElement("hui-button-row")
|
||||||
export class HuiButtonRow extends LitElement implements LovelaceRow {
|
export class HuiButtonRow extends LitElement implements LovelaceRow {
|
||||||
@@ -49,8 +49,11 @@ export class HuiButtonRow extends LitElement implements LovelaceRow {
|
|||||||
? this.hass.states[this._config.entity]
|
? this.hass.states[this._config.entity]
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const name =
|
const name = computeLovelaceEntityName(
|
||||||
this._config.name ?? (stateObj ? computeStateName(stateObj) : "");
|
this.hass!,
|
||||||
|
stateObj,
|
||||||
|
this._config.name
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-state-icon
|
<ha-state-icon
|
||||||
|
|||||||
@@ -168,9 +168,17 @@ export class HomeAreaViewStrategy extends ReactiveElement {
|
|||||||
|
|
||||||
const summaryEntities = Object.values(entitiesBySummary).flat();
|
const summaryEntities = Object.values(entitiesBySummary).flat();
|
||||||
|
|
||||||
|
// Automations section
|
||||||
|
const automationFilter = generateEntityFilter(hass, {
|
||||||
|
domain: "automation",
|
||||||
|
entity_category: "none",
|
||||||
|
});
|
||||||
|
const automations = areaEntities.filter(automationFilter);
|
||||||
|
|
||||||
// Rest of entities grouped by device
|
// Rest of entities grouped by device
|
||||||
const otherEntities = areaEntities.filter(
|
const otherEntities = areaEntities.filter(
|
||||||
(entityId) => !summaryEntities.includes(entityId)
|
(entityId) =>
|
||||||
|
!summaryEntities.includes(entityId) && !automations.includes(entityId)
|
||||||
);
|
);
|
||||||
|
|
||||||
const entitiesByDevice: Record<string, string[]> = {};
|
const entitiesByDevice: Record<string, string[]> = {};
|
||||||
@@ -295,6 +303,21 @@ export class HomeAreaViewStrategy extends ReactiveElement {
|
|||||||
sections.push(...deviceSections);
|
sections.push(...deviceSections);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show automations last, if they exist
|
||||||
|
if (automations.length > 0) {
|
||||||
|
sections.push({
|
||||||
|
type: "grid",
|
||||||
|
cards: [
|
||||||
|
computeHeadingCard(
|
||||||
|
hass.localize("ui.panel.lovelace.strategy.home.automations"),
|
||||||
|
"mdi:robot",
|
||||||
|
"/config/automation/dashboard"
|
||||||
|
),
|
||||||
|
...automations.map(computeTileCard),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Allow between 2 and 3 columns (the max should be set to define the width of the header)
|
// Allow between 2 and 3 columns (the max should be set to define the width of the header)
|
||||||
const maxColumns = clamp(sections.length, 2, 3);
|
const maxColumns = clamp(sections.length, 2, 3);
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import type {
|
|||||||
import { getAreas, getFloors } from "../areas/helpers/areas-strategy-helper";
|
import { getAreas, getFloors } from "../areas/helpers/areas-strategy-helper";
|
||||||
import type { CommonControlSectionStrategyConfig } from "../usage_prediction/common-controls-section-strategy";
|
import type { CommonControlSectionStrategyConfig } from "../usage_prediction/common-controls-section-strategy";
|
||||||
import { getHomeStructure } from "./helpers/home-structure";
|
import { getHomeStructure } from "./helpers/home-structure";
|
||||||
|
import { floorDefaultIcon } from "../../../../components/ha-floor-icon";
|
||||||
|
|
||||||
export interface HomeMainViewStrategyConfig {
|
export interface HomeMainViewStrategyConfig {
|
||||||
type: "home-main";
|
type: "home-main";
|
||||||
@@ -92,7 +93,7 @@ export class HomeMainViewStrategy extends ReactiveElement {
|
|||||||
? floor.name
|
? floor.name
|
||||||
: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
||||||
heading_style: "title",
|
heading_style: "title",
|
||||||
icon: floor.icon,
|
icon: floor.icon || floorDefaultIcon(floor),
|
||||||
},
|
},
|
||||||
...cards,
|
...cards,
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
findEntities,
|
findEntities,
|
||||||
generateEntityFilter,
|
generateEntityFilter,
|
||||||
} from "../../../../common/entity/entity_filter";
|
} from "../../../../common/entity/entity_filter";
|
||||||
|
import { floorDefaultIcon } from "../../../../components/ha-floor-icon";
|
||||||
import type { LovelaceCardConfig } from "../../../../data/lovelace/config/card";
|
import type { LovelaceCardConfig } from "../../../../data/lovelace/config/card";
|
||||||
import type { LovelaceSectionRawConfig } from "../../../../data/lovelace/config/section";
|
import type { LovelaceSectionRawConfig } from "../../../../data/lovelace/config/section";
|
||||||
import type { LovelaceViewConfig } from "../../../../data/lovelace/config/view";
|
import type { LovelaceViewConfig } from "../../../../data/lovelace/config/view";
|
||||||
@@ -96,6 +97,7 @@ export class HomeMMediaPlayersViewStrategy extends ReactiveElement {
|
|||||||
floorCount > 1
|
floorCount > 1
|
||||||
? floor.name
|
? floor.name
|
||||||
: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
||||||
|
icon: floor.icon || floorDefaultIcon(floor),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -44,10 +44,7 @@ export class OriginalStatesViewStrategy extends ReactiveElement {
|
|||||||
// User can override default view. If they didn't, we will add one
|
// User can override default view. If they didn't, we will add one
|
||||||
// that contains all entities.
|
// that contains all entities.
|
||||||
const view = generateDefaultViewConfig(
|
const view = generateDefaultViewConfig(
|
||||||
hass.areas,
|
hass,
|
||||||
hass.devices,
|
|
||||||
hass.entities,
|
|
||||||
hass.states,
|
|
||||||
localize,
|
localize,
|
||||||
energyPrefs,
|
energyPrefs,
|
||||||
config.areas,
|
config.areas,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
generateEntityFilter,
|
generateEntityFilter,
|
||||||
type EntityFilter,
|
type EntityFilter,
|
||||||
} from "../../../common/entity/entity_filter";
|
} from "../../../common/entity/entity_filter";
|
||||||
|
import { floorDefaultIcon } from "../../../components/ha-floor-icon";
|
||||||
import type { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
import type { LovelaceCardConfig } from "../../../data/lovelace/config/card";
|
||||||
import type { LovelaceSectionRawConfig } from "../../../data/lovelace/config/section";
|
import type { LovelaceSectionRawConfig } from "../../../data/lovelace/config/section";
|
||||||
import type { LovelaceViewConfig } from "../../../data/lovelace/config/view";
|
import type { LovelaceViewConfig } from "../../../data/lovelace/config/view";
|
||||||
@@ -140,6 +141,7 @@ export class SafetyViewStrategy extends ReactiveElement {
|
|||||||
floorCount > 1
|
floorCount > 1
|
||||||
? floor.name
|
? floor.name
|
||||||
: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
||||||
|
icon: floor.icon || floorDefaultIcon(floor),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -255,6 +255,10 @@ class DialogTodoItemEditor extends LitElement {
|
|||||||
|
|
||||||
// Parse a date in the browser timezone
|
// Parse a date in the browser timezone
|
||||||
private _parseDate(dateStr: string): Date {
|
private _parseDate(dateStr: string): Date {
|
||||||
|
// If it's a date-only string (no 'T'), parse as midnight in browser time to avoid offset issues
|
||||||
|
if (!dateStr.includes("T")) {
|
||||||
|
return new Date(dateStr + "T00:00:00");
|
||||||
|
}
|
||||||
const tzDate = new TZDate(dateStr, this._timeZone!);
|
const tzDate = new TZDate(dateStr, this._timeZone!);
|
||||||
return new Date(tzDate.getTime());
|
return new Date(tzDate.getTime());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1706,6 +1706,14 @@
|
|||||||
"update": "[%key:ui::panel::config::devices::update%]",
|
"update": "[%key:ui::panel::config::devices::update%]",
|
||||||
"unknown_error": "[%key:ui::panel::config::devices::unknown_error%]"
|
"unknown_error": "[%key:ui::panel::config::devices::unknown_error%]"
|
||||||
},
|
},
|
||||||
|
"label-detail": {
|
||||||
|
"new_label": "New label",
|
||||||
|
"name": "Name",
|
||||||
|
"icon": "Icon",
|
||||||
|
"color": "Color",
|
||||||
|
"description": "Description",
|
||||||
|
"required_error_msg": "[%key:ui::panel::config::zone::detail::required_error_msg%]"
|
||||||
|
},
|
||||||
"voice-settings": {
|
"voice-settings": {
|
||||||
"expose_header": "Expose",
|
"expose_header": "Expose",
|
||||||
"aliases_header": "Aliases",
|
"aliases_header": "Aliases",
|
||||||
@@ -2406,18 +2414,7 @@
|
|||||||
"introduction": "Labels can help you organize your areas, devices, and entities. They can be used to filter in the UI, or use them as a target in automations.",
|
"introduction": "Labels can help you organize your areas, devices, and entities. They can be used to filter in the UI, or use them as a target in automations.",
|
||||||
"introduction2": "Go to the area, device, or entity you want to add a label to, and press the edit button to assign labels to them.",
|
"introduction2": "Go to the area, device, or entity you want to add a label to, and press the edit button to assign labels to them.",
|
||||||
"confirm_remove_title": "Remove label?",
|
"confirm_remove_title": "Remove label?",
|
||||||
"confirm_remove": "Are you sure you want to remove label {label}? It will be removed from all areas, devices, and entities.",
|
"confirm_remove": "Are you sure you want to remove label {label}? It will be removed from all areas, devices, and entities."
|
||||||
"detail": {
|
|
||||||
"new_label": "New label",
|
|
||||||
"name": "Name",
|
|
||||||
"icon": "Icon",
|
|
||||||
"color": "Color",
|
|
||||||
"description": "Description",
|
|
||||||
"delete": "Delete",
|
|
||||||
"update": "Update",
|
|
||||||
"create": "Create",
|
|
||||||
"required_error_msg": "[%key:ui::panel::config::zone::detail::required_error_msg%]"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"areas": {
|
"areas": {
|
||||||
"caption": "Areas",
|
"caption": "Areas",
|
||||||
@@ -3945,7 +3942,6 @@
|
|||||||
"add": "Add trigger",
|
"add": "Add trigger",
|
||||||
"empty_search": "No triggers found for {term}",
|
"empty_search": "No triggers found for {term}",
|
||||||
"id": "Trigger ID",
|
"id": "Trigger ID",
|
||||||
"id_helper": "Helps identify each run based on which trigger fired.",
|
|
||||||
"optional": "Optional",
|
"optional": "Optional",
|
||||||
"edit_id": "Edit ID",
|
"edit_id": "Edit ID",
|
||||||
"duplicate": "[%key:ui::common::duplicate%]",
|
"duplicate": "[%key:ui::common::duplicate%]",
|
||||||
@@ -6943,7 +6939,8 @@
|
|||||||
"areas": "Areas",
|
"areas": "Areas",
|
||||||
"other_areas": "Other areas",
|
"other_areas": "Other areas",
|
||||||
"unamed_device": "Unnamed device",
|
"unamed_device": "Unnamed device",
|
||||||
"others": "Others"
|
"others": "Others",
|
||||||
|
"automations": "Automations"
|
||||||
},
|
},
|
||||||
"common_controls": {
|
"common_controls": {
|
||||||
"not_loaded": "Usage Prediction integration is not loaded.",
|
"not_loaded": "Usage Prediction integration is not loaded.",
|
||||||
@@ -7075,10 +7072,10 @@
|
|||||||
"energy_devices_graph": {
|
"energy_devices_graph": {
|
||||||
"energy_usage": "Energy usage",
|
"energy_usage": "Energy usage",
|
||||||
"previous_energy_usage": "Previous energy usage",
|
"previous_energy_usage": "Previous energy usage",
|
||||||
"total_energy_usage": "Total energy usage",
|
"total_energy_usage": "Total",
|
||||||
"change_chart_type": "Change chart type",
|
"change_chart_type": "Change chart type",
|
||||||
"untracked": "untracked",
|
"untracked_consumption": "Untracked consumption",
|
||||||
"includes_untracked": "Includes {num} kWh of untracked energy"
|
"untracked": "untracked"
|
||||||
},
|
},
|
||||||
"energy_devices_detail_graph": {
|
"energy_devices_detail_graph": {
|
||||||
"untracked_consumption": "Untracked consumption",
|
"untracked_consumption": "Untracked consumption",
|
||||||
|
|||||||
@@ -201,6 +201,7 @@ describe("getStates", () => {
|
|||||||
"pm1",
|
"pm1",
|
||||||
"pm10",
|
"pm10",
|
||||||
"pm25",
|
"pm25",
|
||||||
|
"pm4",
|
||||||
"power_factor",
|
"power_factor",
|
||||||
"power",
|
"power",
|
||||||
"pressure",
|
"pressure",
|
||||||
@@ -215,7 +216,7 @@ describe("getStates", () => {
|
|||||||
"volume_flow_rate",
|
"volume_flow_rate",
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
expect(result.length).toBe(34);
|
expect(result.length).toBe(35);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return empty array for unknown attribute", () => {
|
it("should return empty array for unknown attribute", () => {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it, vi } from "vitest";
|
||||||
import { DEFAULT_ENTITY_NAME } from "../../../../../src/common/entity/compute_entity_name_display";
|
|
||||||
import { computeLovelaceEntityName } from "../../../../../src/panels/lovelace/common/entity/compute-lovelace-entity-name";
|
import { computeLovelaceEntityName } from "../../../../../src/panels/lovelace/common/entity/compute-lovelace-entity-name";
|
||||||
import type { HomeAssistant } from "../../../../../src/types";
|
import type { HomeAssistant } from "../../../../../src/types";
|
||||||
import { mockStateObj } from "../../../../common/entity/context/context-mock";
|
import { mockStateObj } from "../../../../common/entity/context/context-mock";
|
||||||
@@ -23,30 +22,32 @@ describe("computeLovelaceEntityName", () => {
|
|||||||
expect(mockFormatEntityName).not.toHaveBeenCalled();
|
expect(mockFormatEntityName).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns empty string when nameConfig is empty string", () => {
|
it("return state name when nameConfig is empty string", () => {
|
||||||
const mockFormatEntityName = vi.fn();
|
const mockFormatEntityName = vi.fn();
|
||||||
const hass = createMockHass(mockFormatEntityName);
|
const hass = createMockHass(mockFormatEntityName);
|
||||||
const stateObj = mockStateObj({ entity_id: "light.kitchen" });
|
const stateObj = mockStateObj({
|
||||||
|
entity_id: "light.kitchen",
|
||||||
|
attributes: { friendly_name: "Kitchen Light" },
|
||||||
|
});
|
||||||
|
|
||||||
const result = computeLovelaceEntityName(hass, stateObj, "");
|
const result = computeLovelaceEntityName(hass, stateObj, "");
|
||||||
|
|
||||||
expect(result).toBe("");
|
expect(result).toBe("Kitchen Light");
|
||||||
expect(mockFormatEntityName).not.toHaveBeenCalled();
|
expect(mockFormatEntityName).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("calls formatEntityName with DEFAULT_ENTITY_NAME when nameConfig is undefined", () => {
|
it("return state name when nameConfig is undefined", () => {
|
||||||
const mockFormatEntityName = vi.fn(() => "Formatted Name");
|
const mockFormatEntityName = vi.fn(() => "Formatted Name");
|
||||||
const hass = createMockHass(mockFormatEntityName);
|
const hass = createMockHass(mockFormatEntityName);
|
||||||
const stateObj = mockStateObj({ entity_id: "light.kitchen" });
|
const stateObj = mockStateObj({
|
||||||
|
entity_id: "light.kitchen",
|
||||||
|
attributes: { friendly_name: "Kitchen Light" },
|
||||||
|
});
|
||||||
|
|
||||||
const result = computeLovelaceEntityName(hass, stateObj, undefined);
|
const result = computeLovelaceEntityName(hass, stateObj, undefined);
|
||||||
|
|
||||||
expect(result).toBe("Formatted Name");
|
expect(result).toBe("Kitchen Light");
|
||||||
expect(mockFormatEntityName).toHaveBeenCalledTimes(1);
|
expect(mockFormatEntityName).not.toHaveBeenCalled();
|
||||||
expect(mockFormatEntityName).toHaveBeenCalledWith(
|
|
||||||
stateObj,
|
|
||||||
DEFAULT_ENTITY_NAME
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("calls formatEntityName with EntityNameItem config", () => {
|
it("calls formatEntityName with EntityNameItem config", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user