mirror of
https://github.com/home-assistant/frontend.git
synced 2026-02-15 07:25:54 +00:00
Use ValueChangedEvent instead of CustomEvent (#29399)
* Use ValueChangedEvent with generic type requested * Add more * Add * Add more
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
sortDeviceAutomations,
|
||||
} from "../../data/device/device_automation";
|
||||
import type { EntityRegistryEntry } from "../../data/entity/entity_registry";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../types";
|
||||
import "../ha-generic-picker";
|
||||
import "../ha-md-select";
|
||||
import "../ha-md-select-option";
|
||||
@@ -192,7 +192,7 @@ export abstract class HaDeviceAutomationPicker<
|
||||
this._renderEmpty = false;
|
||||
}
|
||||
|
||||
private _automationChanged(ev: CustomEvent<{ value: string }>) {
|
||||
private _automationChanged(ev: ValueChangedEvent<string>) {
|
||||
ev.stopPropagation();
|
||||
const value = ev.detail.value;
|
||||
if (!value || NO_AUTOMATION_KEY === value) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import { computeFloorName } from "../common/entity/compute_floor_name";
|
||||
import { getAreaContext } from "../common/entity/context/get_area_context";
|
||||
import type { FloorRegistryEntry } from "../data/floor_registry";
|
||||
import { getFloors } from "../panels/lovelace/strategies/areas/helpers/areas-strategy-helper";
|
||||
import type { HomeAssistant } from "../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../types";
|
||||
import "./ha-expansion-panel";
|
||||
import "./ha-floor-icon";
|
||||
import "./ha-items-display-editor";
|
||||
@@ -200,7 +200,7 @@ export class HaAreasFloorsDisplayEditor extends LitElement {
|
||||
fireEvent(this, "value-changed", { value: newValue });
|
||||
}
|
||||
|
||||
private async _areaDisplayChanged(ev: CustomEvent<{ value: DisplayValue }>) {
|
||||
private async _areaDisplayChanged(ev: ValueChangedEvent<DisplayValue>) {
|
||||
ev.stopPropagation();
|
||||
const value = ev.detail.value;
|
||||
const currentFloorId = (ev.currentTarget as any).floorId;
|
||||
|
||||
@@ -53,7 +53,7 @@ import {
|
||||
multiTermSortedSearch,
|
||||
type FuseWeightedKey,
|
||||
} from "../resources/fuseMultiTerm";
|
||||
import type { HomeAssistant } from "../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../types";
|
||||
import { brandsUrl } from "../util/brands-url";
|
||||
import type { HaDevicePickerDeviceFilterFunc } from "./device/ha-device-picker";
|
||||
import "./ha-generic-picker";
|
||||
@@ -403,7 +403,7 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
||||
`;
|
||||
}
|
||||
|
||||
private _targetPicked(ev: CustomEvent<{ value: string }>) {
|
||||
private _targetPicked(ev: ValueChangedEvent<string>) {
|
||||
ev.stopPropagation();
|
||||
const value = ev.detail.value;
|
||||
if (value.startsWith(CREATE_ID)) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import "../../../components/ha-date-input";
|
||||
import "../../../components/ha-time-input";
|
||||
import { setDateValue } from "../../../data/date";
|
||||
import { isUnavailableState, UNAVAILABLE } from "../../../data/entity/entity";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../types";
|
||||
|
||||
@customElement("more-info-date")
|
||||
class MoreInfoDate extends LitElement {
|
||||
@@ -31,7 +31,7 @@ class MoreInfoDate extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private _dateChanged(ev: CustomEvent<{ value: string }>): void {
|
||||
private _dateChanged(ev: ValueChangedEvent<string>): void {
|
||||
if (ev.detail.value) {
|
||||
setDateValue(this.hass!, this.stateObj!.entity_id, ev.detail.value);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import "../../../components/ha-date-input";
|
||||
import "../../../components/ha-time-input";
|
||||
import { setDateTimeValue } from "../../../data/datetime";
|
||||
import { isUnavailableState, UNAVAILABLE } from "../../../data/entity/entity";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../types";
|
||||
|
||||
@customElement("more-info-datetime")
|
||||
class MoreInfoDatetime extends LitElement {
|
||||
@@ -45,7 +45,7 @@ class MoreInfoDatetime extends LitElement {
|
||||
ev.stopPropagation();
|
||||
}
|
||||
|
||||
private _timeChanged(ev: CustomEvent<{ value: string }>): void {
|
||||
private _timeChanged(ev: ValueChangedEvent<string>): void {
|
||||
if (ev.detail.value) {
|
||||
const dateObj = new Date(this.stateObj!.state);
|
||||
const newTime = ev.detail.value.split(":").map(Number);
|
||||
@@ -55,7 +55,7 @@ class MoreInfoDatetime extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private _dateChanged(ev: CustomEvent<{ value: string }>): void {
|
||||
private _dateChanged(ev: ValueChangedEvent<string>): void {
|
||||
if (ev.detail.value) {
|
||||
const dateObj = new Date(this.stateObj!.state);
|
||||
const newDate = ev.detail.value.split("-").map(Number);
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
setInputDateTimeValue,
|
||||
stateToIsoDateString,
|
||||
} from "../../../data/input_datetime";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../types";
|
||||
|
||||
@customElement("more-info-input_datetime")
|
||||
class MoreInfoInputDatetime extends LitElement {
|
||||
@@ -55,7 +55,7 @@ class MoreInfoInputDatetime extends LitElement {
|
||||
ev.stopPropagation();
|
||||
}
|
||||
|
||||
private _timeChanged(ev: CustomEvent<{ value: string }>): void {
|
||||
private _timeChanged(ev: ValueChangedEvent<string>): void {
|
||||
setInputDateTimeValue(
|
||||
this.hass!,
|
||||
this.stateObj!.entity_id,
|
||||
@@ -66,7 +66,7 @@ class MoreInfoInputDatetime extends LitElement {
|
||||
);
|
||||
}
|
||||
|
||||
private _dateChanged(ev: CustomEvent<{ value: string }>): void {
|
||||
private _dateChanged(ev: ValueChangedEvent<string>): void {
|
||||
setInputDateTimeValue(
|
||||
this.hass!,
|
||||
this.stateObj!.entity_id,
|
||||
|
||||
@@ -5,7 +5,7 @@ import "../../../components/ha-date-input";
|
||||
import "../../../components/ha-time-input";
|
||||
import { isUnavailableState, UNAVAILABLE } from "../../../data/entity/entity";
|
||||
import { setTimeValue } from "../../../data/time";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../types";
|
||||
|
||||
@customElement("more-info-time")
|
||||
class MoreInfoTime extends LitElement {
|
||||
@@ -35,7 +35,7 @@ class MoreInfoTime extends LitElement {
|
||||
ev.stopPropagation();
|
||||
}
|
||||
|
||||
private _timeChanged(ev: CustomEvent<{ value: string }>): void {
|
||||
private _timeChanged(ev: ValueChangedEvent<string>): void {
|
||||
if (ev.detail.value) {
|
||||
setTimeValue(this.hass!, this.stateObj!.entity_id, ev.detail.value);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import {
|
||||
getPanelIconPath,
|
||||
getPanelTitle,
|
||||
} from "../../data/panel";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../types";
|
||||
import { showConfirmationDialog } from "../generic/show-dialog-box";
|
||||
|
||||
@customElement("dialog-edit-sidebar")
|
||||
@@ -206,7 +206,7 @@ class DialogEditSidebar extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private _changed(ev: CustomEvent<{ value: DisplayValue }>): void {
|
||||
private _changed(ev: ValueChangedEvent<DisplayValue>): void {
|
||||
const { order = [], hidden = [] } = ev.detail.value;
|
||||
this._order = [...order];
|
||||
this._hidden = [...hidden];
|
||||
|
||||
@@ -8,7 +8,7 @@ import "../../../../../components/ha-duration-input";
|
||||
import "../../../../../components/ha-formfield";
|
||||
import "../../../../../components/ha-textfield";
|
||||
import type { WaitForTriggerAction } from "../../../../../data/script";
|
||||
import type { HomeAssistant } from "../../../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../../../types";
|
||||
import "../../trigger/ha-automation-trigger";
|
||||
import type { ActionElement } from "../ha-automation-action-row";
|
||||
import { handleChangeEvent } from "../ha-automation-action-row";
|
||||
@@ -78,7 +78,7 @@ export class HaWaitForTriggerAction
|
||||
`;
|
||||
}
|
||||
|
||||
private _timeoutChanged(ev: CustomEvent<{ value: TimeChangedEvent }>): void {
|
||||
private _timeoutChanged(ev: ValueChangedEvent<TimeChangedEvent>): void {
|
||||
ev.stopPropagation();
|
||||
const value = ev.detail.value;
|
||||
fireEvent(this, "value-changed", {
|
||||
|
||||
@@ -114,7 +114,7 @@ import {
|
||||
} from "../../../data/trigger";
|
||||
import type { HassDialog } from "../../../dialogs/make-dialog-manager";
|
||||
import { KeyboardShortcutMixin } from "../../../mixins/keyboard-shortcut-mixin";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../types";
|
||||
import { isMac } from "../../../util/is_mac";
|
||||
import { showToast } from "../../../util/toast";
|
||||
import "./add-automation-element/ha-automation-add-from-target";
|
||||
@@ -1752,7 +1752,7 @@ class DialogAddAutomationElement
|
||||
this.closeDialog();
|
||||
}
|
||||
|
||||
private _selected(ev: CustomEvent<{ value: string }>) {
|
||||
private _selected(ev: ValueChangedEvent<string>) {
|
||||
let target: HassServiceTarget | undefined;
|
||||
if (
|
||||
this._tab === "targets" &&
|
||||
@@ -1766,7 +1766,7 @@ class DialogAddAutomationElement
|
||||
}
|
||||
|
||||
private _handleTargetSelected = (
|
||||
ev: CustomEvent<{ value: SingleHassServiceTarget }>
|
||||
ev: ValueChangedEvent<SingleHassServiceTarget>
|
||||
) => {
|
||||
this._targetItems = undefined;
|
||||
this._loadItemsError = false;
|
||||
|
||||
@@ -77,7 +77,12 @@ import "../../../layouts/hass-subpage";
|
||||
import { KeyboardShortcutMixin } from "../../../mixins/keyboard-shortcut-mixin";
|
||||
import { PreventUnsavedMixin } from "../../../mixins/prevent-unsaved-mixin";
|
||||
import { haStyle } from "../../../resources/styles";
|
||||
import type { Entries, HomeAssistant, Route } from "../../../types";
|
||||
import type {
|
||||
Entries,
|
||||
HomeAssistant,
|
||||
Route,
|
||||
ValueChangedEvent,
|
||||
} from "../../../types";
|
||||
import { isMac } from "../../../util/is_mac";
|
||||
import { showToast } from "../../../util/toast";
|
||||
import { showAssignCategoryDialog } from "../category/show-dialog-assign-category";
|
||||
@@ -753,7 +758,7 @@ export class HaAutomationEditor extends PreventUnsavedMixin(
|
||||
}
|
||||
}
|
||||
|
||||
private _valueChanged(ev: CustomEvent<{ value: AutomationConfig }>) {
|
||||
private _valueChanged(ev: ValueChangedEvent<AutomationConfig>) {
|
||||
ev.stopPropagation();
|
||||
|
||||
if (this._config) {
|
||||
|
||||
@@ -54,7 +54,7 @@ import {
|
||||
import { configEntriesContext } from "../../../data/context";
|
||||
import { getActionType, type Action } from "../../../data/script";
|
||||
import { SubscribeMixin } from "../../../mixins/subscribe-mixin";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../types";
|
||||
import { documentationUrl } from "../../../util/documentation-url";
|
||||
import { showToast } from "../../../util/toast";
|
||||
import "./action/ha-automation-action";
|
||||
@@ -383,7 +383,7 @@ export class HaManualAutomationEditor extends SubscribeMixin(LitElement) {
|
||||
this._sidebarElement?.focus();
|
||||
}
|
||||
|
||||
private _sidebarConfigChanged(ev: CustomEvent<{ value: SidebarConfig }>) {
|
||||
private _sidebarConfigChanged(ev: ValueChangedEvent<SidebarConfig>) {
|
||||
ev.stopPropagation();
|
||||
if (!this._sidebarConfig) {
|
||||
return;
|
||||
|
||||
@@ -28,7 +28,7 @@ import {
|
||||
sortWeekdays,
|
||||
} from "../../../../../data/backup";
|
||||
import type { SupervisorUpdateConfig } from "../../../../../data/supervisor/update";
|
||||
import type { HomeAssistant } from "../../../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../../../types";
|
||||
import { documentationUrl } from "../../../../../util/documentation-url";
|
||||
import "./ha-backup-config-retention";
|
||||
|
||||
@@ -405,7 +405,7 @@ class HaBackupConfigSchedule extends LitElement {
|
||||
});
|
||||
}
|
||||
|
||||
private _retentionChanged(ev: CustomEvent<{ value: Retention }>) {
|
||||
private _retentionChanged(ev: ValueChangedEvent<Retention>) {
|
||||
ev.stopPropagation();
|
||||
const retention = ev.detail.value;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
updateBackupConfig,
|
||||
} from "../../../data/backup";
|
||||
import "../../../layouts/hass-subpage";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../types";
|
||||
import { showConfirmationDialog } from "../../lovelace/custom-card-helpers";
|
||||
import "./components/config/ha-backup-config-retention";
|
||||
import "./components/ha-backup-data-picker";
|
||||
@@ -284,7 +284,7 @@ class HaConfigBackupDetails extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private _retentionChanged(ev: CustomEvent<{ value: Retention }>) {
|
||||
private _retentionChanged(ev: ValueChangedEvent<Retention>) {
|
||||
const retention = ev.detail.value;
|
||||
this._updateAgentConfig({
|
||||
retention,
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
saveAITaskPreferences,
|
||||
type AITaskPreferences,
|
||||
} from "../../../data/ai_task";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../types";
|
||||
import { brandsUrl } from "../../../util/brands-url";
|
||||
import { documentationUrl } from "../../../util/documentation-url";
|
||||
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||
@@ -137,7 +137,7 @@ export class AITaskPref extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private _handlePrefChange(ev: CustomEvent<{ value: string | undefined }>) {
|
||||
private _handlePrefChange(ev: ValueChangedEvent<string | undefined>) {
|
||||
const input = ev.target as HaEntityPicker;
|
||||
const key = input.dataset.name as keyof AITaskPreferences;
|
||||
const value = ev.detail.value || null;
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
import { getSensorDeviceClassConvertibleUnits } from "../../../../data/sensor";
|
||||
import type { HassDialog } from "../../../../dialogs/make-dialog-manager";
|
||||
import { haStyle, haStyleDialog } from "../../../../resources/styles";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../../types";
|
||||
import type { EnergySettingsBatteryDialogParams } from "./show-dialogs-energy";
|
||||
|
||||
const energyUnitClasses = ["energy"];
|
||||
@@ -361,11 +361,11 @@ export class DialogEnergyBatterySettings
|
||||
}
|
||||
}
|
||||
|
||||
private _statisticToChanged(ev: CustomEvent<{ value: string }>) {
|
||||
private _statisticToChanged(ev: ValueChangedEvent<string>) {
|
||||
this._source = { ...this._source!, stat_energy_to: ev.detail.value };
|
||||
}
|
||||
|
||||
private _statisticFromChanged(ev: CustomEvent<{ value: string }>) {
|
||||
private _statisticFromChanged(ev: ValueChangedEvent<string>) {
|
||||
this._source = { ...this._source!, stat_energy_from: ev.detail.value };
|
||||
}
|
||||
|
||||
@@ -376,26 +376,26 @@ export class DialogEnergyBatterySettings
|
||||
this._powerConfig = {};
|
||||
}
|
||||
|
||||
private _standardPowerChanged(ev: CustomEvent<{ value: string }>) {
|
||||
private _standardPowerChanged(ev: ValueChangedEvent<string>) {
|
||||
this._powerConfig = {
|
||||
stat_rate: ev.detail.value,
|
||||
};
|
||||
}
|
||||
|
||||
private _invertedPowerChanged(ev: CustomEvent<{ value: string }>) {
|
||||
private _invertedPowerChanged(ev: ValueChangedEvent<string>) {
|
||||
this._powerConfig = {
|
||||
stat_rate_inverted: ev.detail.value,
|
||||
};
|
||||
}
|
||||
|
||||
private _dischargePowerChanged(ev: CustomEvent<{ value: string }>) {
|
||||
private _dischargePowerChanged(ev: ValueChangedEvent<string>) {
|
||||
this._powerConfig = {
|
||||
...this._powerConfig,
|
||||
stat_rate_from: ev.detail.value,
|
||||
};
|
||||
}
|
||||
|
||||
private _chargePowerChanged(ev: CustomEvent<{ value: string }>) {
|
||||
private _chargePowerChanged(ev: ValueChangedEvent<string>) {
|
||||
this._powerConfig = {
|
||||
...this._powerConfig,
|
||||
stat_rate_to: ev.detail.value,
|
||||
|
||||
@@ -16,7 +16,7 @@ import { getStatisticLabel } from "../../../../data/recorder";
|
||||
import { getSensorDeviceClassConvertibleUnits } from "../../../../data/sensor";
|
||||
import type { HassDialog } from "../../../../dialogs/make-dialog-manager";
|
||||
import { haStyleDialog } from "../../../../resources/styles";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../../types";
|
||||
import type { EnergySettingsDeviceWaterDialogParams } from "./show-dialogs-energy";
|
||||
|
||||
const volumeUnitClasses = ["volume"];
|
||||
@@ -199,7 +199,7 @@ export class DialogEnergyDeviceSettingsWater
|
||||
`;
|
||||
}
|
||||
|
||||
private _statisticChanged(ev: CustomEvent<{ value: string }>) {
|
||||
private _statisticChanged(ev: ValueChangedEvent<string>) {
|
||||
if (!ev.detail.value) {
|
||||
this._device = undefined;
|
||||
return;
|
||||
|
||||
@@ -19,7 +19,7 @@ import { getStatisticLabel } from "../../../../data/recorder";
|
||||
import { getSensorDeviceClassConvertibleUnits } from "../../../../data/sensor";
|
||||
import type { HassDialog } from "../../../../dialogs/make-dialog-manager";
|
||||
import { haStyleDialog } from "../../../../resources/styles";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../../types";
|
||||
import type { EnergySettingsDeviceDialogParams } from "./show-dialogs-energy";
|
||||
|
||||
const energyUnitClasses = ["energy"];
|
||||
@@ -225,7 +225,7 @@ export class DialogEnergyDeviceSettings
|
||||
`;
|
||||
}
|
||||
|
||||
private _statisticChanged(ev: CustomEvent<{ value: string }>) {
|
||||
private _statisticChanged(ev: ValueChangedEvent<string>) {
|
||||
if (!ev.detail.value) {
|
||||
this._device = undefined;
|
||||
return;
|
||||
@@ -234,7 +234,7 @@ export class DialogEnergyDeviceSettings
|
||||
this._computePossibleParents();
|
||||
}
|
||||
|
||||
private _powerStatisticChanged(ev: CustomEvent<{ value: string }>) {
|
||||
private _powerStatisticChanged(ev: ValueChangedEvent<string>) {
|
||||
if (!this._device) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
import { getSensorDeviceClassConvertibleUnits } from "../../../../data/sensor";
|
||||
import type { HassDialog } from "../../../../dialogs/make-dialog-manager";
|
||||
import { haStyle, haStyleDialog } from "../../../../resources/styles";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../../types";
|
||||
import type { EnergySettingsGasDialogParams } from "./show-dialogs-energy";
|
||||
|
||||
const gasDeviceClasses = ["gas", "energy"];
|
||||
@@ -331,7 +331,7 @@ export class DialogEnergyGasSettings
|
||||
};
|
||||
}
|
||||
|
||||
private async _statisticChanged(ev: CustomEvent<{ value: string }>) {
|
||||
private async _statisticChanged(ev: ValueChangedEvent<string>) {
|
||||
if (ev.detail.value) {
|
||||
const metadata = await getStatisticMetadata(this.hass, [ev.detail.value]);
|
||||
this._pickedDisplayUnit = getDisplayUnit(
|
||||
|
||||
@@ -24,7 +24,7 @@ import { isExternalStatistic } from "../../../../data/recorder";
|
||||
import { getSensorDeviceClassConvertibleUnits } from "../../../../data/sensor";
|
||||
import type { HassDialog } from "../../../../dialogs/make-dialog-manager";
|
||||
import { haStyleDialog } from "../../../../resources/styles";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../../types";
|
||||
import type { EnergySettingsGridFlowDialogParams } from "./show-dialogs-energy";
|
||||
|
||||
const energyUnitClasses = ["energy"];
|
||||
@@ -325,7 +325,7 @@ export class DialogEnergyGridFlowSettings
|
||||
};
|
||||
}
|
||||
|
||||
private async _statisticChanged(ev: CustomEvent<{ value: string }>) {
|
||||
private async _statisticChanged(ev: ValueChangedEvent<string>) {
|
||||
if (
|
||||
ev.detail.value &&
|
||||
isExternalStatistic(ev.detail.value) &&
|
||||
|
||||
@@ -17,7 +17,7 @@ import { energyStatisticHelpUrl } from "../../../../data/energy";
|
||||
import { getSensorDeviceClassConvertibleUnits } from "../../../../data/sensor";
|
||||
import type { HassDialog } from "../../../../dialogs/make-dialog-manager";
|
||||
import { haStyleDialog } from "../../../../resources/styles";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../../types";
|
||||
import type { EnergySettingsGridPowerDialogParams } from "./show-dialogs-energy";
|
||||
|
||||
const powerUnitClasses = ["power"];
|
||||
@@ -287,26 +287,26 @@ export class DialogEnergyGridPowerSettings
|
||||
this._powerConfig = {};
|
||||
}
|
||||
|
||||
private _standardStatisticChanged(ev: CustomEvent<{ value: string }>) {
|
||||
private _standardStatisticChanged(ev: ValueChangedEvent<string>) {
|
||||
this._powerConfig = {
|
||||
stat_rate: ev.detail.value,
|
||||
};
|
||||
}
|
||||
|
||||
private _invertedStatisticChanged(ev: CustomEvent<{ value: string }>) {
|
||||
private _invertedStatisticChanged(ev: ValueChangedEvent<string>) {
|
||||
this._powerConfig = {
|
||||
stat_rate_inverted: ev.detail.value,
|
||||
};
|
||||
}
|
||||
|
||||
private _fromStatisticChanged(ev: CustomEvent<{ value: string }>) {
|
||||
private _fromStatisticChanged(ev: ValueChangedEvent<string>) {
|
||||
this._powerConfig = {
|
||||
...this._powerConfig,
|
||||
stat_rate_from: ev.detail.value,
|
||||
};
|
||||
}
|
||||
|
||||
private _toStatisticChanged(ev: CustomEvent<{ value: string }>) {
|
||||
private _toStatisticChanged(ev: ValueChangedEvent<string>) {
|
||||
this._powerConfig = {
|
||||
...this._powerConfig,
|
||||
stat_rate_to: ev.detail.value,
|
||||
|
||||
@@ -23,7 +23,7 @@ import { getSensorDeviceClassConvertibleUnits } from "../../../../data/sensor";
|
||||
import { showConfigFlowDialog } from "../../../../dialogs/config-flow/show-dialog-config-flow";
|
||||
import type { HassDialog } from "../../../../dialogs/make-dialog-manager";
|
||||
import { haStyle, haStyleDialog } from "../../../../resources/styles";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../../types";
|
||||
import { brandsUrl } from "../../../../util/brands-url";
|
||||
import type { EnergySettingsSolarDialogParams } from "./show-dialogs-energy";
|
||||
|
||||
@@ -285,11 +285,11 @@ export class DialogEnergySolarSettings
|
||||
});
|
||||
}
|
||||
|
||||
private _statisticChanged(ev: CustomEvent<{ value: string }>) {
|
||||
private _statisticChanged(ev: ValueChangedEvent<string>) {
|
||||
this._source = { ...this._source!, stat_energy_from: ev.detail.value };
|
||||
}
|
||||
|
||||
private _powerStatisticChanged(ev: CustomEvent<{ value: string }>) {
|
||||
private _powerStatisticChanged(ev: ValueChangedEvent<string>) {
|
||||
this._source = { ...this._source!, stat_rate: ev.detail.value };
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import { isExternalStatistic } from "../../../../data/recorder";
|
||||
import { getSensorDeviceClassConvertibleUnits } from "../../../../data/sensor";
|
||||
import type { HassDialog } from "../../../../dialogs/make-dialog-manager";
|
||||
import { haStyle, haStyleDialog } from "../../../../resources/styles";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../../types";
|
||||
import type { EnergySettingsWaterDialogParams } from "./show-dialogs-energy";
|
||||
|
||||
@customElement("dialog-energy-water-settings")
|
||||
@@ -277,7 +277,7 @@ export class DialogEnergyWaterSettings
|
||||
};
|
||||
}
|
||||
|
||||
private async _statisticChanged(ev: CustomEvent<{ value: string }>) {
|
||||
private async _statisticChanged(ev: ValueChangedEvent<string>) {
|
||||
if (
|
||||
ev.detail.value &&
|
||||
isExternalStatistic(ev.detail.value) &&
|
||||
|
||||
@@ -43,7 +43,11 @@ import "../../../../../layouts/hass-error-screen";
|
||||
import "../../../../../layouts/hass-loading-screen";
|
||||
import "../../../../../layouts/hass-tabs-subpage";
|
||||
import { haStyle } from "../../../../../resources/styles";
|
||||
import type { HomeAssistant, Route } from "../../../../../types";
|
||||
import type {
|
||||
HomeAssistant,
|
||||
Route,
|
||||
ValueChangedEvent,
|
||||
} from "../../../../../types";
|
||||
import "../../../ha-config-section";
|
||||
import { configTabs } from "./zwave_js-config-router";
|
||||
import "./zwave_js-custom-param";
|
||||
@@ -547,7 +551,7 @@ class ZWaveJSNodeConfig extends LitElement {
|
||||
id: string,
|
||||
item: ZWaveJSNodeConfigParam
|
||||
) {
|
||||
return (ev: CustomEvent<{ value: number }>) =>
|
||||
return (ev: ValueChangedEvent<number>) =>
|
||||
this._numericInputChanged({
|
||||
...ev,
|
||||
target: {
|
||||
|
||||
@@ -27,7 +27,7 @@ import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box";
|
||||
import "../../../layouts/hass-subpage";
|
||||
import { mdiHomeAssistant } from "../../../resources/home-assistant-logo-svg";
|
||||
import { haStyle } from "../../../resources/styles";
|
||||
import type { HomeAssistant, Route } from "../../../types";
|
||||
import type { HomeAssistant, Route, ValueChangedEvent } from "../../../types";
|
||||
import "./error-log-card";
|
||||
import "./system-log-card";
|
||||
import type { SystemLogCard } from "./system-log-card";
|
||||
@@ -201,7 +201,7 @@ export class HaConfigLogs extends LitElement {
|
||||
this.providerPicker?.open();
|
||||
}
|
||||
|
||||
private _handleDropdownSelect(ev: CustomEvent<{ value: string }>) {
|
||||
private _handleDropdownSelect(ev: ValueChangedEvent<string>) {
|
||||
const provider = ev.detail?.value;
|
||||
if (!provider) {
|
||||
return;
|
||||
|
||||
@@ -51,7 +51,7 @@ import {
|
||||
normalizeScriptConfig,
|
||||
} from "../../../data/script";
|
||||
import { SubscribeMixin } from "../../../mixins/subscribe-mixin";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../types";
|
||||
import { documentationUrl } from "../../../util/documentation-url";
|
||||
import { showToast } from "../../../util/toast";
|
||||
import "../automation/action/ha-automation-action";
|
||||
@@ -543,7 +543,7 @@ export class HaManualScriptEditor extends SubscribeMixin(LitElement) {
|
||||
this._sidebarElement?.focus();
|
||||
}
|
||||
|
||||
private _sidebarConfigChanged(ev: CustomEvent<{ value: SidebarConfig }>) {
|
||||
private _sidebarConfigChanged(ev: ValueChangedEvent<SidebarConfig>) {
|
||||
ev.stopPropagation();
|
||||
if (!this._sidebarConfig) {
|
||||
return;
|
||||
|
||||
@@ -7,7 +7,7 @@ import "../../../../../components/ha-form/ha-form";
|
||||
import type { SchemaUnion } from "../../../../../components/ha-form/types";
|
||||
import "../../../../../components/ha-service-control";
|
||||
import type { ServiceAction } from "../../../../../data/script";
|
||||
import type { HomeAssistant } from "../../../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../../../types";
|
||||
import type { ServiceButtonElementConfig } from "../../../elements/types";
|
||||
import type { LovelacePictureElementEditor } from "../../../types";
|
||||
|
||||
@@ -78,7 +78,7 @@ export class HuiServiceButtonElementEditor
|
||||
});
|
||||
}
|
||||
|
||||
private _serviceDataChanged(ev: CustomEvent<{ value: ServiceAction }>): void {
|
||||
private _serviceDataChanged(ev: ValueChangedEvent<ServiceAction>): void {
|
||||
const config: ServiceButtonElementConfig = {
|
||||
...this._config!,
|
||||
action: ev.detail.value.action,
|
||||
|
||||
@@ -4,7 +4,7 @@ import { customElement, property, state } from "lit/decorators";
|
||||
import "../../../components/ha-date-input";
|
||||
import { setDateValue } from "../../../data/date";
|
||||
import { isUnavailableState, UNAVAILABLE } from "../../../data/entity/entity";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../types";
|
||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||
import "../components/hui-generic-entity-row";
|
||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||
@@ -59,7 +59,7 @@ class HuiDateEntityRow extends LitElement implements LovelaceRow {
|
||||
`;
|
||||
}
|
||||
|
||||
private _dateChanged(ev: CustomEvent<{ value: string }>): void {
|
||||
private _dateChanged(ev: ValueChangedEvent<string>): void {
|
||||
if (ev.detail.value) {
|
||||
setDateValue(this.hass!, this._config!.entity, ev.detail.value);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import "../../../components/ha-date-input";
|
||||
import "../../../components/ha-time-input";
|
||||
import { setDateTimeValue } from "../../../data/datetime";
|
||||
import { isUnavailableState, UNAVAILABLE } from "../../../data/entity/entity";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../types";
|
||||
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||
import "../components/hui-generic-entity-row";
|
||||
@@ -90,7 +90,7 @@ class HuiInputDatetimeEntityRow extends LitElement implements LovelaceRow {
|
||||
ev.stopPropagation();
|
||||
}
|
||||
|
||||
private _timeChanged(ev: CustomEvent<{ value: string }>): void {
|
||||
private _timeChanged(ev: ValueChangedEvent<string>): void {
|
||||
if (ev.detail.value) {
|
||||
const stateObj = this.hass!.states[this._config!.entity];
|
||||
const dateObj = new Date(stateObj.state);
|
||||
@@ -101,7 +101,7 @@ class HuiInputDatetimeEntityRow extends LitElement implements LovelaceRow {
|
||||
}
|
||||
}
|
||||
|
||||
private _dateChanged(ev: CustomEvent<{ value: string }>): void {
|
||||
private _dateChanged(ev: ValueChangedEvent<string>): void {
|
||||
if (ev.detail.value) {
|
||||
const stateObj = this.hass!.states[this._config!.entity];
|
||||
const dateObj = new Date(stateObj.state);
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
setInputDateTimeValue,
|
||||
stateToIsoDateString,
|
||||
} from "../../../data/input_datetime";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../types";
|
||||
import { computeLovelaceEntityName } from "../common/entity/compute-lovelace-entity-name";
|
||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||
import "../components/hui-generic-entity-row";
|
||||
@@ -101,7 +101,7 @@ class HuiInputDatetimeEntityRow extends LitElement implements LovelaceRow {
|
||||
ev.stopPropagation();
|
||||
}
|
||||
|
||||
private _timeChanged(ev: CustomEvent<{ value: string }>): void {
|
||||
private _timeChanged(ev: ValueChangedEvent<string>): void {
|
||||
const stateObj = this.hass!.states[this._config!.entity];
|
||||
setInputDateTimeValue(
|
||||
this.hass!,
|
||||
@@ -111,7 +111,7 @@ class HuiInputDatetimeEntityRow extends LitElement implements LovelaceRow {
|
||||
);
|
||||
}
|
||||
|
||||
private _dateChanged(ev: CustomEvent<{ value: string }>): void {
|
||||
private _dateChanged(ev: ValueChangedEvent<string>): void {
|
||||
const stateObj = this.hass!.states[this._config!.entity];
|
||||
|
||||
setInputDateTimeValue(
|
||||
|
||||
@@ -5,7 +5,7 @@ import "../../../components/ha-date-input";
|
||||
import "../../../components/ha-time-input";
|
||||
import { isUnavailableState, UNAVAILABLE } from "../../../data/entity/entity";
|
||||
import { setTimeValue } from "../../../data/time";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import type { HomeAssistant, ValueChangedEvent } from "../../../types";
|
||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||
import "../components/hui-generic-entity-row";
|
||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||
@@ -64,7 +64,7 @@ class HuiTimeEntityRow extends LitElement implements LovelaceRow {
|
||||
ev.stopPropagation();
|
||||
}
|
||||
|
||||
private _timeChanged(ev: CustomEvent<{ value: string }>): void {
|
||||
private _timeChanged(ev: ValueChangedEvent<string>): void {
|
||||
if (ev.detail.value) {
|
||||
const stateObj = this.hass!.states[this._config!.entity];
|
||||
setTimeValue(this.hass!, stateObj.entity_id, ev.detail.value);
|
||||
|
||||
Reference in New Issue
Block a user