Compare commits

...

1 Commits

Author SHA1 Message Date
Paul Bottein
90e807009d Improve energy settings confirmation dialogs 2026-03-17 18:50:07 +01:00
8 changed files with 118 additions and 46 deletions

View File

@@ -123,9 +123,9 @@ export class EnergyBatterySettings extends LitElement {
></ha-icon-button>
<ha-icon-button
.label=${this.hass.localize(
"ui.panel.config.energy.battery.delete_battery_system"
"ui.panel.config.energy.battery.remove_battery_system"
)}
@click=${this._deleteSource}
@click=${this._removeSource}
.path=${mdiDelete}
></ha-icon-button>
</div>
@@ -184,13 +184,20 @@ export class EnergyBatterySettings extends LitElement {
});
}
private async _deleteSource(ev) {
const sourceToDelete: BatterySourceTypeEnergyPreference =
private async _removeSource(ev) {
const sourceToRemove: BatterySourceTypeEnergyPreference =
ev.currentTarget.closest(".row").source;
if (
!(await showConfirmationDialog(this, {
title: this.hass.localize("ui.panel.config.energy.delete_source"),
title: this.hass.localize(
"ui.panel.config.energy.battery.remove_battery_system_title"
),
text: this.hass.localize(
"ui.panel.config.energy.battery.remove_battery_system_text"
),
confirmText: this.hass.localize("ui.common.remove"),
destructive: true,
}))
) {
return;
@@ -200,7 +207,7 @@ export class EnergyBatterySettings extends LitElement {
await this._savePreferences({
...this.preferences,
energy_sources: this.preferences.energy_sources.filter(
(source) => source !== sourceToDelete
(source) => source !== sourceToRemove
),
});
} catch (err: any) {

View File

@@ -114,8 +114,8 @@ export class EnergyDeviceSettingsWater extends LitElement {
.path=${mdiPencil}
></ha-icon-button>
<ha-icon-button
.label=${this.hass.localize("ui.common.delete")}
@click=${this._deleteDevice}
.label=${this.hass.localize("ui.common.remove")}
@click=${this._removeDevice}
.device=${device}
.path=${mdiDelete}
></ha-icon-button>
@@ -207,13 +207,20 @@ export class EnergyDeviceSettingsWater extends LitElement {
});
}
private async _deleteDevice(ev) {
const deviceToDelete: DeviceConsumptionEnergyPreference =
private async _removeDevice(ev) {
const deviceToRemove: DeviceConsumptionEnergyPreference =
ev.currentTarget.device;
if (
!(await showConfirmationDialog(this, {
title: this.hass.localize("ui.panel.config.energy.delete_source"),
title: this.hass.localize(
"ui.panel.config.energy.device_consumption_water.remove_device_title"
),
text: this.hass.localize(
"ui.panel.config.energy.device_consumption_water.remove_device_text"
),
confirmText: this.hass.localize("ui.common.remove"),
destructive: true,
}))
) {
return;
@@ -224,7 +231,7 @@ export class EnergyDeviceSettingsWater extends LitElement {
...this.preferences,
device_consumption_water:
this.preferences.device_consumption_water.filter(
(device) => device !== deviceToDelete
(device) => device !== deviceToRemove
),
};
this._sanitizeParents(newPrefs);

View File

@@ -114,8 +114,8 @@ export class EnergyDeviceSettings extends LitElement {
.path=${mdiPencil}
></ha-icon-button>
<ha-icon-button
.label=${this.hass.localize("ui.common.delete")}
@click=${this._deleteDevice}
.label=${this.hass.localize("ui.common.remove")}
@click=${this._removeDevice}
.device=${device}
.path=${mdiDelete}
></ha-icon-button>
@@ -204,13 +204,20 @@ export class EnergyDeviceSettings extends LitElement {
});
}
private async _deleteDevice(ev) {
const deviceToDelete: DeviceConsumptionEnergyPreference =
private async _removeDevice(ev) {
const deviceToRemove: DeviceConsumptionEnergyPreference =
ev.currentTarget.device;
if (
!(await showConfirmationDialog(this, {
title: this.hass.localize("ui.panel.config.energy.delete_source"),
title: this.hass.localize(
"ui.panel.config.energy.device_consumption.remove_device_title"
),
text: this.hass.localize(
"ui.panel.config.energy.device_consumption.remove_device_text"
),
confirmText: this.hass.localize("ui.common.remove"),
destructive: true,
}))
) {
return;
@@ -220,7 +227,7 @@ export class EnergyDeviceSettings extends LitElement {
const newPrefs = {
...this.preferences,
device_consumption: this.preferences.device_consumption.filter(
(device) => device !== deviceToDelete
(device) => device !== deviceToRemove
),
};
this._sanitizeParents(newPrefs);

View File

@@ -111,9 +111,9 @@ export class EnergyGasSettings extends LitElement {
></ha-icon-button>
<ha-icon-button
.label=${this.hass.localize(
"ui.panel.config.energy.gas.delete_gas_source"
"ui.panel.config.energy.gas.remove_gas_source"
)}
@click=${this._deleteSource}
@click=${this._removeSource}
.path=${mdiDelete}
></ha-icon-button>
</div>
@@ -184,13 +184,20 @@ export class EnergyGasSettings extends LitElement {
});
}
private async _deleteSource(ev) {
const sourceToDelete: GasSourceTypeEnergyPreference =
private async _removeSource(ev) {
const sourceToRemove: GasSourceTypeEnergyPreference =
ev.currentTarget.closest(".row").source;
if (
!(await showConfirmationDialog(this, {
title: this.hass.localize("ui.panel.config.energy.delete_source"),
title: this.hass.localize(
"ui.panel.config.energy.gas.remove_gas_source_title"
),
text: this.hass.localize(
"ui.panel.config.energy.gas.remove_gas_source_text"
),
confirmText: this.hass.localize("ui.common.remove"),
destructive: true,
}))
) {
return;
@@ -200,7 +207,7 @@ export class EnergyGasSettings extends LitElement {
await this._savePreferences({
...this.preferences,
energy_sources: this.preferences.energy_sources.filter(
(source) => source !== sourceToDelete
(source) => source !== sourceToRemove
),
});
} catch (err: any) {

View File

@@ -149,9 +149,9 @@ export class EnergyGridSettings extends LitElement {
></ha-icon-button>
<ha-icon-button
.label=${this.hass.localize(
"ui.panel.config.energy.grid.delete_connection"
"ui.panel.config.energy.grid.remove_connection"
)}
@click=${this._deleteSource}
@click=${this._removeSource}
.path=${mdiDelete}
></ha-icon-button>
</div>
@@ -248,7 +248,14 @@ export class EnergyGridSettings extends LitElement {
const entryId = ev.currentTarget.closest(".row").entry.entry_id;
if (
!(await showConfirmationDialog(this, {
title: this.hass.localize("ui.panel.config.energy.delete_integration"),
title: this.hass.localize(
"ui.panel.config.energy.grid.delete_co2_signal_title"
),
text: this.hass.localize(
"ui.panel.config.energy.grid.delete_co2_signal_text"
),
confirmText: this.hass.localize("ui.common.delete"),
destructive: true,
}))
) {
return;
@@ -302,13 +309,20 @@ export class EnergyGridSettings extends LitElement {
});
}
private async _deleteSource(ev) {
private async _removeSource(ev) {
const row = ev.currentTarget.closest(".row");
const sourceIndex: number = row.sourceIndex;
if (
!(await showConfirmationDialog(this, {
title: this.hass.localize("ui.panel.config.energy.delete_source"),
title: this.hass.localize(
"ui.panel.config.energy.grid.remove_connection_title"
),
text: this.hass.localize(
"ui.panel.config.energy.grid.remove_connection_text"
),
confirmText: this.hass.localize("ui.common.remove"),
destructive: true,
}))
) {
return;

View File

@@ -120,9 +120,9 @@ export class EnergySolarSettings extends LitElement {
: ""}
<ha-icon-button
.label=${this.hass.localize(
"ui.panel.config.energy.solar.delete_solar_production"
"ui.panel.config.energy.solar.remove_solar_production"
)}
@click=${this._deleteSource}
@click=${this._removeSource}
.path=${mdiDelete}
></ha-icon-button>
</div>
@@ -187,13 +187,20 @@ export class EnergySolarSettings extends LitElement {
});
}
private async _deleteSource(ev) {
const sourceToDelete: SolarSourceTypeEnergyPreference =
private async _removeSource(ev) {
const sourceToRemove: SolarSourceTypeEnergyPreference =
ev.currentTarget.closest(".row").source;
if (
!(await showConfirmationDialog(this, {
title: this.hass.localize("ui.panel.config.energy.delete_source"),
title: this.hass.localize(
"ui.panel.config.energy.solar.remove_solar_production_title"
),
text: this.hass.localize(
"ui.panel.config.energy.solar.remove_solar_production_text"
),
confirmText: this.hass.localize("ui.common.remove"),
destructive: true,
}))
) {
return;
@@ -203,7 +210,7 @@ export class EnergySolarSettings extends LitElement {
await this._savePreferences({
...this.preferences,
energy_sources: this.preferences.energy_sources.filter(
(source) => source !== sourceToDelete
(source) => source !== sourceToRemove
),
});
} catch (err: any) {

View File

@@ -110,9 +110,9 @@ export class EnergyWaterSettings extends LitElement {
></ha-icon-button>
<ha-icon-button
.label=${this.hass.localize(
"ui.panel.config.energy.water.delete_water_source"
"ui.panel.config.energy.water.remove_water_source"
)}
@click=${this._deleteSource}
@click=${this._removeSource}
.path=${mdiDelete}
></ha-icon-button>
</div>
@@ -173,13 +173,20 @@ export class EnergyWaterSettings extends LitElement {
});
}
private async _deleteSource(ev) {
const sourceToDelete: WaterSourceTypeEnergyPreference =
private async _removeSource(ev) {
const sourceToRemove: WaterSourceTypeEnergyPreference =
ev.currentTarget.closest(".row").source;
if (
!(await showConfirmationDialog(this, {
title: this.hass.localize("ui.panel.config.energy.delete_source"),
title: this.hass.localize(
"ui.panel.config.energy.water.remove_water_source_title"
),
text: this.hass.localize(
"ui.panel.config.energy.water.remove_water_source_text"
),
confirmText: this.hass.localize("ui.common.remove"),
destructive: true,
}))
) {
return;
@@ -189,7 +196,7 @@ export class EnergyWaterSettings extends LitElement {
await this._savePreferences({
...this.preferences,
energy_sources: this.preferences.energy_sources.filter(
(source) => source !== sourceToDelete
(source) => source !== sourceToRemove
),
});
} catch (err: any) {

View File

@@ -3862,10 +3862,14 @@
"grid_connections": "Grid connections",
"add_connection": "Add grid connection",
"edit_connection": "Edit grid connection",
"delete_connection": "Delete grid connection",
"remove_connection": "Remove grid connection",
"grid_carbon_footprint": "Grid carbon footprint",
"remove_co2_signal": "Remove Electricity Maps integration",
"add_co2_signal": "Add Electricity Maps integration",
"delete_co2_signal_title": "Delete Electricity Maps integration",
"delete_co2_signal_text": "This will delete the integration and all entities it provides.",
"remove_connection_title": "Remove grid connection",
"remove_connection_text": "This will remove the grid connection from your energy configuration.",
"dialog": {
"header": "Configure grid connection",
"energy": "Energy",
@@ -3922,8 +3926,10 @@
"learn_more": "More information on how to get started",
"solar_production": "Solar production",
"edit_solar_production": "Edit solar production",
"delete_solar_production": "Remove solar production",
"remove_solar_production": "Remove solar production",
"add_solar_production": "Add solar production",
"remove_solar_production_title": "Remove solar production",
"remove_solar_production_text": "This will remove the solar production source from your energy configuration.",
"stat_production": "Your solar energy production",
"stat_return_to_grid": "Solar energy returned to the grid",
"stat_predicted_production": "Prediction of your solar energy production",
@@ -3945,8 +3951,10 @@
"learn_more": "More information on how to get started",
"battery_systems": "Battery systems",
"edit_battery_system": "Edit battery system",
"delete_battery_system": "Remove battery system",
"remove_battery_system": "Remove battery system",
"add_battery_system": "Add battery system",
"remove_battery_system_title": "Remove battery system",
"remove_battery_system_text": "This will remove the battery system from your energy configuration.",
"dialog": {
"header": "Configure battery system",
"energy_helper_into": "Pick a sensor that measures the electricity flowing into the battery in either of {unit}.",
@@ -3972,8 +3980,10 @@
"learn_more": "More information on how to get started",
"gas_consumption": "Gas consumption",
"edit_gas_source": "Edit gas source",
"delete_gas_source": "Remove gas source",
"remove_gas_source": "Remove gas source",
"add_gas_source": "Add gas source",
"remove_gas_source_title": "Remove gas source",
"remove_gas_source_text": "This will remove the gas source from your energy configuration.",
"dialog": {
"header": "Configure gas consumption",
"paragraph": "Gas consumption is measured either as the volume of gas that flows to your home or as the amount of energy contained in the gas.",
@@ -4001,8 +4011,10 @@
"learn_more": "More information on how to get started",
"water_consumption": "Water consumption",
"edit_water_source": "Edit water source",
"delete_water_source": "Remove water source",
"remove_water_source": "Remove water source",
"add_water_source": "Add water source",
"remove_water_source_title": "Remove water source",
"remove_water_source_text": "This will remove the water source from your energy configuration.",
"dialog": {
"header": "Configure water consumption",
"paragraph": "Water consumption is the volume of water that flows to your home.",
@@ -4029,6 +4041,8 @@
"selected_stat": "Tracking energy for",
"devices": "Devices",
"add_device": "Add device",
"remove_device_title": "Remove device",
"remove_device_text": "This will remove the device from your energy configuration.",
"dialog": {
"header": "Add a device",
"display_name": "Display name",
@@ -4046,6 +4060,8 @@
"learn_more": "More information on how to get started",
"devices": "Devices",
"add_device": "Add device",
"remove_device_title": "Remove water device",
"remove_device_text": "This will remove the water device from your energy configuration.",
"dialog": {
"header": "Add a water device",
"display_name": "Display name",