Compare commits

..

4 Commits

Author SHA1 Message Date
Wendelin
49bd7852da Fix yaml mode switch 2025-08-29 21:48:38 +02:00
Wendelin
9dbad15626 Also add to scripts 2025-08-29 16:20:21 +02:00
Wendelin
78090a86db Fix editor not rerendering 2025-08-29 15:50:26 +02:00
Wendelin
9bb499e621 Automation editor: fix yaml editor 2025-08-29 15:20:08 +02:00
28 changed files with 271 additions and 253 deletions

View File

@@ -123,7 +123,7 @@
"lit": "3.3.1",
"lit-html": "3.3.1",
"luxon": "3.7.1",
"marked": "16.2.1",
"marked": "16.2.0",
"memoize-one": "6.0.0",
"node-vibrant": "4.0.3",
"object-hash": "3.0.0",
@@ -159,7 +159,7 @@
"@octokit/plugin-retry": "8.0.1",
"@octokit/rest": "22.0.0",
"@rsdoctor/rspack-plugin": "1.2.3",
"@rspack/core": "1.5.1",
"@rspack/core": "1.4.11",
"@rspack/dev-server": "1.1.4",
"@types/babel__plugin-transform-runtime": "7.9.5",
"@types/chromecast-caf-receiver": "6.0.22",

View File

