Avoid use of ExtendedHomeAssistant wherever possible.

This commit is contained in:
Dermot Duffy
2022-04-18 18:04:51 -07:00
parent b27dea67b1
commit 22c2b022e7
13 changed files with 35 additions and 34 deletions
+4 -4
View File
@@ -67,7 +67,7 @@ export class BrowseMediaUtil {
* @returns A FrigateBrowseMediaSource object or null on malformed.
*/
static async browseMedia(
hass: HomeAssistant & ExtendedHomeAssistant,
hass: HomeAssistant,
media_content_id: string,
): Promise<FrigateBrowseMediaSource> {
const request = {
@@ -86,7 +86,7 @@ export class BrowseMediaUtil {
* @returns A FrigateBrowseMediaSource object or null on malformed.
*/
static async browseMediaQuery(
hass: HomeAssistant & ExtendedHomeAssistant,
hass: HomeAssistant,
params: BrowseMediaQueryParameters,
): Promise<FrigateBrowseMediaSource> {
return this.browseMedia(
@@ -183,7 +183,7 @@ export class BrowseMediaUtil {
*/
static async fetchLatestMediaAndDispatchViewChange(
node: HTMLElement,
hass: HomeAssistant & ExtendedHomeAssistant,
hass: HomeAssistant,
view: Readonly<View>,
browseMediaQueryParameters: BrowseMediaQueryParameters,
): Promise<void> {
@@ -225,7 +225,7 @@ export class BrowseMediaUtil {
*/
static async fetchChildMediaAndDispatchViewChange(
node: HTMLElement,
hass: HomeAssistant & ExtendedHomeAssistant,
hass: HomeAssistant,
view: Readonly<View>,
child: Readonly<FrigateBrowseMediaSource>,
): Promise<void> {
+2 -2
View File
@@ -132,7 +132,7 @@ console.info(
@customElement('frigate-card')
export class FrigateCard extends LitElement {
@property({ attribute: false })
protected _hass?: HomeAssistant & ExtendedHomeAssistant;
protected _hass?: ExtendedHomeAssistant;
// The main base configuration object. For most usecases use getConfig() to
// get the correct configuration (which will return overrides as appropriate).
@@ -188,7 +188,7 @@ export class FrigateCard extends LitElement {
/**
* Set the Home Assistant object.
*/
set hass(hass: HomeAssistant & ExtendedHomeAssistant) {
set hass(hass: ExtendedHomeAssistant) {
this._hass = hass;
// Manually set hass in the menu, elements and image. This is to allow these
+2 -2
View File
@@ -54,7 +54,7 @@ export function getParseErrorKeys<T>(error: z.ZodError<T>): string[] {
* @returns The parsed valid response or null on malformed.
*/
export async function homeAssistantWSRequest<T>(
hass: HomeAssistant & ExtendedHomeAssistant,
hass: HomeAssistant,
schema: ZodSchema<T>,
request: MessageBase,
): Promise<T> {
@@ -88,7 +88,7 @@ export async function homeAssistantWSRequest<T>(
* @returns The signed URL, or null if the response was malformed.
*/
export async function homeAssistantSignPath(
hass: HomeAssistant & ExtendedHomeAssistant,
hass: ExtendedHomeAssistant,
path: string,
expires?: number,
): Promise<string | null> {
+5 -5
View File
@@ -68,12 +68,12 @@ class FrigateCardElementsCore extends LitElement {
protected conditionState?: ConditionState;
protected _root: HTMLElement | null = null;
protected _hass?: HomeAssistant & ExtendedHomeAssistant;
protected _hass?: HomeAssistant;
/**
* Set Home Assistant object.
*/
set hass(hass: HomeAssistant & ExtendedHomeAssistant) {
set hass(hass: HomeAssistant) {
if (this._root) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(this._root as any).hass = hass;
@@ -137,7 +137,7 @@ class FrigateCardElementsCore extends LitElement {
@customElement('frigate-card-elements')
export class FrigateCardElements extends LitElement {
@property({ attribute: false })
public hass?: HomeAssistant & ExtendedHomeAssistant;
public hass?: HomeAssistant;
@property({ attribute: false })
protected elements: PictureElements;
@@ -235,7 +235,7 @@ export class FrigateCardElements extends LitElement {
@customElement('frigate-card-conditional')
export class FrigateCardElementsConditional extends LitElement {
protected _config?: FrigateConditional;
protected _hass?: HomeAssistant & ExtendedHomeAssistant;
protected _hass?: HomeAssistant;
@query('frigate-card-elements-core')
_core?: FrigateCardElementsCore;
@@ -243,7 +243,7 @@ export class FrigateCardElementsConditional extends LitElement {
/**
* Set the Home Assistant object.
*/
set hass(hass: HomeAssistant & ExtendedHomeAssistant) {
set hass(hass: HomeAssistant) {
if (this._core) {
this._core.hass = hass;
}
+2 -2
View File
@@ -30,7 +30,7 @@ import galleryStyle from '../scss/gallery.scss';
@customElement('frigate-card-gallery')
export class FrigateCardGallery extends LitElement {
@property({ attribute: false })
protected hass?: HomeAssistant & ExtendedHomeAssistant;
protected hass?: HomeAssistant;
@property({ attribute: false })
protected view?: Readonly<View>;
@@ -98,7 +98,7 @@ export class FrigateCardGallery extends LitElement {
@customElement('frigate-card-gallery-core')
export class FrigateCardGalleryCore extends LitElement {
@property({ attribute: false })
protected hass?: HomeAssistant & ExtendedHomeAssistant;
protected hass?: HomeAssistant;
@property({ attribute: false })
protected view?: Readonly<View>;
+6 -6
View File
@@ -66,7 +66,7 @@ const URL_SIGN_REFRESH_THRESHOLD_SECONDS = 1 * 60 * 60;
@customElement('frigate-card-live')
export class FrigateCardLive extends LitElement {
@property({ attribute: false })
protected hass?: HomeAssistant & ExtendedHomeAssistant;
protected hass?: ExtendedHomeAssistant;
@property({ attribute: false })
protected view?: Readonly<View>;
@@ -182,7 +182,7 @@ export class FrigateCardLive extends LitElement {
@customElement('frigate-card-live-carousel')
export class FrigateCardLiveCarousel extends FrigateCardMediaCarousel {
@property({ attribute: false })
protected hass?: HomeAssistant & ExtendedHomeAssistant;
protected hass?: ExtendedHomeAssistant;
@property({ attribute: false })
protected view?: Readonly<View>;
@@ -531,7 +531,7 @@ export class FrigateCardLiveCarousel extends FrigateCardMediaCarousel {
@customElement('frigate-card-live-provider')
export class FrigateCardLiveProvider extends LitElement {
@property({ attribute: false })
protected hass?: HomeAssistant & ExtendedHomeAssistant;
protected hass?: ExtendedHomeAssistant;
@property({ attribute: false })
protected cameraConfig?: CameraConfig;
@@ -642,7 +642,7 @@ export class FrigateCardLiveProvider extends LitElement {
@customElement('frigate-card-live-ha')
export class FrigateCardLiveFrigate extends LitElement {
@property({ attribute: false })
protected hass?: HomeAssistant & ExtendedHomeAssistant;
protected hass?: HomeAssistant;
@property({ attribute: false })
protected cameraConfig?: CameraConfig;
@@ -731,7 +731,7 @@ export class FrigateCardLiveWebRTCCard extends LitElement {
@property({ attribute: false })
protected cameraConfig?: CameraConfig;
protected hass?: HomeAssistant & ExtendedHomeAssistant;
protected hass?: HomeAssistant;
// A task to await the load of the WebRTC component.
protected _webrtcTask = new Task(this, this._getWebRTCCardElement, () => [1]);
@@ -888,7 +888,7 @@ export class FrigateCardLiveJSMPEG extends LitElement {
@property({ attribute: false, hasChanged: contentsChanged })
protected jsmpegConfig?: JSMPEGConfig;
protected hass?: HomeAssistant & ExtendedHomeAssistant;
protected hass?: ExtendedHomeAssistant;
protected _jsmpegCanvasElement?: HTMLCanvasElement;
protected _jsmpegVideoPlayer?: JSMpeg.VideoElement;
+1 -1
View File
@@ -55,7 +55,7 @@ export const FRIGATE_ICON_FILLED =
@customElement('frigate-card-menu')
export class FrigateCardMenu extends LitElement {
@property({ attribute: false })
public hass?: HomeAssistant & ExtendedHomeAssistant;
public hass?: HomeAssistant;
set menuConfig(menuConfig: MenuConfig) {
this._menuConfig = menuConfig;
+1 -1
View File
@@ -18,7 +18,7 @@ import submenuStyle from '../scss/submenu.scss';
@customElement('frigate-card-submenu')
export class FrigateCardSubmenu extends LitElement {
@property({ attribute: false })
public hass?: HomeAssistant & ExtendedHomeAssistant;
public hass?: HomeAssistant;
@property({ attribute: false })
public submenu?: MenuSubmenu;
+3 -3
View File
@@ -23,7 +23,7 @@ import surroundThumbnailsStyle from '../scss/surround.scss';
@customElement('frigate-card-surround-thumbnails')
export class FrigateCardSurround extends LitElement {
@property({ attribute: false })
protected hass?: HomeAssistant & ExtendedHomeAssistant;
protected hass?: HomeAssistant;
@property({ attribute: false })
protected view?: Readonly<View>;
@@ -51,12 +51,12 @@ export class FrigateCardSurround extends LitElement {
* @returns
*/
protected async _fetchMedia([hass, view, browseMediaParams]: (
| (HomeAssistant & ExtendedHomeAssistant)
| HomeAssistant
| Readonly<View>
| BrowseMediaQueryParameters
| undefined
)[]): Promise<void> {
hass = hass as HomeAssistant & ExtendedHomeAssistant;
hass = hass as HomeAssistant;
view = view as Readonly<View>;
browseMediaParams = browseMediaParams as BrowseMediaQueryParameters;
+4 -4
View File
@@ -239,7 +239,7 @@ class TimelineEventManager {
*/
public async fetchEventsIfNecessary(
element: HTMLElement,
hass: HomeAssistant & ExtendedHomeAssistant,
hass: HomeAssistant,
cameras: Map<string, CameraConfig>,
media: TimelineMediaType,
start: Date,
@@ -262,7 +262,7 @@ class TimelineEventManager {
*/
protected async _fetchEvents(
element: HTMLElement,
hass: HomeAssistant & ExtendedHomeAssistant,
hass: HomeAssistant,
cameras: Map<string, CameraConfig>,
media: TimelineMediaType,
start?: Date,
@@ -328,7 +328,7 @@ class TimelineEventManager {
@customElement('frigate-card-timeline')
export class FrigateCardTimeline extends LitElement {
@property({ attribute: false })
protected hass?: HomeAssistant & ExtendedHomeAssistant;
protected hass?: HomeAssistant;
@property({ attribute: false })
protected view?: Readonly<View>;
@@ -374,7 +374,7 @@ export class FrigateCardTimeline extends LitElement {
@customElement('frigate-card-timeline-core')
export class FrigateCardTimelineCore extends LitElement {
@property({ attribute: false })
protected hass?: HomeAssistant & ExtendedHomeAssistant;
protected hass?: HomeAssistant;
@property({ attribute: false })
protected view?: Readonly<View>;
+2 -2
View File
@@ -46,7 +46,7 @@ import viewerStyle from '../scss/viewer.scss';
@customElement('frigate-card-viewer')
export class FrigateCardViewer extends LitElement {
@property({ attribute: false })
protected hass?: HomeAssistant & ExtendedHomeAssistant;
protected hass?: HomeAssistant;
@property({ attribute: false })
protected view?: Readonly<View>;
@@ -120,7 +120,7 @@ export class FrigateCardViewer extends LitElement {
@customElement('frigate-card-viewer-carousel')
export class FrigateCardViewerCarousel extends FrigateCardMediaCarousel {
@property({ attribute: false })
protected hass?: HomeAssistant & ExtendedHomeAssistant;
protected hass?: HomeAssistant;
@property({ attribute: false })
protected view?: Readonly<View>;
+1 -1
View File
@@ -38,7 +38,7 @@ export class ResolvedMediaCache {
export class ResolvedMediaUtil {
static async resolveMedia(
hass: HomeAssistant & ExtendedHomeAssistant,
hass: HomeAssistant,
mediaSource?: FrigateBrowseMediaSource,
cache?: ResolvedMediaCache,
): Promise<ResolvedMedia | null> {
+2 -1
View File
@@ -2,6 +2,7 @@ import { StyleInfo } from 'lit/directives/style-map.js';
import {
CallServiceActionConfig,
CustomActionConfig,
HomeAssistant,
LovelaceCard,
LovelaceCardEditor,
MoreInfoActionConfig,
@@ -932,7 +933,7 @@ const menuButtonSchema = z.discriminatedUnion('type', [
menuSubmenuSchema,
]);
export type MenuButton = z.infer<typeof menuButtonSchema>;
export interface ExtendedHomeAssistant {
export interface ExtendedHomeAssistant extends HomeAssistant {
hassUrl(path?): string;
themes: Themes & {
darkMode?: boolean