From 6d931b9e375a6bc6391b1f4c108f224f39a954d4 Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Wed, 7 May 2025 07:13:29 -0700 Subject: [PATCH] Add UoM to location selector (#25358) --- .../ha-selector/ha-selector-location.ts | 19 +++++++++++++++---- src/translations/en.json | 3 ++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/components/ha-selector/ha-selector-location.ts b/src/components/ha-selector/ha-selector-location.ts index c169d74e62..165fbcfa54 100644 --- a/src/components/ha-selector/ha-selector-location.ts +++ b/src/components/ha-selector/ha-selector-location.ts @@ -11,6 +11,7 @@ import type { SchemaUnion } from "../ha-form/types"; import type { MarkerLocation } from "../map/ha-locations-editor"; import "../map/ha-locations-editor"; import "../ha-form/ha-form"; +import type { LocalizeFunc } from "../../common/translations/localize"; @customElement("ha-selector-location") export class HaLocationSelector extends LitElement { @@ -27,7 +28,7 @@ export class HaLocationSelector extends LitElement { @property({ type: Boolean, reflect: true }) public disabled = false; private _schema = memoizeOne( - (radius?: boolean, radius_readonly?: boolean) => + (localize: LocalizeFunc, radius?: boolean, radius_readonly?: boolean) => [ { name: "", @@ -36,12 +37,12 @@ export class HaLocationSelector extends LitElement { { name: "latitude", required: true, - selector: { number: { step: "any" } }, + selector: { number: { step: "any", unit_of_measurement: "°" } }, }, { name: "longitude", required: true, - selector: { number: { step: "any" } }, + selector: { number: { step: "any", unit_of_measurement: "°" } }, }, ], }, @@ -52,7 +53,16 @@ export class HaLocationSelector extends LitElement { required: true, default: 1000, disabled: !!radius_readonly, - selector: { number: { min: 0, step: 1, mode: "box" } as const }, + selector: { + number: { + min: 0, + step: 1, + mode: "box", + unit_of_measurement: localize( + "ui.components.selectors.location.radius_meters" + ), + } as const, + }, } as const, ] : []), @@ -84,6 +94,7 @@ export class HaLocationSelector extends LitElement {