diff --git a/src/panels/config/automation/trigger/types/ha-automation-trigger-geo_location.ts b/src/panels/config/automation/trigger/types/ha-automation-trigger-geo_location.ts
index ffb16e28ec..3b8dcb8e71 100644
--- a/src/panels/config/automation/trigger/types/ha-automation-trigger-geo_location.ts
+++ b/src/panels/config/automation/trigger/types/ha-automation-trigger-geo_location.ts
@@ -1,13 +1,12 @@
-import { css, html, LitElement } from "lit";
+import "../../../../../components/ha-form/ha-form";
+import { html, LitElement } from "lit";
import { customElement, property } from "lit/decorators";
+import memoizeOne from "memoize-one";
import { fireEvent } from "../../../../../common/dom/fire_event";
-import "../../../../../components/entity/ha-entity-picker";
-import type { HaRadio } from "../../../../../components/ha-radio";
+import { HaFormSchema } from "../../../../../components/ha-form/types";
import type { GeoLocationTrigger } from "../../../../../data/automation";
import type { HomeAssistant } from "../../../../../types";
-import { handleChangeEvent } from "../ha-automation-trigger-row";
-
-const includeDomains = ["zone"];
+import type { LocalizeFunc } from "../../../../../common/translations/localize";
@customElement("ha-automation-trigger-geo_location")
export class HaGeolocationTrigger extends LitElement {
@@ -15,6 +14,30 @@ export class HaGeolocationTrigger extends LitElement {
@property({ attribute: false }) public trigger!: GeoLocationTrigger;
+ private _schema = memoizeOne((localize: LocalizeFunc) => [
+ { name: "source", selector: { text: {} } },
+ { name: "zone", selector: { entity: { domain: "zone" } } },
+ {
+ name: "event",
+ type: "select",
+ required: true,
+ options: [
+ [
+ "enter",
+ localize(
+ "ui.panel.config.automation.editor.triggers.type.geo_location.enter"
+ ),
+ ],
+ [
+ "leave",
+ localize(
+ "ui.panel.config.automation.editor.triggers.type.geo_location.leave"
+ ),
+ ],
+ ],
+ },
+ ]);
+
public static get defaultConfig() {
return {
source: "",
@@ -24,86 +47,27 @@ export class HaGeolocationTrigger extends LitElement {
}
protected render() {
- const { source, zone, event } = this.trigger;
-
return html`
-
-
-
+ .computeLabel=${this._computeLabelCallback}
+ @value-changed=${this._valueChanged}
+ >
`;
}
private _valueChanged(ev: CustomEvent): void {
- handleChangeEvent(this, ev);
- }
-
- private _zonePicked(ev: CustomEvent) {
ev.stopPropagation();
- fireEvent(this, "value-changed", {
- value: { ...this.trigger, zone: ev.detail.value },
- });
+ const newTrigger = ev.detail.value;
+ fireEvent(this, "value-changed", { value: newTrigger });
}
- private _radioGroupPicked(ev: CustomEvent) {
- ev.stopPropagation();
- fireEvent(this, "value-changed", {
- value: {
- ...this.trigger,
- event: (ev.target as HaRadio).value,
- },
- });
- }
-
- static styles = css`
- label {
- display: flex;
- align-items: center;
- }
- `;
+ private _computeLabelCallback = (schema: HaFormSchema): string =>
+ this.hass.localize(
+ `ui.panel.config.automation.editor.triggers.type.geo_location.${schema.name}`
+ );
}
declare global {