Initializes the ESPRMUser instance and stores tokens in local storage.
Object containing the access token, id token, and refresh token.
StaticeventGlobal event callbacks shared across all ESPRMUser instances.
StaticuserUser ID of the current user.
Adds a new daylight-based automation trigger for particular nodes.
The details of the daylight-based automation trigger and action to add.
A promise that resolves to an ESPAutomation instance containing details of the newly created automation.
Adds tags to the current user.
This method sends a request to associate the provided tags with the currently logged-in user.
An array of strings representing the tags to be added.
A promise that resolves to an ESPAPIResponse containing the result of the operation.
Adds a weather-based automation trigger for specific nodes.
The details of the automation to be added.
A promise that resolves to an ESPAutomation instance containing details of the newly created automation.
Assumes a user role and gets temporary security credentials for MQTT and other AWS services.
The assume role request containing optional userRole, groupIds, and/or nodeIds.
A promise that resolves to an AssumeRoleResponse containing access credentials (accessKey, secretKey, sessionToken).
userRole is optional. If not provided or empty, it defaults to "mqtt". Only "mqtt" and "videostream" are supported.videostream requires nodeIds to generate credentials.mqtt works with groupIds and nodeIds.groupIds and nodeIds are both optional arrays (max AssumeRoleConstants.MAX_NODE_IDS nodeIds and max AssumeRoleConstants.MAX_GROUP_IDS groupIds). Only one of them can be non-empty in a request.groupIds and nodeIds are empty or omitted, credentials will be granted for all groups the user has access to.Cancels pending command-response request(s).
Can cancel:
requestId (across all nodes)nodeIdnodeId with a specific cmdIdCancellation parameters. At least requestId or nodeId is required.
Cancellation status and count of removed requests.
Changes the user's password by providing their old password and a new password.
The user's current password.
The new password to set for the user.
A promise that resolves to an ESPAPIResponse indicating the success of the password change.
Cleans up resources associated with the user.
This method retrieves the device token map from storage, deletes the endpoint associated with the user's device token, and clears all tokens from storage.
A promise that resolves when the resources are cleaned up.
Enables or disables multi-factor authentication (MFA) for the current user.
A boolean indicating whether MFA should be enabled (true) or not (false).
A promise that resolves to an ESPAPIResponse object containing the result of the operation.
Confirms the account deletion request by providing a verification code.
The verification code sent to the user for account deletion confirmation.
A promise that resolves to an ESPAPIResponse indicating the success of the account deletion confirmation.
Confirms the phone number associated with the user by providing a verification code.
The verification code sent to the user for confirming the phone number.
A promise that resolves to an ESPAPIResponse indicating the success of the phone number confirmation.
Confirms the assignment of tags to the user by providing a verification code.
The verification code for confirming the tag assignment.
A promise that resolves to an ESPAPIResponse indicating the success of the tag assignment confirmation.
Adds a command-response request for up to 25 nodes in a single call.
Target node ids, command id, payload, and optional options.
A promise that resolves to the creation response (200 OK or 207 Multi-Status).
Creates an ESP device with the given parameters.
The name of the device.
The transport type to use.
Optionalsecurity: ESPSecurityThe security type to use (optional).
OptionalproofOfPossession: stringThe proof of possession string (optional).
OptionalsoftAPPassword: stringThe SoftAP password (optional).
Optionalusername: stringThe username (optional).
A promise that resolves to an ESPDevice instance.
Creates a file upload request and stores confirm metadata on the result.
Upload and confirm fields for the file.
A promise that resolves to the upload request instance.
Creates a new group with the specified parameters.
The details of the group to be created, including name, node IDs, description, and other optional fields.
A promise that resolves to an instance of the newly created ESPRMGroup.
Creates a platform endpoint for push notifications.
The parameters required to create the platform endpoint.
A promise resolving to the platform endpoint.
Deletes the custom data value associated with the specified key for the current user. This method sends a request to delete the custom data value for the given key associated with the currently logged-in user.
The key for which the custom data value is to be deleted.
A promise that resolves to a success response upon deleting the custom data.
Deletes the custom data entry associated with the specified key for the current user. This method sends a request to delete the custom data entry for the specified key associated with the currently logged-in user.
The key of the custom data entry to be deleted.
A promise that resolves to an ESPAPIResponse indicating the success or failure of the operation.
Deletes the custom data pemissions associated with the specified key for the current user. This method sends a request to delete the custom data permissions for the given key associated with the currently logged-in user.
The key for which the custom data permissions is to be deleted.
A promise that resolves to a success response upon deleting the custom data permissions.
Deletes a platform endpoint associated with the specified device token or endpoint.
OptionaldeviceToken: stringThe mobile device token used for identifying the platform endpoint.
Optionalendpoint: stringThe unique endpoint identifier to delete.
A promise resolving to the API response, indicating success or failure.
Downloads an uploaded file by id.
The file id to download.
Optionalparams: ESPFileDownloadParamsOptional lookup scope and download options.
File bytes in the requested format.
Retrieves an automation based on the provided automation ID.
The ID of the automation to be fetched.
A promise that resolves to an ESPAutomation instance containing the automation details.
Retrieves a list of all automations with optional pagination.
A promise that resolves to a paginated response containing automation data.
Fetches command-response request(s) by id previously created via createCmdRespRequest.
When nodeId is omitted the lookup uses requestId alone and may return
multiple records (one per node for a multi-node send). Pass nodeId to
scope the query to a specific node.
The request id returned by createCmdRespRequest.
OptionalnodeId: stringOptional node id to scope the lookup.
A promise that resolves to matching request records (empty when the backend has no record for the id).
Fetches command-response requests for the current user using optional filters.
Supported query shapes (see RainMaker API docs):
requestId — single recordrequestId + nodeId — single recordnodeId + startTime + endTime — historynodeId with optional cmdId or status — paginated liststatus alone — all requests for the current user with that statusFilter and pagination options.
Paginated command-response request records.
Fetches custom data associated with the current user. This method sends a request to fetch custom data associated with the currently logged-in user.
A promise that resolves with the custom data associated with the user.
Fetches a single uploaded file by id.
The file id to look up.
Optionalparams: ESPFileGetByIdParamsOptional lookup scope such as userName for public files.
The file record, or null when not found.
Fetches uploaded files for the current user with optional filters.
Optionalparams: ESPFileListParamsFilter and pagination options.
Paginated file records.
Retrieves the user's geographical coordinates from the custom data.
A promise that resolves to an ESPGeoCoordinates object containing the latitude and longitude.
Retrieves a group by its ID.
Parameters to filter the group data by ID.
A promise that resolves to an instance of ESPRMGroup.
Retrieves a group by its name.
Parameters to filter the group data by name.
A promise that resolves to an instance of ESPRMGroup.
Retrieves a list of groups with optional filters and pagination.
Parameters to filter and paginate the group data.
A promise that resolves to a paginated response containing group data.
Optionalcount: numberFetches node sharing requests for the user with optional pagination.
OptionalpageCount: numberThe number of results to fetch per request. If not provided, the default value is used.
A promise that resolves to a paginated response containing node sharing requests.
Fetches a list of registered platform endpoints associated with the user.
A promise that resolves to an array of ESPPlatformEndpoint instances.
Optionalcount: numberFetches node sharing invitations for the user with optional pagination.
OptionalresultCount: numberThe number of results to fetch per request. If not provided, the default value is used.
A promise that resolves to a paginated response containing node sharing invitations.
Retrieves user information, optionally including custom data.
OptionalwithCustomData: booleanOptional flag indicating whether to include custom data in the response. Defaults to false.
A promise that resolves to an ESPRMUserInfo object containing the user information.
Fetches user nodes with optional pagination.
OptionalresultCount: numberAn optional parameter to specify the number of results to retrieve. If not provided, all available results will be fetched.
A promise that resolves to a paginated response containing the user nodes.
Retrieves user nodes based on the provided request parameters.
The parameters for the request to get user nodes.
A promise that resolves to a paginated response containing the user nodes.
Logs out the current user, with an option to log out from all sessions.
OptionalshouldLogoutFromAllSessions: booleanOptional flag indicating whether to log out from all sessions. Defaults to false.
A promise that resolves to an ESPAPIResponse object containing the result of the logout operation.
Removes all callbacks for a specified event or all events.
Optionalevent: string(Optional) The event for which to remove callbacks. If omitted, all callbacks for all events are removed.
Removes tags to the current user.
This method sends a request to remove the provided tags with the currently logged-in user.
An array of strings representing the tags to be removed.
A promise that resolves to an ESPAPIResponse containing the result of the operation.
Sends a request to initiate the account deletion process.
A promise that resolves to an ESPAPIResponse indicating the success of the account deletion request.
Searches for ESP BLE devices with the given customer ID.
The customer ID to search for.
A promise that resolves to an array of ESPDevice instances.
Searches for ESP devices with the given prefix.
The prefix of the device name to search for.
A promise that resolves to an array of ESPDevice instances.
Sets custom data associated with the current user. This method sends a request to set custom data for the currently logged-in user.
The custom data to be set for the user.
A promise that resolves to an ESPAPIResponse indicating the success of the operation.
Stores the user's geographical coordinates in the custom data.
An object containing the latitude and longitude to be stored.
A promise that resolves to an ESPAPIResponse indicating the success of the operation.
Sets multiple parameters for the nodes.
The payload containing the parameters to be set for multiple nodes.
A promise that resolves to the API response.
Updates the phone number associated with the current user.
The new phone number to be set for the user.
A promise that resolves to an ESPAPIResponse object containing the result of the operation.
Set the timeZone for the user in the user's custom data.
The timeZone string to set.
A promise that resolves to an ESPAPIResponse indicating the success of the operation.
Shares the specified groups with a user.
The parameters needed for sharing groups.
A promise that resolves to the request ID from the API.
Stop the search for ESP devices.
Subscribes a callback function or an array of callback functions to a specified event.
The event to subscribe to, represented by ESPRMEventType or string.
The callback function or an array of callback functions to execute when the event is triggered.
OptionaldiscoveryConfig: DiscoveryParamsInterfaceThe discovery configuration to use for the custom discovery protocol.
Transfers the specified groups to another user.
The parameters needed for transferring groups.
A promise that resolves to the request ID from the API.
Triggers an event and executes all associated callback functions with the provided argument.
The event to trigger, represented by ESPRMEventType or string.
The argument to pass to the callback functions.
Unsubscribes a specific callback function from a specified event.
The event to unsubscribe from, represented by ESPRMEventType or string.
The callback function to remove.
Updates the name associated with the current user.
The new name to be set for the user.
A promise that resolves to an ESPAPIResponse object containing the result of the operation.
Uploads a file in one call: create upload request, PUT to S3, and confirm.
File bytes to upload.
Upload and confirm fields for the file.
OptionalonProgress: ESPFileUploadProgressCallbackOptional phase progress callback.
A promise that resolves to the confirmed file record.
StaticclearClears all tokens from memory and local storage.
StaticextendStaticgetRetrieves the current access token. If the access token is expired, it attempts to extend the session using the refresh token.
A promise that resolves to the access token or an empty string if no valid token is available.
The
ESPRMUserclass serves as the central interface for managing user-related operations within the ESP RainMaker SDK. It provides a comprehensive set of methods for:By utilizing the
ESPRMUserclass, developers can seamlessly manage user sessions, interact with backend APIs, and handle complex user-related workflows.