@@ -53,15 +53,9 @@ export class HaMediaSelector extends LitElement {
private _contextEntities: string[] | undefined;
private get _hasAccept(): boolean {
return !!this.selector?.media?.accept?.length;
}
willUpdate(changedProps: PropertyValues<this>) {
if (changedProps.has("context")) {
if (!this._hasAccept) {
this._contextEntities = ensureArray(this.context?.filter_entity);
}
this._contextEntities = ensureArray(this.context?.filter_entity);
}
if (changedProps.has("value")) {
@@ -105,8 +99,10 @@ export class HaMediaSelector extends LitElement {
(stateObj &&
supportsFeature(stateObj, MediaPlayerEntityFeature.BROWSE_MEDIA));
const hasAccept = this.selector?.media?.accept?.length;
return html`
${this._hasAccept ||
${hasAccept ||
(this._contextEntities && this._contextEntities.length <= 1)
? nothing
: html`
@@ -152,7 +148,7 @@ export class HaMediaSelector extends LitElement {
: this.value.metadata?.title || this.value.media_content_id}
@click=${this._pickMedia}
@keydown=${this._handleKeyDown}
class=${this.disabled || (!entityId && !this._hasAccept)
class=${this.disabled || (!entityId && !hasAccept)
? "disabled"
: ""}
>
@@ -219,7 +215,7 @@ export class HaMediaSelector extends LitElement {
private _entityChanged(ev: CustomEvent) {
ev.stopPropagation();
if (!this._hasAccept && this.context?.filter_entity) {
if (this.context?.filter_entity) {
fireEvent(this, "value-changed", {
value: {
media_content_id: "",
@@ -261,7 +257,7 @@ export class HaMediaSelector extends LitElement {
media_content_type: id.media_content_type,
media_content_id: id.media_content_id,
})),
...(!this._hasAccept && this.context?.filter_entity
...(this.context?.filter_entity
? { browse_entity_id: this._getActiveEntityId() }
: {}),
},

View File

@@ -556,7 +556,6 @@ export interface AutomationClipboard {
}
export interface BaseSidebarConfig {
toggleYamlMode: () => boolean;
delete: () => void;
close: (focus?: boolean) => void;
}
@@ -568,6 +567,7 @@ export interface TriggerSidebarConfig extends BaseSidebarConfig {
duplicate: () => void;
cut: () => void;
copy: () => void;
toggleYamlMode: () => void;
config: Trigger;
yamlMode: boolean;
uiSupported: boolean;
@@ -581,6 +581,7 @@ export interface ConditionSidebarConfig extends BaseSidebarConfig {
duplicate: () => void;
cut: () => void;
copy: () => void;
toggleYamlMode: () => void;
config: Condition;
yamlMode: boolean;
uiSupported: boolean;
@@ -594,6 +595,7 @@ export interface ActionSidebarConfig extends BaseSidebarConfig {
cut: () => void;
copy: () => void;
run: () => void;
toggleYamlMode: () => void;
config: {
action: Action;
};
@@ -615,6 +617,7 @@ export interface ScriptFieldSidebarConfig extends BaseSidebarConfig {
key: string;
excludeKeys: string[];
};
toggleYamlMode: () => void;
yamlMode: boolean;
}

View File

@@ -97,7 +97,7 @@ export default class HaAutomationActionEditor extends LitElement {
if (!ev.detail.isValid) {
return;
}
fireEvent(this, "value-changed", {
fireEvent(this, "yaml-changed", {
value: migrateAutomationAction(ev.detail.value),
});
}

View File

@@ -688,7 +688,7 @@ export default class HaAutomationActionRow extends LitElement {
},
toggleYamlMode: () => {
this._toggleYamlMode();
return this._yamlMode;
this.openSidebar();
},
disable: this._onDisable,
delete: this._onDelete,

View File

@@ -103,8 +103,7 @@ export default class HaAutomationConditionEditor extends LitElement {
if (!ev.detail.isValid) {
return;
}
// @ts-ignore
fireEvent(this, "value-changed", { value: ev.detail.value, yaml: true });
fireEvent(this, "yaml-changed", { value: ev.detail.value });
}
private _onUiChanged(ev: CustomEvent) {

View File

@@ -660,7 +660,7 @@ export default class HaAutomationConditionRow extends LitElement {
},
toggleYamlMode: () => {
this._toggleYamlMode();
return this._yamlMode;
this.openSidebar();
},
disable: this._onDisable,
delete: this._onDelete,

View File

@@ -1,6 +1,5 @@
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { fireEvent } from "../../../common/dom/fire_event";
import "../../../components/ha-bottom-sheet";
import type { HaBottomSheet } from "../../../components/ha-bottom-sheet";
import {
@@ -34,6 +33,8 @@ export default class HaAutomationSidebar extends LitElement {
@property({ type: Boolean }) public narrow = false;
@property({ attribute: "sidebar-key" }) public sidebarKey?: string;
@state() private _yamlMode = false;
@query("ha-bottom-sheet") private _bottomSheetElement?: HaBottomSheet;
@@ -52,6 +53,7 @@ export default class HaAutomationSidebar extends LitElement {
.narrow=${this.narrow}
.disabled=${this.disabled}
.yamlMode=${this._yamlMode}
.sidebarKey=${this.sidebarKey}
@toggle-yaml-mode=${this._toggleYamlMode}
@close-sidebar=${this._handleCloseSidebar}
></ha-automation-sidebar-trigger>
@@ -67,6 +69,7 @@ export default class HaAutomationSidebar extends LitElement {
.narrow=${this.narrow}
.disabled=${this.disabled}
.yamlMode=${this._yamlMode}
.sidebarKey=${this.sidebarKey}
@toggle-yaml-mode=${this._toggleYamlMode}
@close-sidebar=${this._handleCloseSidebar}
></ha-automation-sidebar-condition>
@@ -82,6 +85,7 @@ export default class HaAutomationSidebar extends LitElement {
.narrow=${this.narrow}
.disabled=${this.disabled}
.yamlMode=${this._yamlMode}
.sidebarKey=${this.sidebarKey}
@toggle-yaml-mode=${this._toggleYamlMode}
@close-sidebar=${this._handleCloseSidebar}
></ha-automation-sidebar-action>
@@ -110,6 +114,7 @@ export default class HaAutomationSidebar extends LitElement {
.narrow=${this.narrow}
.disabled=${this.disabled}
.yamlMode=${this._yamlMode}
.sidebarKey=${this.sidebarKey}
@toggle-yaml-mode=${this._toggleYamlMode}
@close-sidebar=${this._handleCloseSidebar}
></ha-automation-sidebar-script-field-selector>
@@ -125,6 +130,7 @@ export default class HaAutomationSidebar extends LitElement {
.narrow=${this.narrow}
.disabled=${this.disabled}
.yamlMode=${this._yamlMode}
.sidebarKey=${this.sidebarKey}
@toggle-yaml-mode=${this._toggleYamlMode}
@close-sidebar=${this._handleCloseSidebar}
></ha-automation-sidebar-script-field>
@@ -197,13 +203,7 @@ export default class HaAutomationSidebar extends LitElement {
}
private _toggleYamlMode = () => {
this._yamlMode = this.config!.toggleYamlMode();
fireEvent(this, "value-changed", {
value: {
...this.config,
yamlMode: this._yamlMode,
},
});
(this.config as ActionSidebarConfig)?.toggleYamlMode();
};
static styles = css`
@@ -235,5 +235,8 @@ declare global {
interface HASSDomEvents {
"toggle-yaml-mode": undefined;
"yaml-changed": {
value: unknown;
};
}
}

View File

@@ -92,6 +92,8 @@ export class HaManualAutomationEditor extends LitElement {
@state() private _sidebarConfig?: SidebarConfig;
@state() private _sidebarKey?: string;
@query("ha-automation-sidebar") private _sidebarElement?: HaAutomationSidebar;
private _previousConfig?: ManualAutomationConfig;
@@ -287,6 +289,7 @@ export class HaManualAutomationEditor extends LitElement {
.config=${this._sidebarConfig}
@value-changed=${this._sidebarConfigChanged}
.disabled=${this.disabled}
.sidebarKey=${this._sidebarKey}
></ha-automation-sidebar>
</div>
</div>
@@ -314,6 +317,7 @@ export class HaManualAutomationEditor extends LitElement {
// deselect previous selected row
this._sidebarConfig?.close?.();
this._sidebarConfig = ev.detail;
this._sidebarKey = JSON.stringify(this._sidebarConfig);
await this._sidebarElement?.updateComplete;
this._sidebarElement?.focus();

View File

@@ -395,7 +395,6 @@ export default class HaAutomationOptionRow extends LitElement {
rename: () => {
this._renameOption();
},
toggleYamlMode: () => false, // no yaml mode for options
delete: this._removeOption,
duplicate: this._duplicateOption,
defaultOption: !!this.defaultActions,

View File

@@ -11,6 +11,7 @@ import {
} from "@mdi/js";
import { html, LitElement } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { keyed } from "lit/directives/keyed";
import { fireEvent } from "../../../../common/dom/fire_event";
import { handleStructError } from "../../../../common/structs/handle-errors";
import type { LocalizeKeys } from "../../../../common/translations/localize";
@@ -41,6 +42,8 @@ export default class HaAutomationSidebarAction extends LitElement {
@property({ type: Boolean }) public narrow = false;
@property({ attribute: "sidebar-key" }) public sidebarKey?: string;
@state() private _warnings?: string[];
@query(".sidebar-editor")
@@ -181,18 +184,22 @@ export default class HaAutomationSidebarAction extends LitElement {
</ha-md-menu-item>
${description && !this.yamlMode
? html`<div class="description">${description}</div>`
: html`<ha-automation-action-editor
class="sidebar-editor"
.hass=${this.hass}
.action=${actionConfig}
.yamlMode=${this.yamlMode}
.uiSupported=${this.config.uiSupported}
@value-changed=${this._valueChangedSidebar}
sidebar
narrow
.disabled=${this.disabled}
@ui-mode-not-available=${this._handleUiModeNotAvailable}
></ha-automation-action-editor>`}
: keyed(
this.sidebarKey,
html`<ha-automation-action-editor
class="sidebar-editor"
.hass=${this.hass}
.action=${actionConfig}
.yamlMode=${this.yamlMode}
.uiSupported=${this.config.uiSupported}
@value-changed=${this._valueChangedSidebar}
@yaml-changed=${this._yamlChangedSidebar}
sidebar
narrow
.disabled=${this.disabled}
@ui-mode-not-available=${this._handleUiModeNotAvailable}
></ha-automation-action-editor>`
)}
</ha-automation-sidebar-card>`;
}
@@ -220,6 +227,12 @@ export default class HaAutomationSidebarAction extends LitElement {
}
}
private _yamlChangedSidebar(ev: CustomEvent) {
ev.stopPropagation();
this.config?.save?.(ev.detail.value);
}
private _toggleYamlMode = () => {
fireEvent(this, "toggle-yaml-mode");
};

View File

@@ -11,6 +11,7 @@ import {
} from "@mdi/js";
import { html, LitElement } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { keyed } from "lit/directives/keyed";
import { fireEvent } from "../../../../common/dom/fire_event";
import { handleStructError } from "../../../../common/structs/handle-errors";
import type { ConditionSidebarConfig } from "../../../../data/automation";
@@ -35,6 +36,8 @@ export default class HaAutomationSidebarCondition extends LitElement {
@property({ type: Boolean }) public narrow = false;
@property({ attribute: "sidebar-key" }) public sidebarKey?: string;
@state() private _warnings?: string[];
@query(".sidebar-editor")
@@ -173,17 +176,21 @@ export default class HaAutomationSidebarCondition extends LitElement {
</ha-md-menu-item>
${description && !this.yamlMode
? html`<div class="description">${description}</div>`
: html`<ha-automation-condition-editor
class="sidebar-editor"
.hass=${this.hass}
.condition=${this.config.config}
.yamlMode=${this.yamlMode}
.uiSupported=${this.config.uiSupported}
@value-changed=${this._valueChangedSidebar}
.disabled=${this.disabled}
@ui-mode-not-available=${this._handleUiModeNotAvailable}
sidebar
></ha-automation-condition-editor> `}
: keyed(
this.sidebarKey,
html`<ha-automation-condition-editor
class="sidebar-editor"
.hass=${this.hass}
.condition=${this.config.config}
.yamlMode=${this.yamlMode}
.uiSupported=${this.config.uiSupported}
@value-changed=${this._valueChangedSidebar}
@yaml-changed=${this._yamlChangedSidebar}
.disabled=${this.disabled}
@ui-mode-not-available=${this._handleUiModeNotAvailable}
sidebar
></ha-automation-condition-editor>`
)}
</ha-automation-sidebar-card>`;
}
@@ -209,6 +216,12 @@ export default class HaAutomationSidebarCondition extends LitElement {
}
}
private _yamlChangedSidebar(ev: CustomEvent) {
ev.stopPropagation();
this.config?.save?.(ev.detail.value);
}
private _toggleYamlMode = () => {
fireEvent(this, "toggle-yaml-mode");
};

View File

@@ -1,6 +1,7 @@
import { mdiDelete, mdiPlaylistEdit } from "@mdi/js";
import { html, LitElement } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { keyed } from "lit/directives/keyed";
import { fireEvent } from "../../../../common/dom/fire_event";
import type { LocalizeKeys } from "../../../../common/translations/localize";
import type { ScriptFieldSidebarConfig } from "../../../../data/automation";
@@ -24,6 +25,8 @@ export default class HaAutomationSidebarScriptFieldSelector extends LitElement {
@property({ type: Boolean }) public narrow = false;
@property({ attribute: "sidebar-key" }) public sidebarKey?: string;
@state() private _warnings?: string[];
@query(".sidebar-editor")
@@ -81,14 +84,18 @@ export default class HaAutomationSidebarScriptFieldSelector extends LitElement {
)}
<ha-svg-icon slot="start" .path=${mdiDelete}></ha-svg-icon>
</ha-md-menu-item>
<ha-script-field-selector-editor
class="sidebar-editor"
.hass=${this.hass}
.field=${this.config.config.field}
.disabled=${this.disabled}
@value-changed=${this._valueChangedSidebar}
.yamlMode=${this.yamlMode}
></ha-script-field-selector-editor>
${keyed(
this.sidebarKey,
html`<ha-script-field-selector-editor
class="sidebar-editor"
.hass=${this.hass}
.field=${this.config.config.field}
.disabled=${this.disabled}
@value-changed=${this._valueChangedSidebar}
@yaml-changed=${this._yamlChangedSidebar}
.yamlMode=${this.yamlMode}
></ha-script-field-selector-editor>`
)}
</ha-automation-sidebar-card>`;
}
@@ -116,6 +123,12 @@ export default class HaAutomationSidebarScriptFieldSelector extends LitElement {
}
}
private _yamlChangedSidebar(ev: CustomEvent) {
ev.stopPropagation();
this.config?.save?.(ev.detail.value);
}
private _toggleYamlMode = () => {
fireEvent(this, "toggle-yaml-mode");
};

View File

@@ -1,6 +1,7 @@
import { mdiDelete, mdiPlaylistEdit } from "@mdi/js";
import { html, LitElement } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { keyed } from "lit/directives/keyed";
import { fireEvent } from "../../../../common/dom/fire_event";
import type { ScriptFieldSidebarConfig } from "../../../../data/automation";
import type { HomeAssistant } from "../../../../types";
@@ -23,6 +24,8 @@ export default class HaAutomationSidebarScriptField extends LitElement {
@property({ type: Boolean }) public narrow = false;
@property({ attribute: "sidebar-key" }) public sidebarKey?: string;
@state() private _warnings?: string[];
@query(".sidebar-editor")
@@ -74,16 +77,20 @@ export default class HaAutomationSidebarScriptField extends LitElement {
)}
<ha-svg-icon slot="start" .path=${mdiDelete}></ha-svg-icon>
</ha-md-menu-item>
<ha-script-field-editor
class="sidebar-editor"
.hass=${this.hass}
.field=${this.config.config.field}
.key=${this.config.config.key}
.excludeKeys=${this.config.config.excludeKeys}
.disabled=${this.disabled}
.yamlMode=${this.yamlMode}
@value-changed=${this._valueChangedSidebar}
></ha-script-field-editor>
${keyed(
this.sidebarKey,
html`<ha-script-field-editor
class="sidebar-editor"
.hass=${this.hass}
.field=${this.config.config.field}
.key=${this.config.config.key}
.excludeKeys=${this.config.config.excludeKeys}
.disabled=${this.disabled}
.yamlMode=${this.yamlMode}
@value-changed=${this._valueChangedSidebar}
@yaml-changed=${this._yamlChangedSidebar}
></ha-script-field-editor>`
)}
</ha-automation-sidebar-card>`;
}
@@ -110,6 +117,12 @@ export default class HaAutomationSidebarScriptField extends LitElement {
}
}
private _yamlChangedSidebar(ev: CustomEvent) {
ev.stopPropagation();
this.config?.save?.(ev.detail.value);
}
private _toggleYamlMode = () => {
fireEvent(this, "toggle-yaml-mode");
};

View File

@@ -11,6 +11,7 @@ import {
} from "@mdi/js";
import { html, LitElement, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { keyed } from "lit/directives/keyed";
import { fireEvent } from "../../../../common/dom/fire_event";
import { handleStructError } from "../../../../common/structs/handle-errors";
import type { TriggerSidebarConfig } from "../../../../data/automation";
@@ -35,6 +36,8 @@ export default class HaAutomationSidebarTrigger extends LitElement {
@property({ type: Boolean }) public narrow = false;
@property({ attribute: "sidebar-key" }) public sidebarKey?: string;
@state() private _requestShowId = false;
@state() private _warnings?: string[];
@@ -183,18 +186,22 @@ export default class HaAutomationSidebarTrigger extends LitElement {
)}
<ha-svg-icon slot="start" .path=${mdiDelete}></ha-svg-icon>
</ha-md-menu-item>
<ha-automation-trigger-editor
class="sidebar-editor"
.hass=${this.hass}
.trigger=${this.config.config}
@value-changed=${this._valueChangedSidebar}
.uiSupported=${this.config.uiSupported}
.showId=${this._requestShowId}
.yamlMode=${this.yamlMode}
.disabled=${this.disabled}
@ui-mode-not-available=${this._handleUiModeNotAvailable}
sidebar
></ha-automation-trigger-editor>
${keyed(
this.sidebarKey,
html`<ha-automation-trigger-editor
class="sidebar-editor"
.hass=${this.hass}
.trigger=${this.config.config}
@value-changed=${this._valueChangedSidebar}
@yaml-changed=${this._yamlChangedSidebar}
.uiSupported=${this.config.uiSupported}
.showId=${this._requestShowId}
.yamlMode=${this.yamlMode}
.disabled=${this.disabled}
@ui-mode-not-available=${this._handleUiModeNotAvailable}
sidebar
></ha-automation-trigger-editor>`
)}
</ha-automation-sidebar-card>
`;
}
@@ -221,6 +228,12 @@ export default class HaAutomationSidebarTrigger extends LitElement {
}
}
private _yamlChangedSidebar(ev: CustomEvent) {
ev.stopPropagation();
this.config?.save?.(ev.detail.value);
}
private _toggleYamlMode = () => {
fireEvent(this, "toggle-yaml-mode");
};

View File

@@ -121,7 +121,7 @@ export default class HaAutomationTriggerEditor extends LitElement {
if (!ev.detail.isValid) {
return;
}
fireEvent(this, "value-changed", {
fireEvent(this, "yaml-changed", {
value: migrateAutomationTrigger(ev.detail.value),
});
}

View File

@@ -494,7 +494,7 @@ export default class HaAutomationTriggerRow extends LitElement {
},
toggleYamlMode: () => {
this._toggleYamlMode();
return this._yamlMode;
this.openSidebar();
},
disable: this._onDisable,
delete: this._onDelete,

View File

@@ -34,16 +34,6 @@ const UPDATE_THROTTLE_TIME = 10000;
const CORE_SOURCE_ID = "ha";
const CORE_SOURCE_LABEL = "Home Assistant";
const RSSI_COLOR_THRESHOLDS: [number, string][] = [
[-70, "--green-color"], // Excellent: > -70 dBm
[-75, "--lime-color"], // Good: -70 to -75 dBm
[-80, "--yellow-color"], // Okay: -75 to -80 dBm
[-85, "--amber-color"], // Marginal: -80 to -85 dBm
[-90, "--orange-color"], // Weak: -85 to -90 dBm
[-95, "--deep-orange-color"], // Poor: -90 to -95 dBm
[-Infinity, "--red-color"], // Very poor: < -95 dBm
];
@customElement("bluetooth-network-visualization")
export class BluetoothNetworkVisualization extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@@ -135,16 +125,6 @@ export class BluetoothNetworkVisualization extends LitElement {
`;
}
private _getRssiColorVar = memoizeOne((rssi: number): string => {
for (const [threshold, colorVar] of RSSI_COLOR_THRESHOLDS) {
if (rssi > threshold) {
return colorVar;
}
}
// Fallback (should never reach here)
return "--red-color";
});
private _formatNetworkData = memoizeOne(
(
data: BluetoothDeviceData[],
@@ -226,7 +206,7 @@ export class BluetoothNetworkVisualization extends LitElement {
symbol: "none",
lineStyle: {
width: this._getLineWidth(node.rssi),
color: style.getPropertyValue(this._getRssiColorVar(node.rssi)),
color: style.getPropertyValue("--primary-color"),
},
});
return;
@@ -247,7 +227,7 @@ export class BluetoothNetworkVisualization extends LitElement {
lineStyle: {
width: this._getLineWidth(node.rssi),
color: device
? style.getPropertyValue(this._getRssiColorVar(node.rssi))
? style.getPropertyValue("--primary-color")
: style.getPropertyValue("--disabled-color"),
},
});

View File

@@ -199,10 +199,8 @@ export class HaConfigLovelaceDashboards extends LitElement {
"ui.panel.config.lovelace.dashboards.picker.headers.require_admin"
),
sortable: true,
hidden: narrow,
type: "icon",
minWidth: "120px",
maxWidth: "120px",
hidden: narrow,
template: (dashboard) =>
dashboard.require_admin
? html`<ha-svg-icon .path=${mdiCheck}></ha-svg-icon>`
@@ -212,10 +210,8 @@ export class HaConfigLovelaceDashboards extends LitElement {
title: localize(
"ui.panel.config.lovelace.dashboards.picker.headers.sidebar"
),
hidden: narrow,
type: "icon",
minWidth: "120px",
maxWidth: "120px",
hidden: narrow,
template: (dashboard) =>
dashboard.show_in_sidebar
? html`<ha-svg-icon .path=${mdiCheck}></ha-svg-icon>`

View File

@@ -152,7 +152,12 @@ export default class HaScriptFieldEditor extends LitElement {
ev.stopPropagation();
const value = { ...ev.detail.value };
if (typeof value !== "object" || Object.keys(value).length !== 1) {
if (
typeof value !== "object" ||
Object.keys(value).length !== 1 ||
!value[Object.keys(value)[0]] ||
!value[Object.keys(value)[0]].selector
) {
this._yamlError = "yaml_error";
return;
}
@@ -165,7 +170,7 @@ export default class HaScriptFieldEditor extends LitElement {
const newValue = { ...value[key], key };
fireEvent(this, "value-changed", { value: newValue });
fireEvent(this, "yaml-changed", { value: newValue });
}
private _computeLabelCallback = (

View File

@@ -218,7 +218,7 @@ export default class HaScriptFieldRow extends LitElement {
},
toggleYamlMode: () => {
this._toggleYamlMode();
return this._yamlMode;
this.openSidebar();
},
delete: this._onDelete,
config: {

View File

@@ -132,7 +132,7 @@ export default class HaScriptFieldSelectorEditor extends LitElement {
return;
}
fireEvent(this, "value-changed", { value });
fireEvent(this, "yaml-changed", { value });
}
private _computeLabelCallback = (

View File

@@ -73,6 +73,8 @@ export class HaManualScriptEditor extends LitElement {
@state() private _sidebarConfig?: SidebarConfig;
@state() private _sidebarKey?: string;
@query("ha-script-fields")
private _scriptFields?: HaScriptFields;
@@ -223,6 +225,7 @@ export class HaManualScriptEditor extends LitElement {
</div>
<div class="sidebar-positioner">
<ha-automation-sidebar
.sidebarKey=${this._sidebarKey}
tabindex="-1"
class=${classMap({ hidden: !this._sidebarConfig })}
.narrow=${this.narrow}
@@ -463,6 +466,7 @@ export class HaManualScriptEditor extends LitElement {
// deselect previous selected row
this._sidebarConfig?.close?.();
this._sidebarConfig = ev.detail;
this._sidebarKey = JSON.stringify(this._sidebarConfig);
await this._sidebarElement?.updateComplete;
this._sidebarElement?.focus();

View File

@@ -568,10 +568,6 @@ class HaPanelDevState extends LitElement {
margin: 0 8px 16px;
}
ha-expansion-panel p {
padding: 0 8px;
}
.inputs {
width: 100%;
max-width: 800px;
@@ -583,9 +579,8 @@ class HaPanelDevState extends LitElement {
.button-row {
display: flex;
margin: 8px 0;
margin-top: 8px;
align-items: center;
gap: 8px;
}
:host([narrow]) .state-wrapper {

View File

@@ -15,6 +15,7 @@ import type { HomeAssistant } from "../../../../../types";
import { supportsAlarmModesCardFeature } from "../../../card-features/hui-alarm-modes-card-feature";
import { supportsCoverOpenCloseCardFeature } from "../../../card-features/hui-cover-open-close-card-feature";
import { supportsFanSpeedCardFeature } from "../../../card-features/hui-fan-speed-card-feature";
import { supportsHistoryChartCardFeature } from "../../../card-features/hui-history-chart-card-feature";
import { supportsLightBrightnessCardFeature } from "../../../card-features/hui-light-brightness-card-feature";
import { supportsLockCommandsCardFeature } from "../../../card-features/hui-lock-commands-card-feature";
import { supportsTargetTemperatureCardFeature } from "../../../card-features/hui-target-temperature-card-feature";
@@ -237,7 +238,12 @@ export const computeAreaTileCardConfig =
let feature: LovelaceCardFeatureConfig | undefined;
if (includeFeature) {
if (supportsLightBrightnessCardFeature(hass, context)) {
if (supportsHistoryChartCardFeature(hass, context)) {
feature = {
type: "history-chart",
hours_to_show: 24,
};
} else if (supportsLightBrightnessCardFeature(hass, context)) {
feature = {
type: "light-brightness",
};

View File

@@ -12,30 +12,11 @@ import {
} from "../areas/helpers/areas-strategy-helper";
import { getHomeStructure } from "./helpers/home-structure";
import { findEntities, HOME_SUMMARIES_FILTERS } from "./helpers/home-summaries";
import { computeStateName } from "../../../../common/entity/compute_state_name";
import { computeObjectId } from "../../../../common/entity/compute_object_id";
export interface HomeClimateViewStrategyConfig {
type: "home-climate";
}
const createTempHumidBadge = (hass: HomeAssistant, entityId: string) => {
const stateObj = hass.states[entityId];
return {
type: "tile",
entity: entityId,
name: stateObj
? computeStateName(stateObj)
: computeObjectId(entityId).replace(/_/g, " "),
features: [
{
type: "history-chart",
hours_to_show: 3,
},
],
};
};
const processAreasForClimate = (
areaIds: string[],
hass: HomeAssistant,
@@ -65,14 +46,10 @@ const processAreasForClimate = (
});
if (hass.areas[areaId].temperature_entity_id) {
cards.push(
createTempHumidBadge(hass, hass.areas[areaId].temperature_entity_id)
);
cards.push(computeTileCard(hass.areas[areaId].temperature_entity_id));
}
if (hass.areas[areaId].humidity_entity_id) {
cards.push(
createTempHumidBadge(hass, hass.areas[areaId].humidity_entity_id)
);
cards.push(computeTileCard(hass.areas[areaId].humidity_entity_id));
}
for (const entityId of areaEntities) {

View File

@@ -13,8 +13,6 @@ import {
import { getHomeStructure } from "./helpers/home-structure";
import { findEntities, HOME_SUMMARIES_FILTERS } from "./helpers/home-summaries";
import { computeDomain } from "../../../../common/entity/compute_domain";
import { computeStateName } from "../../../../common/entity/compute_state_name";
import { computeObjectId } from "../../../../common/entity/compute_object_id";
export interface HomeSecurityViewStrategyConfig {
type: "home-security";
@@ -27,6 +25,7 @@ const processAreasForSecurity = (
): LovelaceCardConfig[] => {
const cards: LovelaceCardConfig[] = [];
const computeTileCard = computeAreaTileCardConfig(hass, "", false);
const computeTileCardWithFeature = computeAreaTileCardConfig(hass, "", true);
for (const areaId of areaIds) {
const area = hass.areas[areaId];
@@ -49,23 +48,10 @@ const processAreasForSecurity = (
});
for (const entityId of areaEntities) {
const stateObj = hass.states[entityId];
cards.push(
computeDomain(entityId) === "binary_sensor" &&
stateObj?.attributes.device_class === "motion"
? {
type: "tile",
entity: entityId,
name: stateObj
? computeStateName(stateObj)
: computeObjectId(entityId).replace(/_/g, " "),
features: [
{
type: "history-chart",
hours_to_show: 6,
},
],
}
hass.states[entityId]?.attributes.device_class === "motion"
? computeTileCardWithFeature(entityId)
: computeTileCard(entityId)
);
}

178
yarn.lock
View File

@@ -3281,58 +3281,58 @@ __metadata:
languageName: node
linkType: hard
"@module-federation/error-codes@npm:0.18.0":
version: 0.18.0
resolution: "@module-federation/error-codes@npm:0.18.0"
checksum: 10/ccd00f6b2504ec2e685bda6d175ed86df27e21994b36869140a18059595716e9ea7db5d0b516a095891ec9e6c90e702f42a366743df3652bf91ff3bb4f895991
"@module-federation/error-codes@npm:0.17.1":
version: 0.17.1
resolution: "@module-federation/error-codes@npm:0.17.1"
checksum: 10/5f5f02a90a423479c84e4ff4398a3a9e31b66bd545e7c978ecb8a417f33162b86e749356baab14c006e741c9cebae549335a4c99e94ce7ef54210269fdf74f7f
languageName: node
linkType: hard
"@module-federation/runtime-core@npm:0.18.0":
version: 0.18.0
resolution: "@module-federation/runtime-core@npm:0.18.0"
"@module-federation/runtime-core@npm:0.17.1":
version: 0.17.1
resolution: "@module-federation/runtime-core@npm:0.17.1"
dependencies:
"@module-federation/error-codes": "npm:0.18.0"
"@module-federation/sdk": "npm:0.18.0"
checksum: 10/82af795408f2e92bea9c801a2057f1a6ed85eaf131195d5deaa4ef9a6a88db9e2cb851b4416e6e43a841459986b5ebb84e98b4625fb9bbd98cee11929f1ede6b
"@module-federation/error-codes": "npm:0.17.1"
"@module-federation/sdk": "npm:0.17.1"
checksum: 10/b0c945379bde13af84ceb833e3bfe3c8cf11fd265af0ad7640a1506017529458f408a4a3f1bd0f4b5983da71438913d5c25ed25e20908eb1f789bd1483616650
languageName: node
linkType: hard
"@module-federation/runtime-tools@npm:0.18.0":
version: 0.18.0
resolution: "@module-federation/runtime-tools@npm:0.18.0"
"@module-federation/runtime-tools@npm:0.17.1":
version: 0.17.1
resolution: "@module-federation/runtime-tools@npm:0.17.1"
dependencies:
"@module-federation/runtime": "npm:0.18.0"
"@module-federation/webpack-bundler-runtime": "npm:0.18.0"
checksum: 10/c6b1483899865e4c73be0ae77e6e1a5f517798f7ab3b8c6df2bb7ed22463e7a471f68d5f9528b2aff5b45e2db67596805028206f3956aafec5a36dcefb94afd2
"@module-federation/runtime": "npm:0.17.1"
"@module-federation/webpack-bundler-runtime": "npm:0.17.1"
checksum: 10/2e183e357b644dbe015d0e51df3fe601852ca79ffe3a30c582eee7a2050d7600eb3253f5de15e476c60741d0a1dd70add1ade7b5a3537cd2ee12bfee286284ea
languageName: node
linkType: hard
"@module-federation/runtime@npm:0.18.0":
version: 0.18.0
resolution: "@module-federation/runtime@npm:0.18.0"
"@module-federation/runtime@npm:0.17.1":
version: 0.17.1
resolution: "@module-federation/runtime@npm:0.17.1"
dependencies:
"@module-federation/error-codes": "npm:0.18.0"
"@module-federation/runtime-core": "npm:0.18.0"
"@module-federation/sdk": "npm:0.18.0"
checksum: 10/6164597782b21840e3b8f159000338d8e20a817a60909015c11402e9e6442d60d9c3b4b6f25d92d7261011ef1fc0e8caafbb91f25c29b372f28764cbea8ef9eb
"@module-federation/error-codes": "npm:0.17.1"
"@module-federation/runtime-core": "npm:0.17.1"
"@module-federation/sdk": "npm:0.17.1"
checksum: 10/f5405968dff4fa2cf510127701ec1722105f44298fd09eafeecead450b7bb95a05450749157fe2fc39caf6241bec9e45caa9a55375b48e7f195db84799a8df0c
languageName: node
linkType: hard
"@module-federation/sdk@npm:0.18.0":
version: 0.18.0
resolution: "@module-federation/sdk@npm:0.18.0"
checksum: 10/f397dc53c705ad1f1e19530a8ff79116bb5aeeef92a79b3acaaa6140ae4e5784b42e81d1445eabf536c007c9383857f6764506ed725a6352464fe1ce581af89a
"@module-federation/sdk@npm:0.17.1":
version: 0.17.1
resolution: "@module-federation/sdk@npm:0.17.1"
checksum: 10/daaaa49ed900c00a69641130cf673ad5d5b8623d82fb4bd03a67c839a6da760a0a5ae29b836ba66eeb95ee5392e558588ffd987a2c00b05c2b0a7c5039ed042d
languageName: node
linkType: hard
"@module-federation/webpack-bundler-runtime@npm:0.18.0":
version: 0.18.0
resolution: "@module-federation/webpack-bundler-runtime@npm:0.18.0"
"@module-federation/webpack-bundler-runtime@npm:0.17.1":
version: 0.17.1
resolution: "@module-federation/webpack-bundler-runtime@npm:0.17.1"
dependencies:
"@module-federation/runtime": "npm:0.18.0"
"@module-federation/sdk": "npm:0.18.0"
checksum: 10/c80f26e02d497948a0864283bedf13118d5c188ac8165e71edce5da72776091db6da2dc5da5d47a53fbb6914bfbff1ddfce16a6b9c18485a9a41a04bc4060e34
"@module-federation/runtime": "npm:0.17.1"
"@module-federation/sdk": "npm:0.17.1"
checksum: 10/72e5030529dbc53df6271fa78bdb63976d0601fe9fde5105f8a7325e0fa296bc35277b9b084e52995cd314b89e12d33f8b869c1d63a13231c2948d4c741e72fd
languageName: node
linkType: hard
@@ -3990,92 +3990,92 @@ __metadata:
languageName: node
linkType: hard
"@rspack/binding-darwin-arm64@npm:1.5.1":
version: 1.5.1
resolution: "@rspack/binding-darwin-arm64@npm:1.5.1"
"@rspack/binding-darwin-arm64@npm:1.4.11":
version: 1.4.11
resolution: "@rspack/binding-darwin-arm64@npm:1.4.11"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard
"@rspack/binding-darwin-x64@npm:1.5.1":
version: 1.5.1
resolution: "@rspack/binding-darwin-x64@npm:1.5.1"
"@rspack/binding-darwin-x64@npm:1.4.11":
version: 1.4.11
resolution: "@rspack/binding-darwin-x64@npm:1.4.11"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard
"@rspack/binding-linux-arm64-gnu@npm:1.5.1":
version: 1.5.1
resolution: "@rspack/binding-linux-arm64-gnu@npm:1.5.1"
"@rspack/binding-linux-arm64-gnu@npm:1.4.11":
version: 1.4.11
resolution: "@rspack/binding-linux-arm64-gnu@npm:1.4.11"
conditions: os=linux & cpu=arm64 & libc=glibc
languageName: node
linkType: hard
"@rspack/binding-linux-arm64-musl@npm:1.5.1":
version: 1.5.1
resolution: "@rspack/binding-linux-arm64-musl@npm:1.5.1"
"@rspack/binding-linux-arm64-musl@npm:1.4.11":
version: 1.4.11
resolution: "@rspack/binding-linux-arm64-musl@npm:1.4.11"
conditions: os=linux & cpu=arm64 & libc=musl
languageName: node
linkType: hard
"@rspack/binding-linux-x64-gnu@npm:1.5.1":
version: 1.5.1
resolution: "@rspack/binding-linux-x64-gnu@npm:1.5.1"
"@rspack/binding-linux-x64-gnu@npm:1.4.11":
version: 1.4.11
resolution: "@rspack/binding-linux-x64-gnu@npm:1.4.11"
conditions: os=linux & cpu=x64 & libc=glibc
languageName: node
linkType: hard
"@rspack/binding-linux-x64-musl@npm:1.5.1":
version: 1.5.1
resolution: "@rspack/binding-linux-x64-musl@npm:1.5.1"
"@rspack/binding-linux-x64-musl@npm:1.4.11":
version: 1.4.11
resolution: "@rspack/binding-linux-x64-musl@npm:1.4.11"
conditions: os=linux & cpu=x64 & libc=musl
languageName: node
linkType: hard
"@rspack/binding-wasm32-wasi@npm:1.5.1":
version: 1.5.1
resolution: "@rspack/binding-wasm32-wasi@npm:1.5.1"
"@rspack/binding-wasm32-wasi@npm:1.4.11":
version: 1.4.11
resolution: "@rspack/binding-wasm32-wasi@npm:1.4.11"
dependencies:
"@napi-rs/wasm-runtime": "npm:^1.0.1"
conditions: cpu=wasm32
languageName: node
linkType: hard
"@rspack/binding-win32-arm64-msvc@npm:1.5.1":
version: 1.5.1
resolution: "@rspack/binding-win32-arm64-msvc@npm:1.5.1"
"@rspack/binding-win32-arm64-msvc@npm:1.4.11":
version: 1.4.11
resolution: "@rspack/binding-win32-arm64-msvc@npm:1.4.11"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard
"@rspack/binding-win32-ia32-msvc@npm:1.5.1":
version: 1.5.1
resolution: "@rspack/binding-win32-ia32-msvc@npm:1.5.1"
"@rspack/binding-win32-ia32-msvc@npm:1.4.11":
version: 1.4.11
resolution: "@rspack/binding-win32-ia32-msvc@npm:1.4.11"
conditions: os=win32 & cpu=ia32
languageName: node
linkType: hard
"@rspack/binding-win32-x64-msvc@npm:1.5.1":
version: 1.5.1
resolution: "@rspack/binding-win32-x64-msvc@npm:1.5.1"
"@rspack/binding-win32-x64-msvc@npm:1.4.11":
version: 1.4.11
resolution: "@rspack/binding-win32-x64-msvc@npm:1.4.11"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard
"@rspack/binding@npm:1.5.1":
version: 1.5.1
resolution: "@rspack/binding@npm:1.5.1"
"@rspack/binding@npm:1.4.11":
version: 1.4.11
resolution: "@rspack/binding@npm:1.4.11"
dependencies:
"@rspack/binding-darwin-arm64": "npm:1.5.1"
"@rspack/binding-darwin-x64": "npm:1.5.1"
"@rspack/binding-linux-arm64-gnu": "npm:1.5.1"
"@rspack/binding-linux-arm64-musl": "npm:1.5.1"
"@rspack/binding-linux-x64-gnu": "npm:1.5.1"
"@rspack/binding-linux-x64-musl": "npm:1.5.1"
"@rspack/binding-wasm32-wasi": "npm:1.5.1"
"@rspack/binding-win32-arm64-msvc": "npm:1.5.1"
"@rspack/binding-win32-ia32-msvc": "npm:1.5.1"
"@rspack/binding-win32-x64-msvc": "npm:1.5.1"
"@rspack/binding-darwin-arm64": "npm:1.4.11"
"@rspack/binding-darwin-x64": "npm:1.4.11"
"@rspack/binding-linux-arm64-gnu": "npm:1.4.11"
"@rspack/binding-linux-arm64-musl": "npm:1.4.11"
"@rspack/binding-linux-x64-gnu": "npm:1.4.11"
"@rspack/binding-linux-x64-musl": "npm:1.4.11"
"@rspack/binding-wasm32-wasi": "npm:1.4.11"
"@rspack/binding-win32-arm64-msvc": "npm:1.4.11"
"@rspack/binding-win32-ia32-msvc": "npm:1.4.11"
"@rspack/binding-win32-x64-msvc": "npm:1.4.11"
dependenciesMeta:
"@rspack/binding-darwin-arm64":
optional: true
@@ -4097,23 +4097,23 @@ __metadata:
optional: true
"@rspack/binding-win32-x64-msvc":
optional: true
checksum: 10/a6756a35bda55fd9e21b1ce142ca18e228d92832dc213027a19314981f8f12e6510dd862a9724ee96dee61755b3dd30ce73b2bb117d150e9f5ce73ba8fe4b57a
checksum: 10/8bb94774204f41888ff442afec06f019d008abba79964b74d566acf64f7216a148a1842f90c44b3bf680e69b697d8e5cd0f1cca6fd0b8a94df5f97c2a3f05510
languageName: node
linkType: hard
"@rspack/core@npm:1.5.1":
version: 1.5.1
resolution: "@rspack/core@npm:1.5.1"
"@rspack/core@npm:1.4.11":
version: 1.4.11
resolution: "@rspack/core@npm:1.4.11"
dependencies:
"@module-federation/runtime-tools": "npm:0.18.0"
"@rspack/binding": "npm:1.5.1"
"@module-federation/runtime-tools": "npm:0.17.1"
"@rspack/binding": "npm:1.4.11"
"@rspack/lite-tapable": "npm:1.0.1"
peerDependencies:
"@swc/helpers": ">=0.5.1"
peerDependenciesMeta:
"@swc/helpers":
optional: true
checksum: 10/b7a6269d5bdbcad140d172ebe951f4693711573d4f38e4c676c250a9cc6c1bdf602ad5187eeacc07ff12b74d510b746c92e3f112c8ab4dca46846c595d2876b0
checksum: 10/77d463bd90feb2d24f7bc56df198f0b7ad310a9eb676070eac8d78014d151e783943c5b44c64700a51a36708c626a341eeaa9b3287e358616d09dfe25ab04e77
languageName: node
linkType: hard
@@ -9377,7 +9377,7 @@ __metadata:
"@octokit/rest": "npm:22.0.0"
"@replit/codemirror-indentation-markers": "npm:6.5.3"
"@rsdoctor/rspack-plugin": "npm:1.2.3"
"@rspack/core": "npm:1.5.1"
"@rspack/core": "npm:1.4.11"
"@rspack/dev-server": "npm:1.1.4"
"@shoelace-style/shoelace": "npm:2.20.1"
"@swc/helpers": "npm:0.5.17"
@@ -9466,7 +9466,7 @@ __metadata:
lodash.template: "npm:4.5.0"
luxon: "npm:3.7.1"
map-stream: "npm:0.0.7"
marked: "npm:16.2.1"
marked: "npm:16.2.0"
memoize-one: "npm:6.0.0"
node-vibrant: "npm:4.0.3"
object-hash: "npm:3.0.0"
@@ -11137,12 +11137,12 @@ __metadata:
languageName: node
linkType: hard
"marked@npm:16.2.1":
version: 16.2.1
resolution: "marked@npm:16.2.1"
"marked@npm:16.2.0":
version: 16.2.0
resolution: "marked@npm:16.2.0"
bin:
marked: bin/marked.js
checksum: 10/67e911a7dd416869649dee18dc4a9683c0ccd8e72ba0fee3b3f578f857416e69780013e9d63762c600e6f9cf997c5af9fa0507a2053f8e65d39c5459c245c0cd
checksum: 10/0a73dcfbe500514d2f1106da99708beed8a31de586e2826e1aa47ca0e0a4850b1e9598569b09d5366d4f4dee2d279a13f32616ed1ee75c832068eb7dd660f66f
languageName: node
linkType: hard