From c2aeeaa6e5c3025603b88e5ecbef310acec54e35 Mon Sep 17 00:00:00 2001 From: G Johansson Date: Mon, 11 Mar 2024 19:49:02 +0000 Subject: [PATCH] Add default code to alarm_control_panel --- src/data/entity_registry.ts | 6 +++++ .../entity-registry-settings-editor.ts | 27 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/data/entity_registry.ts b/src/data/entity_registry.ts index 2ebfd157785f..02b72bf47782 100644 --- a/src/data/entity_registry.ts +++ b/src/data/entity_registry.ts @@ -96,6 +96,10 @@ export interface LockEntityOptions { default_code?: string | null; } +export interface AlarmControlPanelEntityOptions { + default_code?: string | null; +} + export interface WeatherEntityOptions { precipitation_unit?: string | null; pressure_unit?: string | null; @@ -112,6 +116,7 @@ export interface SwitchAsXEntityOptions { export interface EntityRegistryOptions { number?: NumberEntityOptions; sensor?: SensorEntityOptions; + alarm_control_panel?: AlarmControlPanelEntityOptions; lock?: LockEntityOptions; weather?: WeatherEntityOptions; light?: LightEntityOptions; @@ -134,6 +139,7 @@ export interface EntityRegistryEntryUpdateParams { | SensorEntityOptions | NumberEntityOptions | LockEntityOptions + | AlarmControlPanelEntityOptions | WeatherEntityOptions | LightEntityOptions; aliases?: string[]; diff --git a/src/panels/config/entities/entity-registry-settings-editor.ts b/src/panels/config/entities/entity-registry-settings-editor.ts index b4e8edd88573..a63850941ac4 100644 --- a/src/panels/config/entities/entity-registry-settings-editor.ts +++ b/src/panels/config/entities/entity-registry-settings-editor.ts @@ -59,6 +59,7 @@ import { updateDeviceRegistryEntry, } from "../../../data/device_registry"; import { + AlarmControlPanelEntityOptions, EntityRegistryEntry, EntityRegistryEntryUpdateParams, ExtEntityRegistryEntry, @@ -257,6 +258,10 @@ export class EntityRegistrySettingsEditor extends LitElement { this._defaultCode = this.entry.options?.lock?.default_code; } + if (domain === "alarm_control_panel") { + this._defaultCode = this.entry.options?.alarm_control_panel?.default_code; + } + if (domain === "weather") { const stateObj: HassEntity | undefined = this.hass.states[this.entry.entity_id]; @@ -583,6 +588,19 @@ export class EntityRegistrySettingsEditor extends LitElement { > ` : ""} + ${domain === "alarm_control_panel" + ? html` + + ` + : ""} ${domain === "sensor" && this._deviceClass && stateObj?.attributes.unit_of_measurement && @@ -1071,6 +1089,15 @@ export class EntityRegistrySettingsEditor extends LitElement { params.options = this.entry.options?.[domain] || {}; (params.options as LockEntityOptions).default_code = this._defaultCode; } + if ( + domain === "alarm_control_panel" && + this.entry.options?.[domain]?.default_code !== this._defaultCode + ) { + params.options_domain = domain; + params.options = this.entry.options?.[domain] || {}; + (params.options as AlarmControlPanelEntityOptions).default_code = + this._defaultCode; + } if ( domain === "weather" && (stateObj?.attributes?.precipitation_unit !== this._precipitation_unit ||