diff --git a/src/components/ha-selector/ha-selector-timezone.ts b/src/components/ha-selector/ha-selector-timezone.ts
new file mode 100644
index 0000000000..6fa14a8294
--- /dev/null
+++ b/src/components/ha-selector/ha-selector-timezone.ts
@@ -0,0 +1,47 @@
+import { css, html, LitElement } from "lit";
+import { customElement, property } from "lit/decorators";
+import type { TimezoneSelector } from "../../data/selector";
+import type { HomeAssistant } from "../../types";
+import "../ha-timezone-picker";
+
+@customElement("ha-selector-timezone")
+export class HaTimezoneSelector extends LitElement {
+ @property({ attribute: false }) public hass!: HomeAssistant;
+
+ @property({ attribute: false }) public selector!: TimezoneSelector;
+
+ @property() public value?: string;
+
+ @property() public label?: string;
+
+ @property() public helper?: string;
+
+ @property({ type: Boolean }) public disabled = false;
+
+ @property({ type: Boolean }) public required = false;
+
+ protected render() {
+ return html`
+
+ `;
+ }
+
+ static styles = css`
+ ha-timezone-picker {
+ width: 100%;
+ }
+ `;
+}
+
+declare global {
+ interface HTMLElementTagNameMap {
+ "ha-selector-timezone": HaTimezoneSelector;
+ }
+}
diff --git a/src/components/ha-selector/ha-selector.ts b/src/components/ha-selector/ha-selector.ts
index 3487a6b21d..a9d7209219 100644
--- a/src/components/ha-selector/ha-selector.ts
+++ b/src/components/ha-selector/ha-selector.ts
@@ -52,6 +52,7 @@ const LOAD_ELEMENTS = {
icon: () => import("./ha-selector-icon"),
media: () => import("./ha-selector-media"),
theme: () => import("./ha-selector-theme"),
+ timezone: () => import("./ha-selector-timezone"),
button_toggle: () => import("./ha-selector-button-toggle"),
trigger: () => import("./ha-selector-trigger"),
tts: () => import("./ha-selector-tts"),
diff --git a/src/components/ha-timezone-picker.ts b/src/components/ha-timezone-picker.ts
index 31148502be..a63a5c0d81 100644
--- a/src/components/ha-timezone-picker.ts
+++ b/src/components/ha-timezone-picker.ts
@@ -28,10 +28,17 @@ export class HaTimeZonePicker extends LitElement {
@property() public label?: string;
+ @property() public helper?: string;
+
+ @property() public placeholder?: string;
+
@property({ type: Boolean }) public required = false;
@property({ type: Boolean, reflect: true }) public disabled = false;
+ @property({ type: Boolean, attribute: "hide-clear-icon" })
+ public hideClearIcon = false;
+
private _getTimezoneOptions = memoizeOne(getTimezoneOptions);
private _getItems = () => this._getTimezoneOptions();
@@ -56,14 +63,16 @@ export class HaTimeZonePicker extends LitElement {
"ui.components.timezone-picker.no_timezones"
) || "No time zones available"}
.label=${label}
+ .helper=${this.helper}
+ .placeholder=${this.placeholder}
.value=${this.value}
.valueRenderer=${this._valueRenderer}
.disabled=${this.disabled}
.required=${this.required}
.getItems=${this._getItems}
.searchKeys=${SEARCH_KEYS}
+ .hideClearIcon=${this.hideClearIcon}
@value-changed=${this._changed}
- hide-clear-icon
>
`;
}
diff --git a/src/data/selector.ts b/src/data/selector.ts
index c98ea94a74..265bae16ad 100644
--- a/src/data/selector.ts
+++ b/src/data/selector.ts
@@ -68,6 +68,7 @@ export type Selector =
| TemplateSelector
| ThemeSelector
| TimeSelector
+ | TimezoneSelector
| TriggerSelector
| TTSSelector
| TTSVoiceSelector
@@ -296,6 +297,10 @@ export interface LanguageSelector {
} | null;
}
+export interface TimezoneSelector {
+ timezone: {} | null;
+}
+
export interface LocationSelector {
location: {
radius?: boolean;
diff --git a/src/panels/config/core/ha-config-section-general.ts b/src/panels/config/core/ha-config-section-general.ts
index a15f37c3e9..240a77f642 100644
--- a/src/panels/config/core/ha-config-section-general.ts
+++ b/src/panels/config/core/ha-config-section-general.ts
@@ -106,6 +106,7 @@ class HaConfigSectionGeneral extends LitElement {
.disabled=${disabled}
.value=${this._timeZone}
@value-changed=${this._handleValueChanged}
+ hide-clear-icon
>
),
- ].map(([key, value]) => ({
- value: key,
- label: value,
- })),
- },
- },
- },
+ { name: "time_zone", selector: { timezone: {} } },
] as const satisfies readonly HaFormSchema[]
);
private _data = memoizeOne((config) => ({
clock_style: "digital",
clock_size: "small",
- time_zone: "auto",
time_format: "auto",
show_seconds: false,
no_background: false,
@@ -302,9 +282,6 @@ export class HuiClockCardEditor
}
private _valueChanged(ev: CustomEvent): void {
- if (ev.detail.value.time_zone === "auto") {
- delete ev.detail.value.time_zone;
- }
if (ev.detail.value.time_format === "auto") {
delete ev.detail.value.time_format;
}