npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sentilo-client-nodejs

v1.0.1

Published

Sentilo Nodejs client library

Downloads

8

Readme

Sentilo client library for Node.js v1.0.1

The Sentilo Javascript/Node.js client library code that brings some Sentilo operations that you can include in your own code.

Installation

To install this library via npm, use:

See it at: NPM

Alternatively, use this dependency in your package.json:

Sentilo client configuration options

| Option | Description | Example value | |----------------------|-----------------------------------------------------------|-------------------------| | apiUrl | URL of your Sentilo/Thingtia instance | http://localhost:8081 | | headers.identity_key | token of your provider or application | f7a702ad6.... | | provider | Provider id | samples-provider | | sensor | Sensor Id | sample-sensor-nodejs | | component | Component Id, Only used in catalog operations. | sample-component | | componentType | Type of the component. Only used in catalog operations. | generic | | sensorDataType | Data type of the sensor. Only used in catalog operations. | TEXT | | sensorType | Ty of the sensor. Only used in catalog operations. | status | | sensorUnit | Unit of sensor, only used in catalog operations. | kW | | sensorLocation | Lat/lon values separated with blank space. Optional | 41.387015 2.170047 |

Sentilo client services

| Method | Description | |-------------------------|---------------------------------------------------| | existsSensorInCatalog | Searches a sensor in the catalog. Returns boolean | | createSensor | Creates a sensor in catalog. | | publishObservations | Publishes observations. | | createAlerts | Creates multiple alerts | | publishAlarm | Publishes Alarm | | subscribeOrder | Subscribes to a order | | subscribeOrderToAll | Subscribes to all sensor orders from a provider |

_Note: .*Operations.js files expose more API services.

You might as well check Sentilo Node-RED library on Github and on Node-RED

Note that the API documentation is at https://sentilo.readthedocs.io/en/latest/api_docs.html.

Example Usage

const sentilo = require('sentilo');

// Initialize sentilo
const options = {
    apiUrl : 'http://localhost:8081',
    headers : {
           identity_key : 'f7a702ad6b701...'
    },
    provider : 'testApp_provider',
    sensorLocation : '41.387015 2.170047'
};
sentilo.init();

 
// Checks if the sensor exists
const existingSensor = {
     provider: 'testApp_provider',
     sensor: 'TestSensor'
};
sentilo.existsSensorInCatalog(existingSensor);
 
 
// Creates a new sensor
const newSensor = {
     sensor: 'TestNewSensor',
     description: 'TestNewSensorDescription',
     sensorType: 'anemometer',
     sensorDataType: 'JSON',
     component: 'TestGenericSensor',
     componentType : 'generic',
     sensorUnit : 'T',
     sensorLocation : '41.387015 2.170047'
     
}
sentilo.createSensor(newSensor);
 
 
// Send observation to the sensor
const sensorObservation = 'TEST';
sentilo.publishObservations(sensorObservation, newSensor);
 

// Creates a new alert
const newAlert = {
     alerts: [
         {
             id: 'TEST_ALERT_001',
             name: 'TEST_ALERT_001',
             description: 'External test alert 001',
             type: 'EXTERNAL'
         }
     ]
}
sentilo.createAlerts(newAlert);
 

// Publish new alarm associated to the alarm that is registered later
const message = {message: "This is a test alarm over the TEST_ALERT_001"};
let alarmId = newAlert.alerts[0].id;
sentilo.publishAlarm(alarmId, message);
 

// Example of how to subscribe to a sensor order
const endpoint = {endpoint:"http://my-test-server/sentilo/sensor/data/endpoint"};
sentilo.subscribeOrder(endpoint);
 

// Example of how to subscribe to all orders
sentilo.subscribeOrderToAll(endpoint);

You might as well check your example for Raspberry Pi and NodeJS: https://github.com/sentilo/sentilo-client-sample-nodejs

Changelog

v.1.0.1 - Fixed libraries versions, updated README.md file v.1.0.0 - Initial version