diff --git a/src/panels/config/entities/editor-tabs/settings/entity-settings-helper-tab.ts b/src/panels/config/entities/editor-tabs/settings/entity-settings-helper-tab.ts index d63f58ce05..e2b0009362 100644 --- a/src/panels/config/entities/editor-tabs/settings/entity-settings-helper-tab.ts +++ b/src/panels/config/entities/editor-tabs/settings/entity-settings-helper-tab.ts @@ -4,6 +4,7 @@ import { customElement, property, query, state } from "lit/decorators"; import { isComponentLoaded } from "../../../../../common/config/is_component_loaded"; import { dynamicElement } from "../../../../../common/dom/dynamic-element-directive"; import { fireEvent } from "../../../../../common/dom/fire_event"; +import "../../../../../components/ha-button"; import type { ExtEntityRegistryEntry } from "../../../../../data/entity_registry"; import { removeEntityRegistryEntry } from "../../../../../data/entity_registry"; import { HELPERS_CRUD } from "../../../../../data/helpers_crud"; @@ -22,7 +23,6 @@ import "../../../helpers/forms/ha-schedule-form"; import "../../../helpers/forms/ha-timer-form"; import "../../../voice-assistants/entity-voice-settings"; import "../../entity-registry-settings-editor"; -import "../../../../../components/ha-button"; import type { EntityRegistrySettingsEditor } from "../../entity-registry-settings-editor"; @customElement("entity-settings-helper-tab") @@ -72,22 +72,28 @@ export class EntitySettingsHelperTab extends LitElement { ${this._error ? html`${this._error}` : ""} + ${this._item === null + ? html`${this.hass.localize( + "ui.dialogs.helper_settings.yaml_not_editable" + )}` + : nothing} ${!this._componentLoaded ? this.hass.localize( "ui.dialogs.helper_settings.platform_not_loaded", { platform: this.entry.platform } ) - : this._item === null - ? this.hass.localize("ui.dialogs.helper_settings.yaml_not_editable") - : html` - - ${dynamicElement(`ha-${this.entry.platform}-form`, { - hass: this.hass, - item: this._item, - entry: this.entry, - })} - - `} + : html` + + ${dynamicElement(`ha-${this.entry.platform}-form`, { + hass: this.hass, + item: this._item, + entry: this.entry, + disabled: this._item === null, + })} + + `} ${this._cameraPrefs diff --git a/src/panels/config/helpers/forms/ha-counter-form.ts b/src/panels/config/helpers/forms/ha-counter-form.ts index 79d6d3f2c4..3f289d673b 100644 --- a/src/panels/config/helpers/forms/ha-counter-form.ts +++ b/src/panels/config/helpers/forms/ha-counter-form.ts @@ -17,6 +17,8 @@ class HaCounterForm extends LitElement { @property({ type: Boolean }) public new = false; + @property({ type: Boolean }) public disabled = false; + private _item?: Partial; @state() private _name!: string; @@ -82,6 +84,7 @@ class HaCounterForm extends LitElement { "ui.dialogs.helper_settings.required_error_msg" )} dialogInitialFocus + .disabled=${this.disabled} >
diff --git a/src/panels/config/helpers/forms/ha-input_boolean-form.ts b/src/panels/config/helpers/forms/ha-input_boolean-form.ts index 51291300ae..221c258f5c 100644 --- a/src/panels/config/helpers/forms/ha-input_boolean-form.ts +++ b/src/panels/config/helpers/forms/ha-input_boolean-form.ts @@ -14,6 +14,8 @@ class HaInputBooleanForm extends LitElement { @property({ type: Boolean }) public new = false; + @property({ type: Boolean }) public disabled = false; + private _item?: InputBoolean; @state() private _name!: string; @@ -59,6 +61,7 @@ class HaInputBooleanForm extends LitElement { "ui.dialogs.helper_settings.required_error_msg" )} dialogInitialFocus + .disabled=${this.disabled} >
`; diff --git a/src/panels/config/helpers/forms/ha-input_button-form.ts b/src/panels/config/helpers/forms/ha-input_button-form.ts index 3ab2addb86..2f07f4a1d3 100644 --- a/src/panels/config/helpers/forms/ha-input_button-form.ts +++ b/src/panels/config/helpers/forms/ha-input_button-form.ts @@ -14,6 +14,8 @@ class HaInputButtonForm extends LitElement { @property({ type: Boolean }) public new = false; + @property({ type: Boolean }) public disabled = false; + @state() private _name!: string; @state() private _icon!: string; @@ -59,6 +61,7 @@ class HaInputButtonForm extends LitElement { "ui.dialogs.helper_settings.required_error_msg" )} dialogInitialFocus + .disabled=${this.disabled} >
`; diff --git a/src/panels/config/helpers/forms/ha-input_datetime-form.ts b/src/panels/config/helpers/forms/ha-input_datetime-form.ts index 23056b4ade..f808108001 100644 --- a/src/panels/config/helpers/forms/ha-input_datetime-form.ts +++ b/src/panels/config/helpers/forms/ha-input_datetime-form.ts @@ -17,6 +17,8 @@ class HaInputDateTimeForm extends LitElement { @property({ type: Boolean }) public new = false; + @property({ type: Boolean }) public disabled = false; + private _item?: InputDateTime; @state() private _name!: string; @@ -73,6 +75,7 @@ class HaInputDateTimeForm extends LitElement { "ui.dialogs.helper_settings.required_error_msg" )} dialogInitialFocus + .disabled=${this.disabled} >
${this.hass.localize("ui.dialogs.helper_settings.input_datetime.mode")}: @@ -97,6 +101,7 @@ class HaInputDateTimeForm extends LitElement { value="date" .checked=${this._mode === "date"} @change=${this._modeChanged} + .disabled=${this.disabled} > diff --git a/src/panels/config/helpers/forms/ha-input_number-form.ts b/src/panels/config/helpers/forms/ha-input_number-form.ts index 7444136ba2..c937e494f6 100644 --- a/src/panels/config/helpers/forms/ha-input_number-form.ts +++ b/src/panels/config/helpers/forms/ha-input_number-form.ts @@ -18,6 +18,8 @@ class HaInputNumberForm extends LitElement { @property({ type: Boolean }) public new = false; + @property({ type: Boolean }) public disabled = false; + private _item?: Partial; @state() private _name!: string; @@ -89,6 +91,7 @@ class HaInputNumberForm extends LitElement { "ui.dialogs.helper_settings.required_error_msg" )} dialogInitialFocus + .disabled=${this.disabled} > @@ -163,6 +171,7 @@ class HaInputNumberForm extends LitElement { .label=${this.hass!.localize( "ui.dialogs.helper_settings.input_number.step" )} + .disabled=${this.disabled} > diff --git a/src/panels/config/helpers/forms/ha-input_select-form.ts b/src/panels/config/helpers/forms/ha-input_select-form.ts index 2529db4ee0..b4de226113 100644 --- a/src/panels/config/helpers/forms/ha-input_select-form.ts +++ b/src/panels/config/helpers/forms/ha-input_select-form.ts @@ -23,6 +23,8 @@ class HaInputSelectForm extends LitElement { @property({ type: Boolean }) public new = false; + @property({ type: Boolean }) public disabled = false; + private _item?: InputSelect; @state() private _name!: string; @@ -86,6 +88,7 @@ class HaInputSelectForm extends LitElement { )} .configValue=${"name"} @input=${this._valueChanged} + .disabled=${this.disabled} >
${this.hass!.localize( "ui.dialogs.helper_settings.input_select.options" )}:
- + ${this._options.length ? repeat( @@ -124,6 +132,7 @@ class HaInputSelectForm extends LitElement { "ui.dialogs.helper_settings.input_select.remove_option" )} @click=${this._removeOption} + .disabled=${this.disabled} .path=${mdiDelete} > @@ -146,8 +155,13 @@ class HaInputSelectForm extends LitElement { "ui.dialogs.helper_settings.input_select.add_option" )} @keydown=${this._handleKeyAdd} + .disabled=${this.disabled} > - ${this.hass!.localize( "ui.dialogs.helper_settings.input_select.add" )} @@ -154,6 +161,7 @@ class HaInputTextForm extends LitElement { .helper=${this.hass!.localize( "ui.dialogs.helper_settings.input_text.pattern_helper" )} + .disabled=${this.disabled} > diff --git a/src/panels/config/helpers/forms/ha-schedule-form.ts b/src/panels/config/helpers/forms/ha-schedule-form.ts index 6bccf9c716..13b593888d 100644 --- a/src/panels/config/helpers/forms/ha-schedule-form.ts +++ b/src/panels/config/helpers/forms/ha-schedule-form.ts @@ -17,9 +17,9 @@ import "../../../../components/ha-textfield"; import type { Schedule, ScheduleDay } from "../../../../data/schedule"; import { weekdays } from "../../../../data/schedule"; import { TimeZone } from "../../../../data/translation"; -import { showScheduleBlockInfoDialog } from "./show-dialog-schedule-block-info"; import { haStyle } from "../../../../resources/styles"; import type { HomeAssistant } from "../../../../types"; +import { showScheduleBlockInfoDialog } from "./show-dialog-schedule-block-info"; const defaultFullCalendarConfig: CalendarOptions = { plugins: [timeGridPlugin, interactionPlugin], @@ -43,6 +43,8 @@ class HaScheduleForm extends LitElement { @property({ type: Boolean }) public new = false; + @property({ type: Boolean }) public disabled = false; + @state() private _name!: string; @state() private _icon!: string; @@ -132,6 +134,7 @@ class HaScheduleForm extends LitElement { "ui.dialogs.helper_settings.required_error_msg" )} dialogInitialFocus + .disabled=${this.disabled} > -
+ ${!this.disabled ? html`
` : nothing} `; } @@ -175,7 +179,9 @@ class HaScheduleForm extends LitElement { } protected firstUpdated(): void { - this._setupCalendar(); + if (!this.disabled) { + this._setupCalendar(); + } } private _setupCalendar(): void { diff --git a/src/panels/config/helpers/forms/ha-timer-form.ts b/src/panels/config/helpers/forms/ha-timer-form.ts index 236681051d..86bd916df2 100644 --- a/src/panels/config/helpers/forms/ha-timer-form.ts +++ b/src/panels/config/helpers/forms/ha-timer-form.ts @@ -1,18 +1,18 @@ import type { CSSResultGroup } from "lit"; import { css, html, LitElement, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; +import { createDurationData } from "../../../../common/datetime/create_duration_data"; import { fireEvent } from "../../../../common/dom/fire_event"; import "../../../../components/ha-checkbox"; +import "../../../../components/ha-duration-input"; +import type { HaDurationData } from "../../../../components/ha-duration-input"; import "../../../../components/ha-formfield"; import "../../../../components/ha-icon-picker"; -import "../../../../components/ha-duration-input"; import "../../../../components/ha-textfield"; +import type { ForDict } from "../../../../data/automation"; import type { DurationDict, Timer } from "../../../../data/timer"; import { haStyle } from "../../../../resources/styles"; import type { HomeAssistant } from "../../../../types"; -import { createDurationData } from "../../../../common/datetime/create_duration_data"; -import type { HaDurationData } from "../../../../components/ha-duration-input"; -import type { ForDict } from "../../../../data/automation"; @customElement("ha-timer-form") class HaTimerForm extends LitElement { @@ -20,6 +20,8 @@ class HaTimerForm extends LitElement { @property({ type: Boolean }) public new = false; + @property({ type: Boolean }) public disabled = false; + private _item?: Timer; @state() private _name!: string; @@ -77,6 +79,7 @@ class HaTimerForm extends LitElement { "ui.dialogs.helper_settings.required_error_msg" )} dialogInitialFocus + .disabled=${this.disabled} > @@ -130,6 +136,9 @@ class HaTimerForm extends LitElement { } private _toggleRestore() { + if (this.disabled) { + return; + } this._restore = !this._restore; fireEvent(this, "value-changed", { value: { ...this._item, restore: this._restore },