Skip to content

Instantly share code, notes, and snippets.

@jsdario
Last active November 17, 2017 15:53
Show Gist options
  • Save jsdario/8ef077090622969553a15af2711f11ad to your computer and use it in GitHub Desktop.
Save jsdario/8ef077090622969553a15af2711f11ad to your computer and use it in GitHub Desktop.
Bigfoot Smart Home Samples
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