i-client
The Home Assistant client API. Once initialised, the client will make requests via **either** the websocket or HTTP API where appropriate
Methods
Call a service action
See
Signature
callService(params: Omit<CallServiceCommand, 'id' | 'type'>): Promise<State[]>;
Parameters
Name | Type | Description |
params | Omit<CallServiceCommand, 'id' | 'type'> | parameters to send with the service command |
Return Value
Promise<State[]>
Close the websocket connection
Signature
close(): Promise<void>;
Return Value
Promise<void>
Gets a list of areas registered with home assistant
Signature
getAreas(): Promise<HassArea[]>;
Return Value
Promise<HassArea[]>
Get a list of all registered calendars
Signature
getCalendars(): Promise<CalendarDetails>;
Return Value
Promise<CalendarDetails>
Get the current Home Assistant configuration
Signature
getConfig(): Promise<Config>;
Return Value
Promise<Config>
Get a list of all devices currently registered by home assistant
Signature
getDevices(): Promise<HassDevice[]>;
Return Value
Promise<HassDevice[]>
Get a list of all entities currently registered by home assistant
Signature
getEntities(): Promise<HassEntity[]>;
Return Value
Promise<HassEntity[]>
Retrieve all errors logged during the current session of Home Assistant as a plaintext response.
Signature
getErrorLog(): Promise<string>;
Return Value
Promise<string>
Get the complete list of events that can be listened to and the number of subscribers
Signature
getEvents(): Promise<EventDetails[]>;
Return Value
Promise<EventDetails[]>
Returns an array of state changes from the past
Signature
getHistory(params: GetHistoryParams): Promise<State[][]>;
Parameters
Return Value
Promise<State[][]>
Gets a list of entries from the Home Assistant logbook
Signature
getLogbook(params?: GetLogbookParams): Promise<LogBookEntry[]>;
Parameters
Return Value
Promise<LogBookEntry[]>
Get a list of all registered panels
Signature
getPanels(): Promise<Record<string, Panel>>;
Return Value
Promise<Record<string, Panel>>
Get a list of possible domains for services
Signature
getServiceDomains(): Promise<ServiceDomainDetails[]>;
Return Value
Promise<ServiceDomainDetails[]>
Get details of all the services currently registered in home assistant, grouped by domain
Signature
getServices(): Promise<Record<string, Service>>;
Return Value
Promise<Record<string, Service>>
Get the current state of a specific entity
Signature
getState(entityId: string): Promise<State>;
Parameters
Name | Type | Description |
entityId | string | The entity id in the form . |
Return Value
Promise<State>
Get a list of the current states of all entities
Signature
getStates(): Promise<State[]>;
Return Value
Promise<State[]>
Subscribe to a trigger. See https://developers.home-assistant.io/docs/api/websocket/#subscribe-to-trigger
Signature
registerTrigger(trigger: SubscribeToTriggerMessage['trigger'], callback: (event: unknown) => void | Promise<void>): Promise<void>;
Parameters
Return Value
Promise<void>
Subscribe to events
Signature
subscribeToEvents(callback: (message: Event | TriggerEventMessage['event']) => void): Promise<void>;
Parameters
Name | Type | Description |
callback | (message: Event | TriggerEventMessage['event']) => void | Fire this callback when any Home Assistant events are triggered |
Return Value
Promise<void>
Subscribe to events of a specific type
Signature
subscribeToEvents(type: string, callback: (message: Event | TriggerEventMessage['event']) => void): Promise<void>;
Parameters
Name | Type | Description |
type | string | type of the event to listen for |
callback | (message: Event | TriggerEventMessage['event']) => void | Fire this callback when the Home Assistant events are triggered |
Return Value
Promise<void>