2017 © Pedro Peláez
 

library node-red-api

A package for communicating with the Node-RED API

image

andrewcarteruk/node-red-api

A package for communicating with the Node-RED API

  • Friday, June 2, 2017
  • by AndrewCarterUK
  • Repository
  • 1 Watchers
  • 1 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Node-RED API

Build Status Code Coverage Scrutinizer Code Quality Latest Stable Version Total Downloads License, (*1)

By AndrewCarterUK (Twitter), (*2)

A set of classes for communicating with the Node-RED API. Supports importing flows., (*3)

Authentication

use NodeRED\Instance;
use NodeRED\OAuth;

$instance = new Instance('http://localhost:1883');

$oAuth = new OAuth($instance);
$token = $oAuth->getToken('username', 'password');

Tokens

// Tokens are serializable
$serializedToken = serialize($token);
$token = unserialize($serializedToken);

// Check if a token has expired
if ($token->hasExpired()) {
    // ...
}

Instance Methods

// ::get($path, ? $token)
$authScheme = $instance->get('auth/login');
$flows = $instance->get('flows', $token);

// ::jsonPost($path, $data, ? $token)
$instance->jsonPost('nodes', ['module' => 'node-red-node-suncalc'], $token);

Importing Flows

use NodeRed\Importer;

$importer = new Importer($instance, $token);

$flowJson = '[{"id":"38fb694f.83ac86","type":"inject","z":"7578d4d1.ba2e2c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":602.5,"y":298,"wires":[["f8ac9ac8.c76808"]]},{"id":"f8ac9ac8.c76808","type":"debug","z":"7578d4d1.ba2e2c","name":"","active":true,"console":"false","complete":"false","x":794.5,"y":298,"wires":[]}]';

$flowId = $importer->importFlow('My New Flow', $flowJson);

The Versions

02/06 2017

dev-master

9999999-dev

A package for communicating with the Node-RED API

  Sources   Download

MIT

The Requires

 

The Development Requires

02/06 2017

v0.1.0

0.1.0.0

A package for communicating with the Node-RED API

  Sources   Download

MIT

The Requires

 

The Development Requires