Function useEntityHistory

  • Load entity history by ID, using the REST API.

    type LightAttributes = { brightness: number }
    type LightState = 'on' | 'off'
    const LightHistory = () => {
    const { data } = useEntityHistory<LightAttributes, LightState>('entity.example_light', { refreshInterval: 60 * 1000 })
    return <pre>{JSON.stringify(data)}</pre>
    }

    Type Parameters

    • TAttributes = Record<string, any>

      Type of entity attributes attribute.

    • TState = string

      Type of entity state attribute.

    • TResponse = THomeassistantEntity<TAttributes, TState>[][]

      Type of expected API response. Constructed from TAttributes and TState by default.

    Parameters

    • entityId: string

      full entity ID as displayed in Homeassistant

    • Optional options: Partial<PublicConfiguration<TResponse, unknown, BareFetcher<TResponse>>>

    Returns SWRResponse<TResponse, any, undefined | Partial<PublicConfiguration<TResponse, any, BareFetcher<TResponse>>>>

Generated using TypeDoc