mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +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;
|
latitude: number;
|
||||||
longitude: number;
|
longitude: number;
|
||||||
elevation: number;
|
elevation: number;
|
||||||
|
radius: number;
|
||||||
unit_system: "metric" | "us_customary";
|
unit_system: "metric" | "us_customary";
|
||||||
time_zone: string;
|
time_zone: string;
|
||||||
external_url?: string | null;
|
external_url?: string | null;
|
||||||
|
@ -14,6 +14,7 @@ export interface Zone {
|
|||||||
export interface HomeZoneMutableParams {
|
export interface HomeZoneMutableParams {
|
||||||
latitude: number;
|
latitude: number;
|
||||||
longitude: number;
|
longitude: number;
|
||||||
|
radius: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ZoneMutableParams {
|
export interface ZoneMutableParams {
|
||||||
|
@ -14,7 +14,7 @@ const SCHEMA = [
|
|||||||
{
|
{
|
||||||
name: "location",
|
name: "location",
|
||||||
required: true,
|
required: true,
|
||||||
selector: { location: { radius: true, radius_readonly: true } },
|
selector: { location: { radius: true } },
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -35,6 +35,7 @@ class DialogHomeZoneDetail extends LitElement {
|
|||||||
this._data = {
|
this._data = {
|
||||||
latitude: this.hass.config.latitude,
|
latitude: this.hass.config.latitude,
|
||||||
longitude: this.hass.config.longitude,
|
longitude: this.hass.config.longitude,
|
||||||
|
radius: this.hass.config.radius,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,11 +74,6 @@ class DialogHomeZoneDetail extends LitElement {
|
|||||||
.computeLabel=${this._computeLabel}
|
.computeLabel=${this._computeLabel}
|
||||||
@value-changed=${this._valueChanged}
|
@value-changed=${this._valueChanged}
|
||||||
></ha-form>
|
></ha-form>
|
||||||
<p>
|
|
||||||
${this.hass!.localize(
|
|
||||||
"ui.panel.config.zone.detail.no_edit_home_zone_radius"
|
|
||||||
)}
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<mwc-button
|
<mwc-button
|
||||||
slot="primaryAction"
|
slot="primaryAction"
|
||||||
@ -95,7 +91,7 @@ class DialogHomeZoneDetail extends LitElement {
|
|||||||
location: {
|
location: {
|
||||||
latitude: data.latitude,
|
latitude: data.latitude,
|
||||||
longitude: data.longitude,
|
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 };
|
const value = { ...ev.detail.value };
|
||||||
value.latitude = value.location.latitude;
|
value.latitude = value.location.latitude;
|
||||||
value.longitude = value.location.longitude;
|
value.longitude = value.location.longitude;
|
||||||
|
value.radius = value.location.radius;
|
||||||
delete value.location;
|
delete value.location;
|
||||||
this._data = value;
|
this._data = value;
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,8 @@ export class HaConfigZone extends SubscribeMixin(LitElement) {
|
|||||||
: zoneRadiusColor,
|
: zoneRadiusColor,
|
||||||
location_editable:
|
location_editable:
|
||||||
entityState.entity_id === "zone.home" && this._canEditCore,
|
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) => ({
|
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;
|
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);
|
const entry = this._storageItems!.find((item) => item.id === ev.detail.id);
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
return;
|
return;
|
||||||
@ -478,6 +485,7 @@ export class HaConfigZone extends SubscribeMixin(LitElement) {
|
|||||||
await saveCoreConfig(this.hass, {
|
await saveCoreConfig(this.hass, {
|
||||||
latitude: values.latitude,
|
latitude: values.latitude,
|
||||||
longitude: values.longitude,
|
longitude: values.longitude,
|
||||||
|
radius: values.radius,
|
||||||
});
|
});
|
||||||
this._zoomZone("zone.home");
|
this._zoomZone("zone.home");
|
||||||
}
|
}
|
||||||
|
@ -4168,8 +4168,7 @@
|
|||||||
"required_error_msg": "This field is required",
|
"required_error_msg": "This field is required",
|
||||||
"delete": "Delete",
|
"delete": "Delete",
|
||||||
"create": "Add",
|
"create": "Add",
|
||||||
"update": "Update",
|
"update": "Update"
|
||||||
"no_edit_home_zone_radius": "The radius of the home zone is not editable in the UI."
|
|
||||||
},
|
},
|
||||||
"core_location_dialog": "Home Assistant location"
|
"core_location_dialog": "Home Assistant location"
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user