mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Make the radius of the home zone configurable (#21096)
This commit is contained in:
parent
bb3e8ae33d
commit
8759ed740a
@ -6,6 +6,7 @@ export interface ConfigUpdateValues {
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
elevation: number;
|
||||
radius: number;
|
||||
unit_system: "metric" | "us_customary";
|
||||
time_zone: string;
|
||||
external_url?: string | null;
|
||||
|
@ -14,6 +14,7 @@ export interface Zone {
|
||||
export interface HomeZoneMutableParams {
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
radius: number;
|
||||
}
|
||||
|
||||
export interface ZoneMutableParams {
|
||||
|
@ -14,7 +14,7 @@ const SCHEMA = [
|
||||
{
|
||||
name: "location",
|
||||
required: true,
|
||||
selector: { location: { radius: true, radius_readonly: true } },
|
||||
selector: { location: { radius: true } },
|
||||
},
|
||||
];
|
||||
|
||||
@ -35,6 +35,7 @@ class DialogHomeZoneDetail extends LitElement {
|
||||
this._data = {
|
||||
latitude: this.hass.config.latitude,
|
||||
longitude: this.hass.config.longitude,
|
||||
radius: this.hass.config.radius,
|
||||
};
|
||||
}
|
||||
|
||||
@ -73,11 +74,6 @@ class DialogHomeZoneDetail extends LitElement {
|
||||
.computeLabel=${this._computeLabel}
|
||||
@value-changed=${this._valueChanged}
|
||||
></ha-form>
|
||||
<p>
|
||||
${this.hass!.localize(
|
||||
"ui.panel.config.zone.detail.no_edit_home_zone_radius"
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
<mwc-button
|
||||
slot="primaryAction"
|
||||
@ -95,7 +91,7 @@ class DialogHomeZoneDetail extends LitElement {
|
||||
location: {
|
||||
latitude: data.latitude,
|
||||
longitude: data.longitude,
|
||||
radius: this.hass.states["zone.home"]?.attributes?.radius || 100,
|
||||
radius: data.radius || 100,
|
||||
},
|
||||
}));
|
||||
|
||||
@ -104,6 +100,7 @@ class DialogHomeZoneDetail extends LitElement {
|
||||
const value = { ...ev.detail.value };
|
||||
value.latitude = value.location.latitude;
|
||||
value.longitude = value.location.longitude;
|
||||
value.radius = value.location.radius;
|
||||
delete value.location;
|
||||
this._data = value;
|
||||
}
|
||||
|
@ -101,7 +101,8 @@ export class HaConfigZone extends SubscribeMixin(LitElement) {
|
||||
: zoneRadiusColor,
|
||||
location_editable:
|
||||
entityState.entity_id === "zone.home" && this._canEditCore,
|
||||
radius_editable: false,
|
||||
radius_editable:
|
||||
entityState.entity_id === "zone.home" && this._canEditCore,
|
||||
})
|
||||
);
|
||||
const storageLocations: MarkerLocation[] = storageItems.map((zone) => ({
|
||||
@ -381,8 +382,14 @@ export class HaConfigZone extends SubscribeMixin(LitElement) {
|
||||
});
|
||||
}
|
||||
|
||||
private _radiusUpdated(ev: CustomEvent) {
|
||||
private async _radiusUpdated(ev: CustomEvent) {
|
||||
this._activeEntry = ev.detail.id;
|
||||
if (ev.detail.id === "zone.home" && this._canEditCore) {
|
||||
await saveCoreConfig(this.hass, {
|
||||
radius: Math.round(ev.detail.radius),
|
||||
});
|
||||
return;
|
||||
}
|
||||
const entry = this._storageItems!.find((item) => item.id === ev.detail.id);
|
||||
if (!entry) {
|
||||
return;
|
||||
@ -478,6 +485,7 @@ export class HaConfigZone extends SubscribeMixin(LitElement) {
|
||||
await saveCoreConfig(this.hass, {
|
||||
latitude: values.latitude,
|
||||
longitude: values.longitude,
|
||||
radius: values.radius,
|
||||
});
|
||||
this._zoomZone("zone.home");
|
||||
}
|
||||
|
@ -4168,8 +4168,7 @@
|
||||
"required_error_msg": "This field is required",
|
||||
"delete": "Delete",
|
||||
"create": "Add",
|
||||
"update": "Update",
|
||||
"no_edit_home_zone_radius": "The radius of the home zone is not editable in the UI."
|
||||
"update": "Update"
|
||||
},
|
||||
"core_location_dialog": "Home Assistant location"
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user