Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/data/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/data/zone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface Zone {
export interface HomeZoneMutableParams {
latitude: number;
longitude: number;
radius: number;
}

export interface ZoneMutableParams {
Expand Down
11 changes: 4 additions & 7 deletions src/panels/config/zone/dialog-home-zone-detail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const SCHEMA = [
{
name: "location",
required: true,
selector: { location: { radius: true, radius_readonly: true } },
selector: { location: { radius: true } },
},
];

Expand All @@ -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,
};
}

Expand Down Expand Up @@ -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"
Expand All @@ -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,
},
}));

Expand All @@ -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;
}
Expand Down
12 changes: 10 additions & 2 deletions src/panels/config/zone/ha-config-zone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => ({
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");
}
Expand Down
3 changes: 1 addition & 2 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down