This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var async = require('async'); | |
var Wemo = require('wemo-client'); | |
var Device = require('losant-sdk-js').Device; | |
// The serial number of the Wemo. Makes sure that if there's multiple on | |
// the network, we pick the right one. | |
var myWemoSerial = 'my-wemo-serial'; | |
var wemo = new Wemo(); | |
var device = new Device({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
void setup() { | |
Serial.begin(9600); | |
} | |
void loop() { | |
delay(1000); | |
Serial.println("Hello World!"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var result = { | |
newPost: null, | |
newPostId: null | |
}; | |
// If this is the first time through, lastID will be undefined. | |
// Set it to the most recent post and return. | |
if(!payload.data.lastId) { | |
if(payload.data.latest.body.latest_posts.length) { | |
result.newPostId = payload.data.latest.body.latest_posts[0].id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This #include statement was automatically added by the Particle IDE. | |
#include "SparkJson/SparkJson.h" | |
// This #include statement was automatically added by the Particle IDE. | |
#include "MQTT/MQTT.h" | |
void setup() { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*jslint node:true, vars:true, bitwise:true, unparam:true */ | |
/*jshint unused:true */ | |
// load required modules | |
var async = require('async'); // helps control asynchronous flow | |
var path = require('path'); // utility for handling file paths | |
var exec = require('child_process').exec; // runs a command in a shell and buffers the output | |
var spawn = require('child_process').spawn; // launches a child process | |
var request = require('request'); // http request client | |
var watson = require('watson-developer-cloud'); // IBM Watson services client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Cylon = require('cylon'); | |
var Wemo = require('wemo-client'); | |
var findOutlet = function(cb){ | |
var wemo = new Wemo(); | |
var stop = false; | |
wemo.discover(function(deviceInfo) { | |
if(stop || deviceInfo.friendlyName !== 'LosantOutlet_1') { return; } | |
stop = true; | |
console.log('Found outlet!'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Hue Light Control Service | |
Wants=network-online.target | |
After=network-online.target | |
[Service] | |
ExecStart=/usr/bin/node /usr/local/hue-light-control/worker.js | |
User=nobody | |
Restart=on-failure | |
RestartSec=10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Define the GPIO pins each LED is connected to */ | |
int leftTop = 2; | |
int leftMiddle = 3; | |
int leftBottom = 4; | |
int middleMiddle = 5; | |
int rightTop = 6; | |
int rightMiddle = 7; | |
int rightBottom = 8; | |
/* Save them in an array so we can easily iterate all of them. */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const doc = require('dynamodb-doc'); | |
const dynamo = new doc.DynamoDB(); | |
exports.handler = (event, context, callback) => { | |
if(!event || !Array.isArray(event)){ return callback(null, null); } | |
let deviceSerial; | |
event.forEach((pair) => { | |
if(pair.key === 'deviceSerial'){ deviceSerial = pair.value; } |
OlderNewer