Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
ninja-blocks
Advanced tools
A simple library to help interacting with the Ninja Blocks Platform.
npm install ninja-blocks
var ninjaBlocks = require('ninja-blocks');
// ACCESS_TOKEN acquired via OAuth
var ninja = ninjaBlocks.app({access_token:ACCESS_TOKEN});
ninja.devices(function(err,devices) {
// ...
});
var ninjaBlocks = require('ninja-blocks');
// USER_ACCESS_TOKEN acquired via settings page in Ninja Cloud
var ninja = ninjaBlocks.app({user_access_token:USER_ACCESS_TOKEN});
ninja.devices(function(err,devices) {
// ...
});
// Fetch a user's profile anyformation
ninja.user(function(err, data) { ... });
// Fetch a user's activity stream
ninja.user().stream(function(err,data){ ... })
// Fetch a user's pusher channel
ninja.user().pusher_channel(function(err,data){ ... })
/**
* Fetch all the user's device details.
* Optionally if an object is passed as the first argument,
* it will filter by the parameters. If a string is provided,
* it will assume it's the device type intended for filtering.
*
* NOTE: The returned data is in the form guid => meta data
* You will need the guid for all the other device commands.
*/
ninja.devices(function(err, data) { ... });
ninja.devices({ device_type:'rgb_led' },function(err,data){ ... })
ninja.devices({ vid:0, shortName:'On Board RGB LED' },function(err,data){ ... })
// Fetch one device's details
ninja.device(guid).fetch(function(err,data) { ... });
// Send `command` to device `guid`
ninja.device(guid).actuate(command,function(err) { ... })
// Subscribe to a device's data feed. Ninja Blocks will POST the requested
// device's data to the `url` provided here.
// Optionally `overwrite`s an existing callback `url`
ninja.device(guid).subscribe(url,overwrite,function(err) { ... })
// Unubscribe from a device's data feed.
ninja.device(guid).unsubscribe(function(err) { ... })
// Fetch any historical data about this device. Optionally specify the period's `start` and `end` timestamp.
ninja.device(guid).data(start, end, function(err, data) { ... })
// Fetch the last heartbeat received by this device.
ninja.device(guid).last_heartbeat(function(err, data) { ... })
// Returns found subdevices within a set of devices
ninja.utils.findSubDevice({ shortName: 'Lamp On' }, deviceSet);
This is by no means exhaustive, and more functionality will be forthcoming.
var _ = require('underscore');
var ninjaBlocks = require('ninja-blocks');
// Use the API Access Token from https://a.ninja.is/hacking
var ninja = ninjaBlocks.app({user_access_token:USER_ACCESS_TOKEN});
// Get the most recent temperature reading from all temperature sensors
ninja.devices({ device_type: 'temperature' }, function(err, devices) {
_.each(devices, function(device,guid){
ninja.device(guid).last_heartbeat(function(err, data) {
console.log(device.shortName+' is '+data.DA+'C');
})
})
});
// Execute an RF command by name - turn a "Lamp Off"
ninja.devices({ device_type: 'rf433' }, function(err, devices) {
var lamps = ninja.utils.findSubDevice({ shortName: 'Lamp Off' }, devices);
_.each(lamps, function(lamp){
ninja.device(lamp.guid).actuate(lamp.data)
})
});
FAQs
Library for interfacing with Ninja Blocks platform.
The npm package ninja-blocks receives a total of 1 weekly downloads. As such, ninja-blocks popularity was classified as not popular.
We found that ninja-blocks demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.