Skip to content

Latest commit

 

History

History
208 lines (123 loc) · 5.69 KB

_util_smart_app_context_d_.smartappcontext.md

File metadata and controls

208 lines (123 loc) · 5.69 KB

SmartAppSmartAppContext

SmartAppContext

Properties

Methods

api

api: SmartThingsClient

An instance of the SmartThings core API instantiated with the access token for the installed app instance.


config

config: ConfigMap

The SmartApp configuration object containing the values of all user selections made during app installation.

configBooleanValue

configBooleanValue(id: string): boolean

Returns the specified configuration setting typed as a boolean

Parameters:

Name Type Description
id string the id specified when the setting was created

Returns: boolean


configDateValue

configDateValue(id: string): Date

Returns the specified configuration setting typed as a Date object

Parameters:

Name Type Description
id string the id specified when the setting was created

Returns: Date


configDevices

configDevices(id: string): Promise‹DeviceContext[]›

Retrieves the devices specified in the configuration along with their names and labels (which are not stored in the configuration map and so require API calls)

Parameters:

Name Type Description
id string the id specified when the setting was created

Returns: Promise‹DeviceContext[]›


configDevicesWithState

configDevicesWithState(id: string): Promise‹DeviceStateContext[]›

Retrieves the devices specified in the configuration along with their names, labels, and the current values of all of their capabilities.

Parameters:

Name Type Description
id string the id specified when the setting was created

Returns: Promise‹DeviceStateContext[]›


configModeIds

configModeIds(id: string): string[]

Returns a list of mode ids from the specified mode configuration setting

Parameters:

Name Type Description
id string the id specified when the setting was created

Returns: string[]


configNumberValue

configNumberValue(id: string): number

Returns the specified configuration setting typed as a number

Parameters:

Name Type Description
id string the id specified when the setting was created

Returns: number


configStringValue

configStringValue(id: string): string

Returns the specified configuration setting typed as a string

Parameters:

Name Type Description
id string the id specified when the setting was created

Returns: string


configTimeString

configTimeString(id: string): string

Returns the specified configuration setting typed as a time string

Parameters:

Name Type Description
id string the id specified when the setting was created

Returns: string


isAuthenticated

isAuthenticated(): boolean

Tests whether the context is authenticated to make API calls, i.e. has an accessToken. Note that this method does not actually test the validity of the token, but rather whether it is present or not. Contexts of CONFIGURATION lifecycle events are not authenticated. Therefore if an app needs to make API calls during the configuration lifecycle it must use a token store to authenicate itself.

Returns: boolean


retrieveTokens

retrieveTokens(): Promise‹SmartAppContext

Retrieve the tokens of the installed instance from the token store and return a new, authenticated SmartAppContext. This method is typically used to allow API calls to be made from the handlers of CONFIGURATION/PAGE lifecycle events.

Returns: Promise‹SmartAppContext


setLocationId

setLocationId(id: string): void

Sets the location of the app context. Explicitly setting the location is typically necessary when an API Access app is first authorized. It is not needed when handling lifecycle events.

Parameters:

Name Type Description
id string the location UUID

Returns: void