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

runnr-app

v0.2.0

Published

Runnr is a simple domotics API written in Node for Raspberry Pi and to use with Runnr app

Downloads

8

Readme

Runnr App

Installation

Installation is extremely simple, just go throught the following instructions.

NPM install

npm install -g runnr-app will install Runnr App in your preferred global folder.

Usually this is under /usr/lib/node_modules.

Reverse Proxy (other port than 80)

If you wish to setup Google Assistant or IFTTT proxying you will need to expose your Runnr App to the internet.

We strongly advise you to use a server software (like nginx) and a reverseproxy, and get a domain name to set https. As a matter of fact, Runnr Servers will only perform requests on your webhook if they are https, if not an error will occur.

Nginx + NAT

A "normal" configuration will require you to enable NAT features on your home router or modem. Most modems/routers have a dedicated web interface where you can set this up (usually by the name Port Redirection). You may want to redirect ports 80 and 443 to your Runnr App instance (ie:Raspberry Pi).

On your Raspberry Pi you can then install nginx (apt-get update; apt-get install nginx) and configure it to listen on those ports and with a domain if you set that up (there a thousands of tutorials to set up DNS for domains and nginx configs, Google them ;)).

Ngrok

Another alternative is to use ngrok. Bear in mind that this cannot be considered a safe, secure, long-term solution.

ngrok is a tunneling service, that creates a tunnel between your local machine and a domain at *.ngrok.com.

To use ngrok on your machine please launch it by using

ngrok http -bind-tls=true localhost:PORT

You will then receive a ngrok URL that you can use on the administration iterface.

After setting up your https configuration, be sure to enter your IP or domain into your settings on the website.

Configure

Go to your installation folder and find the queries.dist.json and scripts.dist.json along with the config.dist.json. These are distribution files, hence the dist in their names.

You can just copy them using the following commands: cp queries.dist.json queries.json cp scripts.dist.json scripts.json cp config.dist.json config.json and edit them.

config.json

This file only contains one element, app_key. You can delete it or set an app key.

Be aware that setting an app key means using it for API calls and you must set it on the website if using Google Assistant or IFTTT Proxying.

queries.json

This file is used along with Google Assistatn proxying. Google Assistant takes input in the form of free text. It treats this text to understand what the user means and sends a request to Runnr servers.

Because of this, Runnr proxy can only send you text or an intent (more on that on the bottom) provided that you set up an agent via Dialogflow. You can use any NLP provider if you go through the default_handler and make the requests yourself.

Query

A query looks like the following

[{
	"id":"OPEN_DOOR_SCRIPT",
	"intent":"open_door",
	"script":"open_door.js"
}, {
	"id":"MAKE_COFFEE_SCRIPT",
	"intent": "make_coffee",
	"command":"python /home/pi/scripts/coffe_maker.py"
}, {
	"id":"SOME_SCRIPT_SCRIPT",
	"regex": "launch some script",
	"script": "some_script.js"
}, {
	"id":"WEIRD_COMMAND",
	"regex":[
		"execute weird command",
		"do super command",
		"have some fun"
	],
	"command":"this would be | some command"
}, {
	"id":"MAKE_COFFEE",
	"regex":"coffee",
	"script": "make_coffee.js"
}]

Notice that every query in the array has a different configuration. Queries are defined by the following params

| Name | Required | Description | |:----:|:--------:|:-----------:| | id| true | The ID that will be used by the app + on the API | | intent | false | Required if the script/command will be called upon arrival of given intent (case sensitive) | | regex | false | (Array or String) Required if no intent expected (no Dialogflow integration), the app will try to find a match to the message received via these RegExp| |script | false | Required if a script must be launched from the scripts.json config file | |command |false| Required if a command must be executed on request|

Note that even though most properties are not required, a combination of them must be as the example.

A query script file is defined as:

// MUST export a function
module.exports = (message, entities) => {
	console.log('Message received', message);
	console.log('It contains', entities);
};

Queries scripts go into the queries folder.

scripts.json

This file tells Runnr App what scripts to load on boot and on request.

Script

A script looks like this

[{
	"id": "coffee-maker",
	"name": "Super Coffee Maker Script",
	"command": "php /home/pi/PHP/is/for_dummies/coffee_maker.php"
}, {
	"id": "laundry-maker",
	"name": "Super Laundry Maker Script",
	"file": "laundry_maker.js"
}]

| Name | Required | Description | |:----:|:--------:|:-----------:| | id| true | The ID that will be used by the app + on the API | |file | false | The file to load (must be JS) | | command | false | A command if the script must be launched from a command |

A file script is defined as :

module.exports = () => {
	console.log('Whatever you want in here');
};

Normal Scripts go into the scripts folder.

API

An API is also available, that will allow you to create Rooms and Devices, and link them together:

						____________
						|			|
 ___________	 _______|	Device1	|----- Script
|			|	/		|___________|
|	ROOM 	|---		____________
|___________|	\_______|			|
						|	Device2 |----- Script
						|___________|

This allows you to request the API to switch individual devices, or entire rooms. Note that this is hierarchichal:

  • Turning OFF a room turns OFF all linked devices
  • Turning ON a room turns ON all linked devices
  • Switching a room switches all devices (from on to off and vice versa)

Devices : /api/devices

Rooms : /api/rooms

Scripts : /api/scripts

Commands : /api/commands