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

node-red-contrib-wappsto

v0.0.3

Published

Node-RED nodes that enable communication with Wappsto.

Downloads

1

Readme

node-red-contrib-wappsto

This module wil help your apps and devices to work together in new interesting ways. It provides a set of Node-RED nodes that enable communication with Wappsto, as all the necessary API calls are nicely wrapped by the given nodes.

Table of Contents

  1. Prerequisites
  2. Installing
  3. Getting started
  4. Create your first flow
  5. Weather flow example
  6. Manage nodes from Wappsto
  7. Upload your flows
  8. License

Prerequisites

Before you start, you need first:

  • a Wappsto account (is free);
  • Node.js (preferably LTS version) and npm installed on your computer. If you don't have them, you can use e.g. nvm or n to get them easily installed on your computer;
  • and Node-RED.

There are at least two ways to install Node-RED:

1. package.json (faster)

Download this file and run in the same directory where you placed the "package.json" file the following command:

npm install

This file also includes all the used nodes in this guide, thus the Installing section and openweathermap node installation can be skiped. Feel free to add additional nodes.

2. npm

According to Node-RED docs, you can simply execute the following command to install Node-RED package globally on your computer:

sudo npm install -g --unsafe-perm node-red

Installing

Install the Wappsto nodes by either:

  • using the following command in your ~/.node-red installation directory:

    npm install node-red-contrib-wappsto
  • or using Node-RED Install Pallet, look for "node-red-contrib-wappsto".

Getting started

1. Run Node-RED

If you've chosen the "package.json" installation approach, then execute npm start command, otherwise node-red in your terminal to run it. When that is done, to access Node-RED dashboard, open your web browser and go to this address: http://localhost:1880.

If you installed this package while Node-RED was running, remember to restart Node-RED and refresh the dashboard (press F5 key) to see the newly installed nodes.

2. Locate Wappsto nodes

This package comes with two nodes:

  • listener - listens for stream events coming from Wappsto and outputs a message so that wired nodes can act upon it.

  • writer - sends data from wired nodes to Wappsto.

The listener node (1) can be found under the "input" category whereas the writer node (2) under the "output" category.

Create your first flow

This section describes a very basic scenario on how you can pass data throught Wappsto.

1. Sending data to Wappsto

Add inject and writer nodes to the canvas and wire them together (1). Next, click on the writer node to open the editing view and add a new "Value" (2). Once you enter the "Value" view, provide your Wappsto email and password (3), and click the "Get" button (4) to retrieve a new installation ID. Then click Add > Done buttons (5-6) to exit the editing mode.

2. Receiving data from Wappsto

In order to receive and see the injected data, add listener and debug nodes to the canvas and wire the debug node to the second pin of the listener (7). Open the listener node editing view and select the previously created "Value" (8). Last but not least, click the Done > Deploy buttons (9-10).

Click on the inject node (11) and go to the "Debug" tab to see the injected timestamp (12).

Weather flow example

This flow example extends the previous scenario by adding an openweathermap node and 2 core "function" nodes to the flow.

1. Prerequisites

  • You need to have the weather node installed, e.g. execute the following command in your ~/.node-red directory:

    npm install node-red-node-openweathermap

    Remember to restart Node-RED and refresh your web browser to see the openweathermap nodes.

  • Get an OpenWeatherMap API key.

2. Import the example

Copy the content of this file, paste it to Settings > Import > Clipboard (press Ctrl+I keys to quickly open it) input field, click the "Import" button, and open the "Weather" tab.

Rember to replace "email" and "password" with your Wappsto credentials and get a new installation ID. Use the same ID in both of the "Values". Also, place the API key into the openweathermap node.

You're ready to deploy and play around!

Manage nodes from Wappsto

Behind the scenes, to enable the communication with Wappsto, the nodes will create a couple of data structures that are part of our Unified Data Model, that is: Network > Device > Value > State. Each node in this schema represents a "Value". The created schema and its data can be accessed and managed using e.g. My Data wapp.

In the case of the weather example, using the "My Data" wapp, the location can be changed and you can see the reported temperature.

Upload your flows

Apart from providing the connectivity, this packages enables to run Node-RED flows in Wappsto. To upload the flows and make them running, it is enough to click the "Upload flows to Wappsto" button (1). To see and edit the exported files, go to Wapp Creator and click on the "Node-RED" application (2).

To run Node-RED flows in Wappsto, the main.js file includes these lines:

const RED = require('node-red-contrib-wappsto/red');

It creates a wrapper for Node-RED runtime. Aside from exposing the runtime object, it gives possibility to modify the Runtime Configuration with ease. Before you start the runtime, you can modify RED._settings object to apply your own configuration.

The next crucial line is:

RED.start({ flows: ..., credentials: ... });

it accepts an object as argument with the following keys:

  • flows (object): Node-RED flows.
  • credentials (object): decoded flows credentials.

It runs or restarts Node-RED runtime with the provided arguments and returns a Promise object so that you can chain than function.

Try to make your own modifications to the files and play around. This is just the beginning!

License

Apache 2.0 © Seluxit A/S