refactor: Retire the use of unmaintained custom-card-helpers (#1956)

- Closes #1295
This commit is contained in:
Dermot Duffy
2025-03-09 16:02:33 -07:00
committed by GitHub
parent c65ee3f0f2
commit a79ffa6edc
116 changed files with 933 additions and 545 deletions
@@ -87,7 +87,8 @@ export class ActionsManager {
*/
public handleCustomActionEvent = (ev: Event): void => {
if (!('detail' in ev)) {
// The event may not be a CustomEvent object, see:
// The event may or may not be a CustomEvent object. For example, whilst
// this card doesn't use custom-card-helpers, embedded elements may:
// https://github.com/custom-cards/custom-card-helpers/blob/master/src/fire-event.ts#L70
return;
}
@@ -1,4 +1,5 @@
import { ActionConfig, handleActionConfig } from '@dermotduffy/custom-card-helpers';
import { handleActionConfig } from '../../../ha/handle-action';
import { ActionConfig } from '../../../ha/types';
import { CardActionsAPI } from '../../types';
import { BaseAction } from './base';
+1 -1
View File
@@ -1,6 +1,6 @@
import { ActionConfig } from '@dermotduffy/custom-card-helpers';
import { ActionContext } from 'action';
import { ActionType, INTERNAL_CALLBACK_ACTION } from '../../config/types';
import { ActionConfig } from '../../ha/types';
import { convertActionToCardCustomAction } from '../../utils/action';
import { CameraSelectAction } from './actions/camera-select';
import { CameraUIAction } from './actions/camera-ui';
@@ -1,11 +1,11 @@
import { dispatchAdvancedCameraCardEvent } from '../../../utils/basic';
import { fireAdvancedCameraCardEvent } from '../../../utils/fire-advanced-camera-card-event';
import { ActionExecutionRequest } from '../types';
export const dispatchActionExecutionRequest = (
element: HTMLElement,
request: ActionExecutionRequest,
) => {
dispatchAdvancedCameraCardEvent(element, 'action:execution-request', request);
fireAdvancedCameraCardEvent(element, 'action:execution-request', request);
};
export interface ActionExecutionRequestEventTarget extends EventTarget {
+1 -1
View File
@@ -1,8 +1,8 @@
import { LovelaceCardEditor } from '@dermotduffy/custom-card-helpers';
import { ReactiveController } from 'lit';
import { CameraManager } from '../camera-manager/manager';
import { ConditionStateManager } from '../conditions/state-manager';
import { AdvancedCameraCardConfig } from '../config/types';
import { LovelaceCardEditor } from '../ha/types';
import {
createDeviceRegistryCache,
DeviceRegistryManager,
+4 -4
View File
@@ -1,11 +1,11 @@
import { HomeAssistant } from '../../ha/types';
import { localize } from '../../localize/localize';
import { ExtendedHomeAssistant } from '../../types';
import { hasHAConnectionStateChanged } from '../../utils/ha';
import { CardHASSAPI } from '../types';
import { StateWatcher, StateWatcherSubscriptionInterface } from './state-watcher';
export class HASSManager {
protected _hass: ExtendedHomeAssistant | null = null;
protected _hass: HomeAssistant | null = null;
protected _api: CardHASSAPI;
protected _stateWatcher: StateWatcher = new StateWatcher();
@@ -13,7 +13,7 @@ export class HASSManager {
this._api = api;
}
public getHASS(): ExtendedHomeAssistant | null {
public getHASS(): HomeAssistant | null {
return this._hass;
}
@@ -25,7 +25,7 @@ export class HASSManager {
return this._stateWatcher;
}
public setHASS(hass?: ExtendedHomeAssistant | null): void {
public setHASS(hass?: HomeAssistant | null): void {
if (hasHAConnectionStateChanged(this._hass, hass)) {
if (!hass?.connected) {
this._api.getMessageManager().setMessageIfHigherPriority({
+1 -1
View File
@@ -1,4 +1,4 @@
import { HomeAssistant } from '@dermotduffy/custom-card-helpers';
import { HomeAssistant } from '../../ha/types';
import { getHassDifferences, HassStateDifference } from '../../utils/ha';
type StateWatcherCallback = (difference: HassStateDifference) => void;
+2 -2
View File
@@ -1,7 +1,7 @@
import { HomeAssistant } from '@dermotduffy/custom-card-helpers';
import { HASS, renderTemplate } from 'ha-nunjucks/dist';
import { ConditionsTriggerData, ConditionState } from '../../conditions/types';
import { ConditionState, ConditionsTriggerData } from '../../conditions/types';
import { ActionType } from '../../config/types';
import { HomeAssistant } from '../../ha/types';
interface TemplateContextInternal {
camera?: string;