New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

wappsto-wapp

Package Overview
Dependencies
Maintainers
1
Versions
197
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wappsto-wapp

This is a node/js library for easily creating wapps for [Wappsto](https://wappsto.com)

  • 0.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
274
increased by14.17%
Maintainers
1
Weekly downloads
 
Created
Source

Wappsto Wapp API CI codecov

This is a node/js library for easily creating wapps for Wappsto

Usage

Here are some examlples on how to use the library.

Create a new Network

To create a new network you need to call 'createNetwork'. If there is an Network with the same name, the exsisting network will be returned.

let network = await Wappsto.createNetwork({
	name: 'new network name'
});

Create a new device

To create a new device under an existing network, you should call createDevice. If a device exsists with the given name, the existing device will be returned,

let device = network.createDevice({
	name. 'Device Name',
	product: 'Great Product',
	serial: 'SG123456',
	description: 'My great new device',
	protocol: 'WAPP-JS',
	communication: 'wapp',
	version: '1.0.0',
	manufacturer: 'My Self'
});

Create a new value

To create a new value under an exsisting device, you should call createValue. There are some helper functions to create number, string, bloc and xml values. There will also be created the states nedded based on the permission. The only allowed values for permission is 'r', 'w' and 'rw'.

To create a number value:

let value = device.createNumberValue({
	name: 'Value Name',
	permission: 'rw',
	type: 'Counter',
	period: '1h',
	delta: '1',
	min: 0,
	max: 10,
	step: 1,
	unit: 'count',
	si_conversion: 'c'
});

To create a string value:

let value = device.createStringValue({
	name: 'Value Name',
	permission: 'rw',
	type: 'debug',
	max: 10,
	encoding: 'debug string'
});

To report a change in the value

To send a new data point to wappsto, just call the 'report' function on the value.

value.report('1');

To change a value on another networks value

To send a new data point to another value, just call the 'control' function on the value.

value.control('1');

Listing for changes on values

You can register onControl and onReport to receive events when the value changes.

value.onReport((value, data, timestamp) => {
	console.log(`${value.name} changed it's report value to ${data}`);
});

value.onControl((value, data, timestamp) => {
	console.log(`Request to change ${value.name} to ${data}`);
});

Background loggering

The debug log from the background wapp can be turn on like this:

Wappsto.startLogging();

Enable verbose responses from wappsto

To enable verbose mode in wappsto, the verbose mode needs to be set to true.

Wappsto.verbose(true);

Raw requests

It is possible to send your own requests to wappsto by using the 'request' object in wappsto.

let netwoks = await Wappsto.request.get('/network');

Find a model by ID

It is possible to find a spefic model using it ID.

let network = await Wappsto.Network.findById('b23b41c1-0859-46de-9b11-128c6d44df72');

FAQs

Package last updated on 09 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc