Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Entity<T, S>

Class representing entities on the Home Assistant system. This class gives a generic view of all entities providing functionality to monitor state changes as well as querying current state disregarding.

Objects of this call can be treated as a @{link Observable}.*

Type parameters

  • T: HassEntityBase = HassEntity

    Type of the entity

  • S = string

    Type of the entity state property - represented as a string in Home Assistant.

Hierarchy

Implements

  • Subscribable<T>

Index

Constructors

constructor

Properties

Protected _entity

_entity: T | undefined

_isScalar

_isScalar: boolean

Internal implementation detail, do not use directly.

Readonly id

id: string

Protected Readonly instance

instance: HAInstance

operator

operator: Operator<any, T>
deprecated

This is an internal implementation detail, do not use.

Protected restClient

restClient: RESTClient

source

source: Observable<any>
deprecated

This is an internal implementation detail, do not use.

Readonly state$

state$: Observable<S> = this.pipe(state<S>())

Emits the state whenever it changes.

Static create

create: Function

Creates a new cold Observable by calling the Observable constructor

static

true

owner

Observable

method

create

param

the subscriber function to be passed to the Observable constructor

returns

a new cold observable

nocollapse
deprecated

use new Observable() instead

Static if

if: typeof iif
nocollapse
deprecated

In favor of iif creation function: import { iif } from 'rxjs';

Static throw

throw: typeof throwError
nocollapse
deprecated

In favor of throwError creation function: import { throwError } from 'rxjs';

Accessors

assumedState

  • get assumedState(): Promise<boolean | undefined>

deviceClass

  • get deviceClass(): Promise<string | undefined>

entity

  • get entity(): Promise<T>

entityPicture

  • get entityPicture(): Promise<string | undefined>

friendlyName

  • get friendlyName(): Promise<string | undefined>

hidden

  • get hidden(): Promise<boolean | undefined>

icon

  • get icon(): Promise<string | undefined>

state

  • get state(): Promise<S>

supportedFeatures

  • get supportedFeatures(): Promise<number | undefined>

unitOfMeasurement

  • get unitOfMeasurement(): Promise<string | undefined>

Methods

_trySubscribe

  • _trySubscribe(sink: Subscriber<T>): TeardownLogic
  • deprecated

    This is an internal implementation detail, do not use.

    Parameters

    • sink: Subscriber<T>

    Returns TeardownLogic

forEach

  • forEach(next: (value: T) => void, promiseCtor?: PromiseConstructorLike): Promise<void>
  • method

    forEach

    Parameters

    • next: (value: T) => void

      a handler for each value emitted by the observable

        • (value: T): void
        • Parameters

          • value: T

          Returns void

    • Optional promiseCtor: PromiseConstructorLike

    Returns Promise<void>

    a promise that either resolves on observable completion or rejects with the handled error

getAttribute

  • getAttribute<T>(key: string): Promise<T>
  • Get the last known value of a entity attribute.

    Type parameters

    • T

      Type of entity

    Parameters

    • key: string

      Name (key) of attribute

    Returns Promise<T>

lift

  • lift<R>(operator: Operator<T, R>): Observable<R>
  • Creates a new Observable, with this Observable as the source, and the passed operator defined as the new observable's operator.

    method

    lift

    Type parameters

    • R

    Parameters

    • operator: Operator<T, R>

      the operator defining the operation to take on the observable

    Returns Observable<R>

    a new observable with the Operator applied

