GithubHelp home page GithubHelp logo

acte-technology / thingsboard-js-sdk Goto Github PK

View Code? Open in Web Editor NEW
15.0 3.0 4.0 37 KB

Integrate Thingsboard backend to Javascript front-end frameworks and NodeJS

JavaScript 100.00%
thingsboard iot nodejs reactjs

thingsboard-js-sdk's Introduction

Thingsboard Javascript SDK

Thingsboard Javascript SDK

Dev version, work in progress.

Installation

npm install thingsboard-js-sdk

Examples

  • Reactjs, checkout docs/reactjs.js component.

Methods

  • connect
  • disconnect
  • subscribe (websocket)
  • getTenantDevices
  • getKeys (timeseries & attributes)
  • deleteEntityKeys (timeseries & attributes)
  • getAttributesByScope
  • getTimeseries

Import client class

import tbClient from 'thingsboard-js-sdk';
const client = new tbClient(config);

Connect to public device

const client = new tbClient({
  host: 'localhost',
  publicId: 'xxx-xxx-xxx-xxx' // dashboard public id
});

const connect = async () => {

  const token = await client.connect(true); //true for public login

}

Connect with user/password

const client = new tbClient({
  host: 'localhost',
  username: 'username',
  password: 'password'
});

const connect = async () => {

  const token = await client.connect();

}

Get Tenant Devices

must be logged as a tenant

const params = {
  pageSize: 100,
  page: 0,
  sortProperty: 'name',
  sortOrder: 'ASC'
}
//...
let devices = await client.getTenantDevices(params, callback)

Get Keys

const params = {
  entityId: 'xxx-xxx-xxx',
  scope: 'timeseries', //timeseries | client | shared | server
}
//...
let keys = await client.getKeys(params, callback)

Get Attributes By Scope

const params = {
  entityId: 'xxx-xxx-xxx',
  scope: 'CLIENT_SCOPE', // CLIENT_SCOPE | SHARED_SCOPE | SERVER_SCOPE
  keys: ['temperature', 'humidity']
}
//...
let attrs = await client.getAttributesByScope(params, callback)

Delete keys

const params = {
  entityId: 'xxx-xxx-xxx',
  keys: ['temperature', 'humidity'],
  olderThan: Date.now()-3600, //delete older than 1 hour
  scope: 'timeseries' // timeseries, client, shared, server
}
//...
let response = await client.deleteEntityKeys(params, callback)

Get timeseries

const now = Date.now();

const params = {
  entityId: 'xxx-xxx-xxx',
  keys: ['temperature', 'humidity']
  limit: 500,
  agg: 'AVG',
  interval: 60000,
  startTs: now-3600000,
  endTs: now,
  useStrictDataTypes: true
}
//...
let timeseries = await client.getTimeseries(params, callback)

WSS Websocket subscribe

const params = {
  entityId: 'xxx-xxx-xxx',
  cmdId: 10 //websocket id
}
//...
let keys = await client.subscribe(params, callback)

Issues

Github: https://github.com/acte-technology/thingsboard-js-sdk/issues

Working examples:

thingsboard-js-sdk's People

Contributors

adrienadb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

thingsboard-js-sdk's Issues

Unable to import within NodeJS

The module cannot be imported into the properly. When imported using the ES6 import Syntax, the nodejs package needs to be of type "module". However. The module uses the import syntax itself, without having the "module" type, leading to an exception as well. The alternative version - the import via require doesn't work either for the same reasons.

How to install and use your script?

I am new to this.
So I installed NPM on windows.

Then installed your script using your install script.

Where from here should I go to so I can have a local webpage of your site: https://acte.ltd/iot/client/login

With your website (that is awesome to use!) I cannot remove telemetry from the future. By a programming error, I added telemetry with the year 2026. Your website only goes from now till past, Not future.

Hope you can help me by installing your script on my local PC.

Thank you

Connect by websocket example

Hello, I'm newbie in ReactJS trying to collect data from device's telemetry to show on ReactJS. Can you have code example to do it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.