${this.hass.localize(
@@ -673,6 +730,24 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
`
: nothing
}
+ ${
+ this.narrow || areasInOverflow
+ ? html`
+
+
+ ${this.hass.localize(
+ "ui.panel.config.devices.picker.bulk_actions.move_area"
+ )}
+
+
+
+ ${areaItems}
+ `
+ : nothing
+ }
`
: nothing}
${!this.scripts.length
@@ -1111,6 +1186,46 @@ ${rejected
});
}
+ private async _handleBulkArea(ev) {
+ const area = ev.currentTarget.value;
+ this._bulkAddArea(area);
+ }
+
+ private async _bulkAddArea(area: string) {
+ const promises: Promise
[] = [];
+ this._selected.forEach((entityId) => {
+ promises.push(
+ updateEntityRegistryEntry(this.hass, entityId, {
+ area_id: area,
+ })
+ );
+ });
+ const result = await Promise.allSettled(promises);
+ if (hasRejectedItems(result)) {
+ const rejected = rejectedItems(result);
+ showAlertDialog(this, {
+ title: this.hass.localize("ui.panel.config.common.multiselect.failed", {
+ number: rejected.length,
+ }),
+ text: html`
+${rejected
+ .map((r) => r.reason.message || r.reason.code || r.reason)
+ .join("\r\n")}
`,
+ });
+ }
+ }
+
+ private async _bulkCreateArea() {
+ showAreaRegistryDetailDialog(this, {
+ createEntry: async (values) => {
+ const area = await createAreaRegistryEntry(this.hass, values);
+ this._bulkAddArea(area.area_id);
+ return area;
+ },
+ });
+ }
+
private _handleSortingChanged(ev: CustomEvent) {
this._activeSorting = ev.detail;
}