pipe

  • pipe(): Observable<T>
  • pipe<A>(op1: OperatorFunction<T, A>): Observable<A>
  • pipe<A, B>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>): Observable<B>
  • pipe<A, B, C>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>): Observable<C>
  • pipe<A, B, C, D>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>): Observable<D>
  • pipe<A, B, C, D, E>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>): Observable<E>
  • pipe<A, B, C, D, E, F>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>): Observable<F>
  • pipe<A, B, C, D, E, F, G>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>): Observable<G>
  • pipe<A, B, C, D, E, F, G, H>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>, op8: OperatorFunction<G, H>): Observable<H>
  • pipe<A, B, C, D, E, F, G, H, I>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>, op8: OperatorFunction<G, H>, op9: OperatorFunction<H, I>): Observable<I>
  • pipe<A, B, C, D, E, F, G, H, I>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>, op8: OperatorFunction<G, H>, op9: OperatorFunction<H, I>, ...operations: OperatorFunction<any, any>[]): Observable<{}>
  • Returns Observable<T>

  • Type parameters

    • A

    Parameters

    • op1: OperatorFunction<T, A>

    Returns Observable<A>

  • Type parameters

    • A

    • B

    Parameters

    • op1: OperatorFunction<T, A>
    • op2: OperatorFunction<A, B>

    Returns Observable<B>

  • Type parameters

    • A

    • B

    • C

    Parameters

    • op1: OperatorFunction<T, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>

    Returns Observable<C>

  • Type parameters

    • A

    • B

    • C

    • D

    Parameters

    • op1: OperatorFunction<T, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>
    • op4: OperatorFunction<C, D>

    Returns Observable<D>

  • Type parameters

    • A

    • B

    • C

    • D

    • E

    Parameters

    • op1: OperatorFunction<T, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>
    • op4: OperatorFunction<C, D>
    • op5: OperatorFunction<D, E>

    Returns Observable<E>

  • Type parameters

    • A

    • B

    • C

    • D

    • E

    • F

    Parameters

    • op1: OperatorFunction<T, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>
    • op4: OperatorFunction<C, D>
    • op5: OperatorFunction<D, E>
    • op6: OperatorFunction<E, F>

    Returns Observable<F>

  • Type parameters

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    Parameters

    • op1: OperatorFunction<T, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>
    • op4: OperatorFunction<C, D>
    • op5: OperatorFunction<D, E>
    • op6: OperatorFunction<E, F>
    • op7: OperatorFunction<F, G>

    Returns Observable<G>

  • Type parameters

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    • H

    Parameters

    • op1: OperatorFunction<T, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>
    • op4: OperatorFunction<C, D>
    • op5: OperatorFunction<D, E>
    • op6: OperatorFunction<E, F>
    • op7: OperatorFunction<F, G>
    • op8: OperatorFunction<G, H>

    Returns Observable<H>

  • Type parameters

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    • H

    • I

    Parameters

    • op1: OperatorFunction<T, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>
    • op4: OperatorFunction<C, D>
    • op5: OperatorFunction<D, E>
    • op6: OperatorFunction<E, F>
    • op7: OperatorFunction<F, G>
    • op8: OperatorFunction<G, H>
    • op9: OperatorFunction<H, I>

    Returns Observable<I>

  • Type parameters

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    • H

    • I

    Parameters

    • op1: OperatorFunction<T, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>
    • op4: OperatorFunction<C, D>
    • op5: OperatorFunction<D, E>
    • op6: OperatorFunction<E, F>
    • op7: OperatorFunction<F, G>
    • op8: OperatorFunction<G, H>
    • op9: OperatorFunction<H, I>
    • Rest ...operations: OperatorFunction<any, any>[]

    Returns Observable<{}>

subscribe

  • subscribe(observer?: PartialObserver<T>): Subscription
  • subscribe(next: null | undefined, error: null | undefined, complete: () => void): Subscription
  • subscribe(next: null | undefined, error: (error: any) => void, complete?: undefined | (() => void)): Subscription
  • subscribe(next: (value: T) => void, error: null | undefined, complete: () => void): Subscription
  • subscribe(next?: undefined | ((value: T) => void), error?: undefined | ((error: any) => void), complete?: undefined | (() => void)): Subscription
  • Parameters

    • Optional observer: PartialObserver<T>

    Returns Subscription

  • deprecated

    Use an observer instead of a complete callback

    Parameters

    • next: null | undefined
    • error: null | undefined
    • complete: () => void
        • (): void
        • Returns void

    Returns Subscription

  • deprecated

    Use an observer instead of an error callback

    Parameters

    • next: null | undefined
    • error: (error: any) => void
        • (error: any): void
        • Parameters

          • error: any

          Returns void

    • Optional complete: undefined | (() => void)

    Returns Subscription

  • deprecated

    Use an observer instead of a complete callback

    Parameters

    • next: (value: T) => void
        • (value: T): void
        • Parameters

          • value: T

          Returns void

    • error: null | undefined
    • complete: () => void
        • (): void
        • Returns void

    Returns Subscription

  • Parameters

    • Optional next: undefined | ((value: T) => void)
    • Optional error: undefined | ((error: any) => void)
    • Optional complete: undefined | (() => void)

    Returns Subscription

toPromise

  • toPromise<T>(this: Observable<T>): Promise<T>
  • toPromise<T>(this: Observable<T>, PromiseCtor: typeof Promise): Promise<T>
  • toPromise<T>(this: Observable<T>, PromiseCtor: PromiseConstructorLike): Promise<T>
  • Type parameters

    • T

    Parameters

    • this: Observable<T>

    Returns Promise<T>

  • Type parameters

    • T

    Parameters

    • this: Observable<T>
    • PromiseCtor: typeof Promise

    Returns Promise<T>

  • Type parameters

    • T

    Parameters

    • this: Observable<T>
    • PromiseCtor: PromiseConstructorLike

    Returns Promise<T>

toString

  • toString(pretty?: boolean): Promise<string>
  • Returns a JSON string representation of the last known state of the entity.

    Parameters

    • Default value pretty: boolean = true

    Returns Promise<string>

Generated using TypeDoc