### Install SmartThings Core SDK Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Home Install the SDK using npm. This is the first step to using the SmartThings Core SDK in your project. ```bash npm install @smartthings/core-sdk ``` -------------------------------- ### get Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Installed-Apps Retrieves the definition of a specific installed app. Requires the UUID of the installed app. ```APIDOC ## get ### Description Returns the specified installed app definition. ### Parameters #### Path Parameters - **installedAppId** (string) - Required - The UUID of the installed app. ``` -------------------------------- ### get Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Subscriptions Gets the definition of a specific subscription for the specified installed app. Requires the subscription name and optionally accepts the installedAppId. ```APIDOC ## get ### Description Gets the definition of a specific subscription for the specified installed app. ### Parameters #### Query Parameters - **name** (string) - Required - The alphanumeric name of the subscription. - **installedAppId** (string) - Optional - The UUID of the installed app. ``` -------------------------------- ### listConfigurations Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Installed-Apps Lists configurations of an installed app instance. Requires the UUID of the installed app. Options include the desired configuration status. ```APIDOC ## listConfigurations ### Description List configurations of an installed app instance. ### Parameters #### Path Parameters - **installedAppId** (string) - Required - The UUID of the installed app. ### Query Parameters - **configurationStatus** (string) - Optional - Filter by configuration status. ``` -------------------------------- ### getConfiguration Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Installed-Apps Retrieves a specific installed app configuration. Requires the UUID of the installed app and the UUID of the configuration. ```APIDOC ## getConfiguration ### Description Returns a specific installed app configuration. ### Parameters #### Path Parameters - **installedAppId** (string) - Required - The UUID of the installed app. - **configurationId** (string) - Required - The UUID of the configuration. ``` -------------------------------- ### create Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Installed-Apps Creates a new installed app instance. Requires configuration data for the app instance. ```APIDOC ## create ### Description Creates an installed app instance. ### Request Body - **configuration** (object) - Required - Configuration data for the app instance. ``` -------------------------------- ### list Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Subscriptions Returns a list of all the subscriptions for an installed app. Optionally accepts the installedAppId. ```APIDOC ## list ### Description Returns a list of all the subscriptions for an installed app. ### Parameters #### Query Parameters - **installedAppId** (string) - Optional - The UUID of the installed app. ``` -------------------------------- ### create Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Subscriptions Creates a subscription for an installed app instance. Requires the subscription data definition and optionally accepts the installedAppId. ```APIDOC ## create ### Description Creates a subscription for an installed app instance. ### Parameters #### Request Body - **data** (object) - Required - The data definition of the subscription. #### Query Parameters - **installedAppId** (string) - Optional - The UUID of the installed app. ``` -------------------------------- ### installedApps Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Schema Returns a list of installed ST Schema connector instances in a specified location. ```APIDOC ## installedApps ### Description Returns a list of the installed ST Schema connector instances in the specified location. ### Method GET ### Endpoint /smartthings/locations/{locationId}/installed-apps ### Parameters #### Path Parameters - **locationId** (string) - Required - The locationId UUID of the location. ### Request Example None ### Response #### Success Response (200) - **installedApps** (array) - A list of installed ST Schema connector instances. ``` -------------------------------- ### list Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Installed-Apps Returns a list of installed app instances matching the query options or all instances accessible by the user if no options are specified. Query options include locationId, installedAppStatus, installedAppType, and deviceId. Options can be single values or arrays. ```APIDOC ## list ### Description Returns a list of installed app instances matching the query options or all instances accessible by the user if no options are specified. ### Query Options - **locationId** (string or array) - Filter by location ID. - **installedAppStatus** (string or array) - Filter by installed app status. - **installedAppType** (string or array) - Filter by installed app type. - **deviceId** (string or array) - Filter by device ID. ``` -------------------------------- ### Installed Apps Endpoint Source: https://github.com/smartthingscommunity/smartthings-core-sdk/blob/main/README.md Operations related to installed SmartApps. ```APIDOC ## Installed Apps Endpoint ### Description Operations related to installed SmartApps. ### Method Not specified in source. ### Endpoint `/installedApps` ### Parameters No parameters specified in source. ### Request Example No request example specified in source. ### Response No response details specified in source. ``` -------------------------------- ### get Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Devices Returns a description of the specified device. Requires the UUID of the device. ```APIDOC ## get ### Description Returns a description of the specified device. ### Requires - UUID (string): The unique identifier of the device. ``` -------------------------------- ### Schema Endpoint Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Home Operations for ST Schema connectors and installed instances, including listing devices owned by each installed instance. ```APIDOC ## Schema Endpoint ### Description Operations for ST Schema connectors and installed instances, including listing devices owned by each installed instance. ### Endpoint /schema ``` -------------------------------- ### getInstalledApps Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Schema Retrieves a specific installed instance of an ST Schema connector, including its devices. ```APIDOC ## getInstalledApps ### Description Returns a specific installed instance of an ST Schema connector. The returned object includes a list of the devices created by the instance. ### Method GET ### Endpoint /smartthings/installed-apps/{installedAppId} ### Parameters #### Path Parameters - **installedAppId** (string) - Required - The UUID of the installed app instance. ### Request Example None ### Response #### Success Response (200) - **installedApp** (object) - The installed ST Schema connector instance details, including a list of devices. ``` -------------------------------- ### Implement WinstonLoggerProxy for SmartThings SDK Source: https://github.com/smartthingscommunity/smartthings-core-sdk/blob/main/README.md Example implementation of the SDK's Logger interface to proxy logs to a Winston logger. Note the mapping of Winston's 'silly' level to the SDK's 'trace' level. ```typescript import { Logger as WinstonLogger } from 'winston' import { Logger } from '@smartthings/core-sdk' export class WinstonLoggerProxy implements Logger { proxy: WinstonLogger level: string constructor(winstonLogger) { this.level = proxy.level } trace(message: any, ...args: any[]): void { // Winston doesn't have a "trace" level but it has a "silly" level in the same place. proxy.silly(message, args) } debug(message: any, ...args: any[]): void { proxy.debug(message, args) } info(message: any, ...args: any[]): void { proxy.info(message, args) } ... isTraceEnabled(): boolean { return proxy.isSillyEnabled() } ... ``` -------------------------------- ### Schema Endpoint Source: https://github.com/smartthingscommunity/smartthings-core-sdk/blob/main/README.md Operations for ST Schema connectors and installed instances, along with operations to list the Devices owned by each installed instance. ```APIDOC ## Schema Endpoint ### Description Operations for ST Schema connectors and installed instances, along with operations to list the Devices owned by each installed instance. ### Method Not specified in source. ### Endpoint `/schema` ### Parameters No parameters specified in source. ### Request Example No request example specified in source. ### Response No response details specified in source. ``` -------------------------------- ### get Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Modes Get the definition of a specific location. Requires the UUID of the location. ```APIDOC ## get ### Description Get the definition of a specific location. Requires the UUID of the location. ### Method GET ### Endpoint /locations/{locationId} ### Parameters #### Path Parameters - **locationId** (string) - Required - The UUID of the location. ### Request Example None ### Response #### Success Response (200) - **locationId** (string) - The UUID of the location. - **name** (string) - The name of the location. - **countryCode** (string) - The country code of the location. - **latitude** (number) - The latitude of the location. - **longitude** (number) - The longitude of the location. - **regionName** (string) - The region name of the location. - **timeZoneId** (string) - The time zone ID of the location. - **locale** (string) - The locale of the location. #### Response Example { "locationId": "string", "name": "string", "countryCode": "string", "latitude": 0.0, "longitude": 0.0, "regionName": "string", "timeZoneId": "string", "locale": "string" } ``` -------------------------------- ### createEvent Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Installed-Apps Creates events for an installed app. Note that this method is here in support of future functionality not yet available in the SmartThings platform. Requires a data object containing lists of events, and the UUID of the installed app. ```APIDOC ## createEvent ### Description Creates events for an installed app. Note that this method is here in support of future functionality not yet available in the SmartThings platform. ### Parameters #### Path Parameters - **installedAppId** (string) - Required - The UUID of the installed app. ### Request Body - **eventData** (object) - Required - A data object containing lists of events. ``` -------------------------------- ### Get App Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Apps Returns a specific app by its unique identifier. ```APIDOC ## get ### Description Returns a specific app. ### Method GET ### Endpoint /apps/{appIdOrName} ``` -------------------------------- ### tokenInfo Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Installed-Apps Retrieves the token information for an installed app user. ```APIDOC ## tokenInfo ### Description Returns the token info for an installed app user. ### Parameters #### Path Parameters - **installedAppId** (string) - Required - The UUID of the installed app. ``` -------------------------------- ### get Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Capabilities Retrieves the current details of a specific capability. Requires capability ID and version. ```APIDOC ## get ### Description Get the current capability. ### Parameters #### Query Parameters - **capabilityID** (string) - Required - The ID of the capability. - **capabilityVersion** (string) - Required - The version of the capability. ``` -------------------------------- ### Get App Settings Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Apps Retrieves the settings for a specific app. ```APIDOC ## getSettings ### Description Get the settings of an app. Settings are string name / value pairs for optional use by the developer. ### Method GET ### Endpoint /apps/{appIdOrName}/settings ``` -------------------------------- ### delete Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Installed-Apps Deletes an installed app instance. If the client is configured with an installedApp ID, this value can be omitted. Requires the UUID of the installed app. ```APIDOC ## delete ### Description Deletes an installed app instance. ### Parameters #### Path Parameters - **installedAppId** (string) - Required - The UUID of the installed app. If the client is configured with an installedApp ID, this value can be omitted. ``` -------------------------------- ### Installed Apps Endpoint Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Home Operations related to installed apps, which may be useful for creating developer tools and automating tests. ```APIDOC ## Installed Apps Endpoint ### Description Operations related to installed apps, which may be useful for creating developer tools and automating tests. ### Endpoint /installedApps ``` -------------------------------- ### getLatestConfiguration Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Installed-Apps Retrieves the most recent configuration, authorized or not. Requires the installed app ID. ```APIDOC ## getLatestConfiguration ### Description Returns the most recent configuration, authorized or not. ### Parameters #### Path Parameters - **installedAppId** (string) - Required - The UUID of the installed app. ``` -------------------------------- ### Get Scene Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Scenes Retrieves the details of a specific scene using its UUID. ```APIDOC ## get ### Description Get a specific scene. ### Parameters #### Path Parameters - **sceneId** (string) - Required - The UUID of the scene. ``` -------------------------------- ### updateConfiguration Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Installed-Apps Updates an Installed App configuration. Call implicitly operates on the latest STAGED configuration. Requires the UUID of the installed app and data for the new configuration. ```APIDOC ## updateConfiguration ### Description Updates an Installed App configuration. Call implicitly operates on the latest STAGED configuration. ### Parameters #### Path Parameters - **installedAppId** (string) - Required - The UUID of the installed app. ### Request Body - **configurationData** (object) - Required - Data for the new configuration. ``` -------------------------------- ### get Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Schema Returns a specific ST schema connector by its ID. ```APIDOC ## get ### Description Returns a specific ST schema connector. ### Method GET ### Endpoint /smartthings/schema/connectors/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The id of the "endpointApp" UUID of the connector, e.g. "viper_799ff3a0-8249-11e9-9bf1-b5c7d651c2c3" ### Request Example None ### Response #### Success Response (200) - **connector** (object) - The ST Schema connector details. ``` -------------------------------- ### update Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Installed-Apps Updates the display name of an installed app instance. Requires the UUID of the installed app and a request containing the display name. ```APIDOC ## update ### Description Updates the display name of an installed app instance. ### Parameters #### Path Parameters - **installedAppId** (string) - Required - The UUID of the installed app. ### Request Body - **displayName** (string) - Required - The new display name for the installed app. ``` -------------------------------- ### patchConfiguration Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Installed-Apps Allows specific configuration keys to be removed or upserted from any configuration that may already exist. This operation is only supported on install configurations with a status of STAGED. Useful for iteratively configuring an installed app. Requires the UUID of the installed app, the UUID of the configuration, and the data requesting the upserts and removals of configuration items. ```APIDOC ## patchConfiguration ### Description Allows specific configuration keys to be removed / upserted from any configuration that may already exist. This operation is only supported on install configurations with a status of STAGED. Useful for iteratively configuring an installed app. ### Parameters #### Path Parameters - **installedAppId** (string) - Required - The UUID of the installed app. - **configurationId** (string) - Required - The UUID of the configuration. ### Request Body - **patchData** (object) - Required - Data requesting the upserts and removals of configuration items. ``` -------------------------------- ### Get Device Profile Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Device-Profiles Retrieves the definition of a specific device profile. ```APIDOC ## get ### Description Gets the definition of a specific device profile. ### Method GET ### Endpoint /deviceprofiles/{deviceProfileId} ### Parameters #### Path Parameters - **deviceProfileId** (string) - Required - The UUID of the device profile. ### Response #### Success Response (200) - **deviceProfile** (object) - The device profile definition. ``` -------------------------------- ### Get Room Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Rooms Retrieves details for a specific room within a location. ```APIDOC ## get ### Description Get a specific room in a location. ### Method GET ### Endpoint /locations/{locationId}/rooms/{roomId} ### Parameters #### Path Parameters - **locationId** (UUID) - Required - The UUID of the location. - **roomId** (UUID) - Required - The UUID of the room. ``` -------------------------------- ### Get Schedule Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Schedules Retrieves details for a specific schedule by its name. The installedAppId is required unless it's already configured in the client. ```APIDOC ## get ### Description Get a specific schedule. ### Parameters #### Path Parameters * **name** (string) - Required - The alphanumeric name of the schedule. * **installedAppId** (string) - Required - UUID of the installed app. If the client is configured with an installed app ID then this parameter is not needed. ### Request Example ``` // Assuming client is configured with installedAppId schedules.get({ name: "my-schedule" }) // Explicitly providing installedAppId schedules.get({ name: "my-schedule", installedAppId: "your-installed-app-id" }) ``` ### Response #### Success Response (200) - schedule (object) - The details of the requested schedule. ``` -------------------------------- ### getAuthorizedConfiguration Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Installed-Apps Retrieves the current authorized configuration, or undefined if there is no authorized configuration. Requires the UUID of the installed app. ```APIDOC ## getAuthorizedConfiguration ### Description Returns the current authorized configuration, or undefined if there is no authorized configuration. ### Parameters #### Path Parameters - **installedAppId** (string) - Required - The UUID of the installed app. ``` -------------------------------- ### List Schedules Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Schedules Retrieves a list of all schedules associated with an installed application. The installedAppId is required unless it's already configured in the client. ```APIDOC ## list ### Description Returns a list of schedules for an installed app. ### Parameters #### Path Parameters * **installedAppId** (string) - Required - UUID of the installed app. If the client is configured with an installed app ID then this parameter is not needed. ### Request Example ``` // Assuming client is configured with installedAppId await schedules.list() // Explicitly providing installedAppId schedules.list({ installedAppId: "your-installed-app-id" }) ``` ### Response #### Success Response (200) - schedules (array) - A list of schedule objects. ``` -------------------------------- ### getCurrentConfiguration Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Installed-Apps Retrieves the current authorized configuration, or the latest configuration of any status if none are authorized. Requires the UUID of the installed app. ```APIDOC ## getCurrentConfiguration ### Description Returns the current authorized configuration, or the latest configuration of any status if none are authorized. ### Parameters #### Path Parameters - **installedAppId** (string) - Required - The UUID of the installed app. ``` -------------------------------- ### deleteInstalledApp Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Schema Deletes a specific installed instance of an ST Schema connector and all its associated devices. ```APIDOC ## deleteInstalledApp ### Description Deletes a specific installed instance of an ST Schema connector. This operation will also delete all devices created by the instance. ### Method DELETE ### Endpoint /smartthings/installed-apps/{installedAppId} ### Parameters #### Path Parameters - **installedAppId** (string) - Required - The id of the connector to be deleted. ### Request Example None ### Response #### Success Response (200) - **message** (string) - Confirmation message. ``` -------------------------------- ### List Rules Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Rules Lists the rules associated with a specific location and principal (user or installed app). The location UUID is required unless configured client-side. ```APIDOC ## list ### Description Lists the rules for a location and the access token principal. The principal is the user in the case of a Personal Access Token (PAT) or the installed app in the case of a SmartApp token. The rules belonging to one principal cannot see the rules belonging to another principal. ### Parameters #### Path Parameters - **locationId** (string) - Required - The UUID of the location. #### Query Parameters - **principal** (string) - Required - The principal associated with the rules (e.g., user or installed app). ### Request Example ``` GET /locations/{locationId}/rules?principal={principal} ``` ### Response #### Success Response (200) - **rules** (array) - A list of rule objects. ``` -------------------------------- ### Get App OAuth Info Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Apps Retrieves the OAuth information for a specific app, including name, scopes, and redirect URLs. ```APIDOC ## getOauth ### Description Returns the OAuth information for this app, including the name, scopes, and redirect URLs, if any. Requires the appId (UUID) or the appName unique name. ### Method GET ### Endpoint /apps/{appIdOrName}/oauth ``` -------------------------------- ### Get Location Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Locations Get the definition of a specific location. ```APIDOC ## get ### Description Get the definition of a specific location. ### Method GET ### Endpoint /locations/{locationId} ### Parameters #### Path Parameters - **locationId** (string) - Required - The UUID of the location. ### Response #### Success Response (200) - **locationId** (string) - The unique identifier for the location. - **name** (string) - The name of the location. - **countryCode** (string) - The country code for the location. - **latitude** (number) - The latitude of the location. - **longitude** (number) - The longitude of the location. - **locale** (string) - The locale for the location. - **timezoneId** (string) - The timezone ID for the location. - **virtual** (boolean) - Indicates if the location is virtual. - **supportedApis** (array) - A list of supported APIs for the location. ### Response Example ```json { "locationId": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "name": "My Home", "countryCode": "US", "latitude": 34.0522, "longitude": -118.2437, "locale": "en-US", "timezoneId": "America/Los_Angeles", "virtual": false, "supportedApis": ["நர்ஸ்", "நர்ஸ்"] } ``` ``` -------------------------------- ### getCapabilityStatus Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Devices Gets the attribute values for the specified component capability. Requires the UUID of the device, the alphanumeric component ID, and the alphanumeric capability ID. ```APIDOC ## getCapabilityStatus ### Description Gets the attribute values for the specified component capability. ### Requires - UUID (string): The unique identifier of the device. - component ID (string): The alphanumeric component ID. - capability ID (string): The alphanumeric capability ID. ``` -------------------------------- ### Initialize SmartThingsClient with PAT Source: https://github.com/smartthingscommunity/smartthings-core-sdk/blob/main/README.md Initialize the SmartThingsClient using a Personal Access Token (PAT) for authentication. Requires the `r:locations:*` scope. ```javascript const {SmartThingsClient, BearerTokenAuthenticator} = require('@smartthings/core-sdk') const client = new SmartThingsClient(new BearerTokenAuthenticator('YOUR-PAT-HERE')) client.locations.list().then(locations => { console.log(`Found ${locations.length} locations`) }) ``` -------------------------------- ### create Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Devices Creates a device. Requires the device definition. If the client configuration specifies a locationID and installedAppId then these values don't need to be included in the definition. ```APIDOC ## create ### Description Creates a device. ### Requires - device definition (object): The definition of the device to create. ### Note If the client configuration specifies a locationID and installedAppId, these values do not need to be included in the definition. ``` -------------------------------- ### Initialize SmartThingsClient and List Locations Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Home Initialize the SmartThingsClient with a BearerTokenAuthenticator using a Personal Access Token (PAT). Then, list all accessible locations. ```javascript const {SmartThingsClient, BearerTokenAuthenticator} = require('@smartthings/core-sdk') const client = new SmartThingsClient(new BearerTokenAuthenticator('{YOUR-PAT-TOKEN}')) client.locations.list().then(locations => { console.log(`Found ${locations.length} locations`) }) ``` -------------------------------- ### Create Device Profile Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Device-Profiles Creates a new device profile. ```APIDOC ## create ### Description Creates a device profile. ### Method POST ### Endpoint /deviceprofiles ### Parameters #### Request Body - **deviceProfileDefinition** (object) - Required - The definition of the device profile. ### Request Example { "deviceProfileDefinition": { "name": "My Smart Light", "components": [ { "id": "main", "capabilities": [ { "id": "switch", "version": 1 } ] } ] } } ### Response #### Success Response (201) - **deviceProfileId** (string) - The UUID of the newly created device profile. ``` -------------------------------- ### create Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Schema Creates a new ST Schema connector. ```APIDOC ## create ### Description Create an ST Schema connector. ### Method POST ### Endpoint /smartthings/schema/connectors ### Parameters #### Request Body - **data** (object) - Required - The data definition of the connector. ### Request Example ```json { "data": { "connector_definition": "..." } } ``` ### Response #### Success Response (200) - **connector** (object) - The newly created ST Schema connector details. ``` -------------------------------- ### create Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Capabilities Creates a new custom capability. ```APIDOC ## create ### Description Create a new capability. ### Parameters None explicitly mentioned, but typically requires capability definition. ``` -------------------------------- ### Create Daily Schedule Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Schedules Creates a schedule that runs once per day at a specific time. The installedAppId is required unless it's already configured in the client. Time zone can optionally be specified. ```APIDOC ## runDaily ### Description Create a schedule that runs at a specific time once per day. ### Parameters #### Path Parameters * **name** (string) - Required - The name for the schedule. * **timeConfig** (string | Date | object) - Required - Configuration for the daily run time. Can be an ISO date string, a 24-hour hh:mm time expression, or a Date object. * **installedAppId** (string) - Required - UUID of the installed app. If the client is configured with an installed app ID then this parameter is not needed. * **timeZone** (string) - Optional - The time zone for the schedule. Defaults to UTC or the time zone derived from geo-coordinates if available. ### Request Example ``` // Using ISO date string // Assuming client is configured with installedAppId schedules.runDaily({ name: "daily-summary", timeConfig: "2020-02-08T16:35:00.000-0800" }) // Using hh:mm time expression schedules.runDaily({ name: "daily-checkin", timeConfig: "10:00" }) // Using Date object const runAt = new Date(); runAt.setHours(18, 0, 0, 0); schedules.runDaily({ name: "evening-routine", timeConfig: runAt }) // With specified time zone schedules.runDaily({ name: "daily-report", timeConfig: "08:00", timeZone: "Europe/London" }) // Explicitly providing installedAppId schedules.runDaily({ name: "daily-task", timeConfig: "23:00", installedAppId: "your-installed-app-id" }) ``` ### Response #### Success Response (200) - schedule (object) - The created daily schedule object. ``` -------------------------------- ### Create Schedule Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Schedules Creates a new schedule with the provided definition data. The installedAppId is required unless it's already configured in the client. ```APIDOC ## create ### Description Create a schedule. ### Parameters #### Path Parameters * **data** (object) - Required - The data for the schedule definition. * **installedAppId** (string) - Required - UUID of the installed app. If the client is configured with an installed app ID then this parameter is not needed. ### Request Example ``` const scheduleData = { /* ... schedule definition ... */ }; // Assuming client is configured with installedAppId schedules.create({ data: scheduleData }) // Explicitly providing installedAppId schedules.create({ data: scheduleData, installedAppId: "your-installed-app-id" }) ``` ### Response #### Success Response (200) - schedule (object) - The created schedule object. ``` -------------------------------- ### createPresentation Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Capabilities Creates a new presentation for a capability. Requires capability ID, version, and presentation details. ```APIDOC ## createPresentation ### Description Creates a new presentation. ### Parameters #### Query Parameters - **capabilityID** (string) - Required - The ID of the capability. - **capabilityVersion** (string) - Required - The version of the capability. #### Request Body - **presentation** (object) - Required - The presentation details to create. ``` -------------------------------- ### Import SmartThings Core SDK for NodeJS Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Locations Import the necessary components from the SmartThings core SDK for NodeJS. ```typescript const {SmartThingsClient, BearerTokenAuthenticator} = require('@smartthings/core-sdk') ``` -------------------------------- ### list Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Devices Returns a list of devices matching the query options or all devices accessible by the user if no options are specified. Options for the query are capability, capabilities, locationId, deviceId. These can be single values or arrays. ```APIDOC ## list ### Description Returns a list of devices matching the query options or all devices accessible by the user if no options are specified. ### Options - capability (string or array) - capabilities (string or array) - locationId (string or array) - deviceId (string or array) ``` -------------------------------- ### sendCommand Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Devices Sends the specified command or commands to the device and component defined in the specified config entry. The end result is the same as calling the executeCommand method, but this method accepts a SmartApp config entry for convenience. Requires the config entry specifying the device UUID and component, a capability ID or list of commands, the command name, and a list of arguments. ```APIDOC ## sendCommand ### Description Sends the specified command or commands to the device and component defined in the specified config entry. This method accepts a SmartApp config entry for convenience. ### Requires - config entry (object): Specifies the device UUID and component. - capability ID or list of commands (string or array) - command name (string) - arguments (array) ``` -------------------------------- ### Delete Location Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Locations Deletes a location and all associated devices and installed apps. ```APIDOC ## delete ### Description Deletes a location and all of the devices and installed apps associated with it. ### Method DELETE ### Endpoint /locations/{locationId} ### Parameters #### Path Parameters - **locationId** (string) - Required - The UUID of the location to delete. ### Response #### Success Response (204) No content is returned on successful deletion. ``` -------------------------------- ### create Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Modes Creates a location. Requires the location definition. ```APIDOC ## create ### Description Creates a location. Requires the location definition. ### Method POST ### Endpoint /locations ### Parameters #### Request Body - **name** (string) - Required - The name of the location. - **countryCode** (string) - Required - The country code of the location. - **latitude** (number) - Optional - The latitude of the location. - **longitude** (number) - Optional - The longitude of the location. - **regionName** (string) - Optional - The region name of the location. - **timeZoneId** (string) - Optional - The time zone ID of the location. - **locale** (string) - Optional - The locale of the location. ### Request Example { "name": "My Home", "countryCode": "US", "latitude": 34.0522, "longitude": -118.2437, "timeZoneId": "America/Los_Angeles", "locale": "en-US" } ### Response #### Success Response (201) - **locationId** (string) - The UUID of the newly created location. #### Response Example { "locationId": "string" } ``` -------------------------------- ### List Apps Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Apps Returns a list of all apps belonging to the user. ```APIDOC ## list ### Description Returns a list of all apps belonging to the user. ### Method GET ### Endpoint /apps ``` -------------------------------- ### Organizations Endpoint Source: https://github.com/smartthingscommunity/smartthings-core-sdk/blob/main/README.md Operations to list and get Organizations. Future feature. Not yet supported. ```APIDOC ## Organizations Endpoint ### Description Operations to list and get Organizations. Future feature. Not yet supported. ### Method Not specified in source. ### Endpoint `/organizations` ### Parameters No parameters specified in source. ### Request Example No request example specified in source. ### Response No response details specified in source. ``` -------------------------------- ### Create Location Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Locations Creates a location. ```APIDOC ## create ### Description Creates a location. ### Method POST ### Endpoint /locations ### Parameters #### Request Body - **name** (string) - Required - The name of the location. - **countryCode** (string) - Optional - The country code for the location. - **locale** (string) - Optional - The locale for the location. - **timezoneId** (string) - Optional - The timezone ID for the location. ### Request Example ```json { "name": "My New Location", "countryCode": "CA", "locale": "en-CA", "timezoneId": "America/Toronto" } ``` ### Response #### Success Response (201) - **locationId** (string) - The unique identifier for the newly created location. - **name** (string) - The name of the location. - **countryCode** (string) - The country code for the location. - **locale** (string) - The locale for the location. - **timezoneId** (string) - The timezone ID for the location. ### Response Example ```json { "locationId": "f0e9d8c7-b6a5-4321-fedc-ba9876543210", "name": "My New Location", "countryCode": "CA", "locale": "en-CA", "timezoneId": "America/Toronto" } ``` ``` -------------------------------- ### Create App Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Apps Creates a new app. Requires a SignatureType and whether or not confirmation is required. ```APIDOC ## create ### Description Creates a new app. Requires a SignatureType and whether or not confirmation is required (true / false). For WEBHOOK_SMART_APPs the default SignatureType is ST_PADLOCK. ### Method POST ### Endpoint /apps ### Parameters #### Request Body - **signatureType** (string) - Required - The type of signature to use for the app. - **confirmationRequired** (boolean) - Required - Whether or not confirmation is required for the app. ``` -------------------------------- ### Import SmartThingsClient for NodeJS Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Home Import the SmartThingsClient for use in NodeJS environments. This allows you to instantiate the client for API interactions. ```javascript const {SmartThingsClient} = require('@smartthings/core-sdk') ``` -------------------------------- ### listVersions Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Capabilities Retrieves a list of versions for a specific capability. Requires the capability ID. ```APIDOC ## listVersions ### Description Get a list of the versions of the capability. ### Parameters #### Query Parameters - **capabilityID** (string) - Required - The ID of the capability. ``` -------------------------------- ### list Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Capabilities Retrieves a list of custom capabilities. Requires the namespace to be specified. ```APIDOC ## list ### Description Get a list of custom capabilities. ### Parameters #### Query Parameters - **namespace** (string) - Required - The namespace to filter capabilities by. ``` -------------------------------- ### delete Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Modes Deletes a location and all of the devices and installed apps associated with it. Requires the UUID of the location. ```APIDOC ## delete ### Description Deletes a location and all of the devices and installed apps associated with it. Requires the UUID of the location. ### Method DELETE ### Endpoint /locations/{locationId} ### Parameters #### Path Parameters - **locationId** (string) - Required - The UUID of the location to delete. ### Request Example None ### Response #### Success Response (204) None #### Response Example None ``` -------------------------------- ### sendCommands Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Devices Sends a list of specified command or commands to the device and component defined in the specified config entry. The end result is the same as calling the executeCommand method, but this method accepts a SmartApp config entry for convenience. Requires the config entry specifying the device UUID and component, a capability ID or list of commands, the command name, and a list of arguments. ```APIDOC ## sendCommands ### Description Sends a list of specified command or commands to the device and component defined in the specified config entry. This method accepts a SmartApp config entry for convenience. ### Requires - config entry (object): Specifies the device UUID and component. - capability ID or list of commands (string or array) - command name (string) - arguments (array) ``` -------------------------------- ### Configure SmartThingsClient with Custom Logger Source: https://github.com/smartthingscommunity/smartthings-core-sdk/blob/main/README.md Pass a custom logger implementation, such as WinstonLoggerProxy, to the SmartThingsClient configuration. ```javascript const config = { logger: new WinstonLoggerProxy(myWinstonLoggerInstance) } const client = new SmartThingsClient(new BearerTokenAuthenticator('{YOUR-PAT-TOKEN}'), config) ``` -------------------------------- ### Import SmartThingsClient for ES2015+ Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Home Import the SmartThingsClient using ES2015+ module syntax. This is suitable for modern JavaScript and TypeScript projects. ```javascript import {SmartThingsClient} from '@smartthings/core-sdk' ``` -------------------------------- ### getComponentStatus Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Devices Gets the attribute values of the specified component of the device. Requires the UUID of the device and the alphanumeric component ID. ```APIDOC ## getComponentStatus ### Description Gets the attribute values of the specified component of the device. ### Requires - UUID (string): The unique identifier of the device. - component ID (string): The alphanumeric component ID. ``` -------------------------------- ### executeCommand Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Devices Sends the specified command to the device. Requires the UUID of the device and the single device command. ```APIDOC ## executeCommand ### Description Sends the specified command to the device. ### Requires - UUID (string): The unique identifier of the device. - command (object): The single device command to execute. ``` -------------------------------- ### executeCommands Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Devices Sends the specified list of commands to the device. Requires the UUID of the device and a list of commands to execute. ```APIDOC ## executeCommands ### Description Sends the specified list of commands to the device. ### Requires - UUID (string): The unique identifier of the device. - commands (array): A list of commands to execute. ``` -------------------------------- ### Get Rule Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Rules Retrieves details for a specific rule. The rule UUID and location UUID are required unless configured client-side. ```APIDOC ## get ### Description Get a specific rule. Requires the UUID of the rule and the UUID for the location. ### Parameters #### Path Parameters - **locationId** (string) - Required - The UUID of the location. - **ruleId** (string) - Required - The UUID of the rule. ### Request Example ``` GET /locations/{locationId}/rules/{ruleId} ``` ### Response #### Success Response (200) - **rule** (object) - The details of the specified rule. ``` -------------------------------- ### subscribeToCapability Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Subscriptions Creates a device subscription to a specific capability for all devices in a location. Intended for SmartApps or API Access apps with installedAppId and locationId. Requires capability, attribute, and subscriptionName. Optionally accepts options. ```APIDOC ## subscribeToCapability ### Description Creates a device subscription to a specific capability for all devices in a location. This method is intended for use from SmartApps or API access apps and must be called from the client configured with an installedAppId and locationId. ### Parameters #### Request Body - **capability** (string) - Required - An alphanumeric ID for the capability. - **attribute** (string) - Required - Defines what attribute(s) and attribute value(s) to subscribe to. Examples: 'switch', 'switch.on', '*'. - **subscriptionName** (string) - Required - The alphanumeric subscription name. - **options** (object) - Optional - A map of options. If 'stateChangeOnly' is not specified, the default is true. If 'modes' is not specified, events are sent for all modes. ``` -------------------------------- ### delete Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Subscriptions Deletes one or more subscriptions of an installed app. Requires the subscription name, or deletes all if not specified. Optionally accepts the installedAppId. ```APIDOC ## delete ### Description Deletes one or more subscriptions of an installed app. ### Parameters #### Query Parameters - **name** (string) - Required - The name of the subscription to be deleted. If not specified, all subscriptions are deleted. - **installedAppId** (string) - Optional - The UUID of the installed app. ``` -------------------------------- ### Presentation Endpoint Source: https://github.com/smartthingscommunity/smartthings-core-sdk/blob/main/README.md Operations to query and create Device Configurations and Presentations. ```APIDOC ## Presentation Endpoint ### Description Operations to query and create Device Configurations and Presentations. ### Method Not specified in source. ### Endpoint `/presentation` ### Parameters No parameters specified in source. ### Request Example No request example specified in source. ### Response No response details specified in source. ``` -------------------------------- ### getPresentation Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Capabilities Retrieves the presentation for a specified capability. Requires capability ID and version. ```APIDOC ## getPresentation ### Description Get the presentation for the specified capability. ### Parameters #### Query Parameters - **capabilityID** (string) - Required - The ID of the capability. - **capabilityVersion** (string) - Required - The version of the capability. ``` -------------------------------- ### Regenerate App OAuth Credentials Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Apps Regenerates the clientId and clientSecret for an app. Note that this will require re-authorization of installed app instances. ```APIDOC ## regenerateOauth ### Description Regenerate clientId and clientSecret for this app. Note that this operation will result in any currently authorized installed app instances to need to be re-authorized to make calls to SmartThings. Requires the appId (UUID) or the appName unique name and the new OAuth definition. ### Method POST ### Endpoint /apps/{appIdOrName}/oauth/regenerate ### Parameters #### Request Body - **oauthDefinition** (object) - Required - The new OAuth definition for the app. ``` -------------------------------- ### List Devices in Room Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Rooms Returns a list of all devices associated with a specific room. ```APIDOC ## listDevices ### Description Returns a list of all the devices in a room. ### Method GET ### Endpoint /locations/{locationId}/rooms/{roomId}/devices ### Parameters #### Path Parameters - **locationId** (UUID) - Required - The UUID of the location. - **roomId** (UUID) - Required - The UUID of the room. ``` -------------------------------- ### sendMessage Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Installed-Apps Sends a message group. Note that this method is here in support of future functionality not yet available in the SmartThings platform. Requires data for the message and the UUID for the installed app. ```APIDOC ## sendMessage ### Description Send a message group. Note that this method is here in support of future functionality not yet available in the SmartThings platform. ### Parameters #### Path Parameters - **installedAppId** (string) - Required - The UUID for the installed app. ### Request Body - **messageData** (object) - Required - Data for the message. ``` -------------------------------- ### Initialize SmartThings Client with Bearer Token Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Locations Initialize the SmartThings client using a BearerTokenAuthenticator with your Personal Access Token (PAT). ```typescript const client = new SmartThingsClient(new BearerTokenAuthenticator('{YOUR-PAT-TOKEN}')) ``` -------------------------------- ### listStandard Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Capabilities Retrieves a list of standard capabilities. ```APIDOC ## listStandard ### Description Get a list of standard capabilities. ### Parameters None ``` -------------------------------- ### Delete Schedules Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Schedules Deletes one or more schedules. If a schedule name is provided, only that schedule is deleted. Otherwise, all schedules for the installed app are deleted. The installedAppId is required unless it's already configured in the client. ```APIDOC ## delete ### Description Delete one or more schedules. ### Parameters #### Path Parameters * **name** (string) - Optional - The name of the schedule to be deleted. If not specified, all schedules of the installed app are deleted. * **installedAppId** (string) - Required - UUID of the installed app. If the client is configured with an installed app ID then this parameter is not needed. ### Request Example ``` // Delete a specific schedule // Assuming client is configured with installedAppId schedules.delete({ name: "my-schedule" }) // Delete all schedules schedules.delete() // Explicitly providing installedAppId for deleting all schedules schedules.delete({ installedAppId: "your-installed-app-id" }) ``` ### Response #### Success Response (200) - status (string) - Confirmation of deletion. ``` -------------------------------- ### updateSubscription Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Services Updates an existing location service subscription. This requires the subscription ID, the updated subscription definition, and the locationId. The locationId can be omitted if the client is configured with one. It also requires the installedApp UUID, which can be omitted if the client is configured with an installed App ID. ```APIDOC ## updateSubscription ### Description Modifies an existing subscription to location service data, allowing for changes to its configuration or parameters. ### Method PUT (assumed, based on function name) ### Endpoint /subscriptions/{subscriptionId} (assumed) ### Parameters #### Path Parameters - **subscriptionId** (UUID) - Required - The unique identifier of the subscription to update. #### Query Parameters - **locationId** (UUID) - Optional - The unique identifier for the location. Can be omitted if client is configured with a location ID. - **installedApp** (UUID) - Optional - The unique identifier for the installed application. Can be omitted if client is configured with an installed App ID. #### Request Body - **subscriptionDefinition** (object) - Required - The updated definition for the subscription. - **locationId** (UUID) - Required - The unique identifier for the location. - **installedApp** (UUID) - Required - The unique identifier for the installed application. ``` -------------------------------- ### subscribeToDevices Source: https://github.com/smartthingscommunity/smartthings-core-sdk/wiki/Subscriptions Creates device event subscriptions for specified devices. Intended for SmartApps or API Access apps with an installedAppId. Requires devices, capability, attribute, and subscriptionName. Optionally accepts options. ```APIDOC ## subscribeToDevices ### Description Creates device event subscriptions for one or more devices specified in a SmartApp device configuration setting. This method is intended for use from SmartApps or API Access apps and must be called from a client configured with an installedAppId. ### Parameters #### Request Body - **devices** (object) - Required - A SmartApp device configuration setting with one or more devices. - **capability** (string) - Required - The alphanumeric ID of the capability to subscribe to or '*' to subscribe to all capabilities of the devices. - **attribute** (string) - Required - Defines what attribute(s) and attribute value(s) to subscribe to. Examples: 'switch', 'switch.on', '*'. - **subscriptionName** (string) - Required - The alphanumeric subscription name. - **options** (object) - Optional - A map of options. If 'stateChangeOnly' is not specified, the default is true. If 'modes' is not specified, events are sent for all modes. ```