Last active
November 17, 2017 15:53
-
-
Save jsdario/8ef077090622969553a15af2711f11ad to your computer and use it in GitHub Desktop.
Bigfoot Smart Home Samples
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
const bigfoot = require("@netbeast/bigfoot") | |
const five = require("johnny-five") | |
const board = new five.Board() | |
const options = {id: 'motion-sensor-01', topic: 'Motion'} | |
let state = { motion: "uncalibrated" } | |
board.on("ready", function() { | |
const motion = new five.Motion(7) | |
const device = bigfoot.alive(options, function (commit, params) { | |
// params can be ignored, sensors may not be actionable | |
commit(state) | |
}) | |
motion.on("calibrated", function() { | |
state = { motion: 'calibrated' } // change the state | |
}) | |
motion.on("motionstart", function() { | |
state = { motion: 'motionstart' } | |
}) | |
motion.on("motionend", function() { | |
state = { motion: 'motionend' } | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment