node-red-contrib-mobius-flow-thingsboard
Version:
Node-RED nodes to work with MOBiUSFlow and ThingsBoard.io
80 lines (79 loc) • 2.79 kB
TypeScript
export interface IThingsboardHttpClient {
/**
* Close the HTTP connection
*
* @memberof IThingsboardHttpClient
*/
closeHttpConnection(): any;
/**
* Check if the HTTP client has a valid access token
*
* @returns {boolean}
* @memberof IThingsboardHttpClient
*/
hasToken(): boolean;
/**
* Get a Thingsboard device by name
*
* @param {string} deviceName The device name
* @returns {Promise<any>}
* @memberof IThingsboardHttpClient
*/
getDeviceByName(deviceName: string): Promise<any>;
/**
* Get a Thingsboard device's credentials
*
* @param {string} deviceId The device ID
* @returns {Promise<any>}
* @memberof IThingsboardHttpClient
*/
getDeviceCredentials(deviceId: string): Promise<any>;
/**
* Add a new device to Thingsboard
*
* @param {string} deviceName The device name
* @param {*} mobiusObject The mobius object representing the device
* @returns {Promise<any>}
* @memberof IThingsboardHttpClient
*/
addDevice(deviceName: string, mobiusObject: any): Promise<any>;
/**
* Update a Thingsboard device's attributes
*
* @param {string} deviceAccessToken The device's access token
* @param {*} attributes The attributes as key value pairs
* @returns {Promise<any>}
* @memberof IThingsboardHttpClient
*/
updateClientAttributes(deviceAccessToken: string, attributes: any): Promise<any>;
/**
* Update a Thingsboard device's telemetry
* Resolves if the device is added
*
* @param {string} deviceAccessToken The device's access token
* @param {number} timestamp The update timestamp
* @param {*} telemetry The telemetry as key value pairs
* @returns {Promise<any>}
* @memberof IThingsboardHttpClient
*/
updateDeviceTelemetry(deviceAccessToken: string, timestamp: number, telemetry: any): Promise<any>;
}
export declare class ThingsboardHttpClient implements IThingsboardHttpClient {
private httpClient;
private siteURL;
private userName;
private password;
private isLocal;
private token;
private refreshToken;
private httpTokenRefreshTimer;
constructor(siteURL: string, userName: string, password: string, isLocal: boolean);
closeHttpConnection(): void;
hasToken(): boolean;
getDeviceByName(deviceName: string): Promise<any>;
getDeviceCredentials(deviceId: string): Promise<any>;
addDevice(deviceName: string, mobiusObject: any): Promise<any>;
updateClientAttributes(deviceAccessToken: string, attributes: any): Promise<any>;
updateDeviceTelemetry(deviceAccessToken: string, timestamp: number, telemetry: any): Promise<any>;
private getHttpTokenFromTB;
}