├── .travis.yml ├── assets ├── images │ ├── johnny-five-icon.png │ └── README.md ├── sketches │ ├── raspi-switch-led.fzz │ ├── arduino-temperature-4k7-thermistor.fzz │ └── arduino-temperature-4k7-thermistor.png ├── docs │ └── pin-naming.md └── fonts │ └── default.js ├── .gitignore ├── devices ├── johnny-five-lcd-display.coffee ├── johnny-five-servo.coffee ├── johnny-five-oled-display.coffee ├── johnny-five-contact-sensor.coffee ├── johnny-five-presence-sensor.coffee ├── johnny-five-button.coffee ├── johnny-five-relay.coffee ├── johnny-five-temperature.coffee ├── johnny-five-switch.coffee ├── johnny-five-pwm-output.coffee ├── johnny-five-temperature-humidity.coffee ├── johnny-five-temperature-pressure.coffee └── johnny-five-rgb-led.coffee ├── johnny-five-config-schema.coffee ├── package.json ├── johnny-five.coffee ├── actions └── johnny-five-rgb-color-action.coffee ├── HISTORY.md ├── board-manager.coffee ├── device-config-schema.coffee ├── README.md └── LICENSE /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '4' 4 | - '6' 5 | -------------------------------------------------------------------------------- /assets/images/johnny-five-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwittig/pimatic-johnny-five/HEAD/assets/images/johnny-five-icon.png -------------------------------------------------------------------------------- /assets/sketches/raspi-switch-led.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwittig/pimatic-johnny-five/HEAD/assets/sketches/raspi-switch-led.fzz -------------------------------------------------------------------------------- /assets/sketches/arduino-temperature-4k7-thermistor.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwittig/pimatic-johnny-five/HEAD/assets/sketches/arduino-temperature-4k7-thermistor.fzz -------------------------------------------------------------------------------- /assets/sketches/arduino-temperature-4k7-thermistor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwittig/pimatic-johnny-five/HEAD/assets/sketches/arduino-temperature-4k7-thermistor.png -------------------------------------------------------------------------------- /assets/images/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Copyright Notice 3 | 4 | The 'johnny-five-icon' files have been created with [Inkscape](https://inkscape.org) using artwork 5 | by [Mike Sgier](http://msgierillustration.com/) published as part of the Johnny Five project. 6 | 7 | Copyright (c) 2012, 2013, 2014 Rick Waldron 8 | Copyright (c) 2014, 2015 The Johnny-Five Authors 9 | 10 | MIT-License: https://github.com/rwaldron/johnny-five/blob/master/LICENSE-MIT 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # node-waf configuration 20 | .lock-wscript 21 | 22 | # Compiled binary addons (http://nodejs.org/api/addons.html) 23 | build/Release 24 | 25 | # Dependency directory 26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 27 | node_modules 28 | -------------------------------------------------------------------------------- /devices/johnny-five-lcd-display.coffee: -------------------------------------------------------------------------------- 1 | module.exports = (env) -> 2 | 3 | Promise = env.require 'bluebird' 4 | commons = require('pimatic-plugin-commons')(env) 5 | 6 | 7 | # Device class representing a Johnny Five LCD display 8 | class JohnnyFiveLcdDisplay extends env.devices.Device 9 | 10 | # Create a new JohnnyFiveLcdDisplay device 11 | # @param [Object] config device configuration 12 | # @param [JohnnyFivePlugin] plugin plugin instance 13 | # @param [Object] lastState state information stored in database 14 | constructor: (@config, plugin, lastState) -> 15 | @id = @config.id 16 | @name = @config.name 17 | @debug = @plugin.config.debug || false 18 | @_base = commons.base @, @config.class 19 | super() 20 | 21 | 22 | destroy: () -> 23 | super() -------------------------------------------------------------------------------- /johnny-five-config-schema.coffee: -------------------------------------------------------------------------------- 1 | # #pimatic-johnny-five plugin config options 2 | module.exports = { 3 | title: "pimatic-johnny-five plugin config options" 4 | type: "object" 5 | properties: 6 | boards: 7 | description: "Boards" 8 | type: "array" 9 | default: [] 10 | format: "table" 11 | items: 12 | type: "object" 13 | properties: 14 | id: 15 | type: "string" 16 | description: "A unique identifier used a reference to the boards" 17 | boardType: 18 | type: "string" 19 | description: "Board type, one of arduino, raspi-io, etherport" 20 | default: "arduino" 21 | port: 22 | description: "Path or name of device port" 23 | type: "string" 24 | default: "" 25 | baudrate: 26 | description: "The baudrate to use for serial communication" 27 | type: "number" 28 | required: false 29 | token: 30 | description: "Particle token. Only required for particle-io board type" 31 | type: "string" 32 | required: false 33 | deviceId: 34 | description: "Particle device id. Only required for particle-io board type" 35 | type: "string" 36 | required: false 37 | controller: 38 | description: "Expander controller type. Only required for expander board type" 39 | type: "string" 40 | required: false 41 | address: 42 | description: "Expander I2C address or IP address/hostname. Only used for expander and etherport-client board type" 43 | type: "string" 44 | required: false 45 | debug: 46 | description: "Debug mode. Writes debug messages to the pimatic log, if set to true." 47 | type: "boolean" 48 | default: false 49 | } -------------------------------------------------------------------------------- /devices/johnny-five-servo.coffee: -------------------------------------------------------------------------------- 1 | module.exports = (env) -> 2 | 3 | Promise = env.require 'bluebird' 4 | _ = env.require 'lodash' 5 | five = require('johnny-five') 6 | commons = require('pimatic-plugin-commons')(env) 7 | 8 | 9 | # Device class representing an Johnny Five servo 10 | class JohnnyFiveServo extends env.devices.ButtonsDevice 11 | 12 | # Create a new JohnnyFiveServo device 13 | # @param [Object] config device configuration 14 | # @param [JohnnyFivePlugin] plugin plugin instance 15 | # @param [Object] lastState state information stored in database 16 | constructor: (@config, @plugin, lastState) -> 17 | @id = @config.id 18 | @name = @config.name 19 | for b in @config.buttons 20 | b.text = b.id unless b.text? 21 | @debug = @plugin.config.debug || false 22 | super(@config) 23 | @_base = commons.base @, @config.class 24 | @boardHandle = @plugin.boardManager.getBoard(@config.boardId) 25 | #console.log("----------------------", lastState) 26 | 27 | @boardHandle.boardReady() 28 | .then (board)=> 29 | @_base.debug "initializing digital output pin #{@config.pin}" 30 | @servo = new five.Servo { 31 | pin: @config.pin 32 | controller: @config.controller 33 | address: parseInt @config.address 34 | type: @config.type 35 | range: @config.range 36 | board: board 37 | } 38 | .catch (error) => 39 | @_base.rejectWithError null, error 40 | 41 | 42 | destroy: () -> 43 | super() 44 | 45 | buttonPressed: (buttonId) -> 46 | for b in @config.buttons 47 | if b.id is buttonId 48 | @_lastPressedButton = b.id 49 | @emit 'button', b.id 50 | @servo[b.id]() 51 | return Promise.resolve() 52 | 53 | throw new Error("No button with the id #{buttonId} found") 54 | -------------------------------------------------------------------------------- /devices/johnny-five-oled-display.coffee: -------------------------------------------------------------------------------- 1 | module.exports = (env) -> 2 | 3 | Promise = env.require 'bluebird' 4 | _ = env.require 'lodash' 5 | five = require('johnny-five') 6 | Oled = require('oled-js') 7 | font = require('oled-font-5x7') 8 | commons = require('pimatic-plugin-commons')(env) 9 | 10 | 11 | # Device class representing a Johnny Five OLED display 12 | class JohnnyFiveOledDisplay extends env.devices.Device 13 | attributes: {} 14 | 15 | # Create a new JohnnyFiveOledDisplay device 16 | # @param [Object] config device configuration 17 | # @param [JohnnyFivePlugin] plugin plugin instance 18 | # @param [Object] lastState state information stored in database 19 | constructor: (@config, @plugin, lastState) -> 20 | @id = @config.id 21 | @name = @config.name 22 | @rows = @config.rows || 2 23 | @cols = @config.cols || 16 24 | @debug = @plugin.config.debug || false 25 | @_base = commons.base @, @config.class 26 | 27 | oledOptions = 28 | width: 128 29 | height: 64 30 | if @config.address? and @config.address isnt "" 31 | oledOptions.address = @config.address 32 | # if @config.slavePin? and @config.slavePin isnt "" 33 | # oledOptions.slavePin = @config.slavePin 34 | @_base.debug "Oled config", oledOptions 35 | @board = @plugin.boardManager.getBoard(@config.boardId) 36 | super() 37 | 38 | @board.boardReady() 39 | .then( => 40 | @board.wait 3000, => 41 | @oled = new Oled(@board, five, oledOptions); 42 | @oled.clearDisplay() 43 | @oled.update(); 44 | # @oled.clearDisplay() 45 | # 46 | @oled.setCursor(0, 0); 47 | @oled.writeString(font, 1, '1234567890', 0, false, 2); 48 | @oled.update(); 49 | 50 | ) 51 | .catch ((error) => 52 | @_base.rejectWithError null, error 53 | ) 54 | 55 | 56 | destroy: () -> 57 | super() -------------------------------------------------------------------------------- /devices/johnny-five-contact-sensor.coffee: -------------------------------------------------------------------------------- 1 | module.exports = (env) -> 2 | 3 | Promise = env.require 'bluebird' 4 | five = require('johnny-five') 5 | commons = require('pimatic-plugin-commons')(env) 6 | 7 | 8 | # Device class representing an Johnny Five digital input 9 | class JohnnyFiveContactSensor extends env.devices.ContactSensor 10 | 11 | # Create a new JohnnyFiveContactSensor device 12 | # @param [Object] config device configuration 13 | # @param [JohnnyFivePlugin] plugin plugin instance 14 | # @param [Object] lastState state information stored in database 15 | constructor: (@config, @plugin, lastState) -> 16 | @id = @config.id 17 | @name = @config.name 18 | @debug = @plugin.config.debug || false 19 | @_invert = @config.invert || false 20 | @_contact = @_invert 21 | @_base = commons.base @, @config.class 22 | @boardHandle = @plugin.boardManager.getBoard(@config.boardId) 23 | super() 24 | 25 | @boardHandle.boardReady() 26 | .then (board)=> 27 | @pin = new five.Pin { 28 | pin: @config.pin 29 | type: "digital" 30 | mode: 0 31 | board: board 32 | } 33 | @pin.on("high", => 34 | @_base.debug "#{@id} pin #{@config.pin} HIGH" 35 | @_setContact(!@_invert) 36 | ) 37 | @pin.on("low", => 38 | @_base.debug "#{@id} pin #{@config.pin} LOW" 39 | @_setContact(@_invert) 40 | ) 41 | .catch (error) => 42 | @_base.rejectWithError null, error 43 | 44 | 45 | destroy: () -> 46 | if @pin? 47 | @pin.removeAllListeners 'high' 48 | @pin.removeAllListeners 'low' 49 | delete @pin 50 | super() 51 | 52 | 53 | getContact: () -> 54 | return new Promise( (resolve, reject) => 55 | @boardHandle.boardReady() 56 | .then => 57 | resolve @_contact 58 | .catch (error) => 59 | @_base.rejectWithError reject, error 60 | ) -------------------------------------------------------------------------------- /devices/johnny-five-presence-sensor.coffee: -------------------------------------------------------------------------------- 1 | module.exports = (env) -> 2 | 3 | Promise = env.require 'bluebird' 4 | _ = env.require 'lodash' 5 | five = require('johnny-five') 6 | commons = require('pimatic-plugin-commons')(env) 7 | 8 | 9 | # Device class representing an Johnny Five digital input 10 | class JohnnyFivePresenceSensor extends env.devices.PresenceSensor 11 | 12 | # Create a new JohnnyFivePresenceSensor device 13 | # @param [Object] config device configuration 14 | # @param [JohnnyFivePlugin] plugin plugin instance 15 | # @param [Object] lastState state information stored in database 16 | constructor: (@config, @plugin, lastState) -> 17 | @id = @config.id 18 | @name = @config.name 19 | @debug = @plugin.config.debug || false 20 | @_invert = @config.invert || false 21 | @_presence = @_invert 22 | @_base = commons.base @, @config.class 23 | @board = @plugin.boardManager.getBoard(@config.boardId) 24 | super() 25 | 26 | @board.boardReady() 27 | .then (board)=> 28 | @pin = new five.Pin { 29 | pin: @config.pin 30 | type: "digital" 31 | mode: 0 32 | board: board 33 | } 34 | @boardReady = true 35 | @pin.on("high", => 36 | @_base.debug "#{@id} pin #{@config.pin} HIGH" 37 | @_setPresence(!@_invert) 38 | ) 39 | @pin.on("low", => 40 | @_base.debug "#{@id} pin #{@config.pin} LOW" 41 | @_setPresence(@_invert) 42 | ) 43 | .catch (error) => 44 | @_base.rejectWithError null, error 45 | 46 | 47 | destroy: () -> 48 | if @pin? 49 | @pin.removeAllListeners 'high' 50 | @pin.removeAllListeners 'low' 51 | delete @pin 52 | super() 53 | 54 | 55 | getPresence: () -> 56 | return new Promise( (resolve, reject) => 57 | @board.boardReady() 58 | .then => 59 | resolve @_presence 60 | .catch (error) => 61 | @_base.rejectWithError reject, error 62 | ) -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pimatic-johnny-five", 3 | "description": "Pimatic Plugin for Johnny Five, a Robotics and IoT programming framework.", 4 | "author": { 5 | "name": "Marcus Wittig", 6 | "url": "https://github.com/mwittig" 7 | }, 8 | "main": "johnny-five", 9 | "icon": "assets/images/johnny-five-icon.svg", 10 | "files": [ 11 | "johnny-five.coffee", 12 | "johnny-five-config-schema.coffee", 13 | "device-config-schema.coffee", 14 | "board-manager.coffee", 15 | "devices", 16 | "actions", 17 | "assets", 18 | "LICENSE", 19 | "HISTORY.md", 20 | "README.md" 21 | ], 22 | "keywords": [ 23 | "Johnny Five", 24 | "Pimatic" 25 | ], 26 | "version": "0.9.12", 27 | "homepage": "https://github.com/mwittig/pimatic-johnny-five/tree/master", 28 | "private": false, 29 | "repository": { 30 | "type": "git", 31 | "url": "git://github.com/mwittig/pimatic-johnny-five.git" 32 | }, 33 | "bugs": { 34 | "url": "https://github.com/mwittig/pimatic-johnny-five/issues" 35 | }, 36 | "license": "AGPL-3.0", 37 | "maintainers": [ 38 | { 39 | "name": "mwittig", 40 | "url": "https://github.com/mwittig" 41 | } 42 | ], 43 | "contributors": [ 44 | { 45 | "name": "Ruben Oost", 46 | "email": "ruben@oost.io" 47 | }, 48 | { 49 | "name": "Gabriel Bretschner", 50 | "email": "info@kanedo.net" 51 | } 52 | ], 53 | "configSchema": "johnny-five-config-schema.coffee", 54 | "config": { 55 | "unsafe-perm": true 56 | }, 57 | "dependencies": { 58 | "colornames": "^1.1.1", 59 | "etherport": "git+https://github.com/mwittig/etherport.git#5f3fd5dabf5fc84c8859367d580f45c95fbb7d68", 60 | "etherport-client": "^0.1.3", 61 | "johnny-five": "^0.11.1", 62 | "oled-font-5x7": "^1.0.0", 63 | "oled-js": "^4.0.4", 64 | "pimatic-plugin-commons": "^0.9.5" 65 | }, 66 | "optionalDependencies": { 67 | "particle-io": "^0.14.0", 68 | "raspi-io": "^8.0.1", 69 | "pigpio": "^0.5.1" 70 | }, 71 | "peerDependencies": { 72 | "pimatic": ">=0.8.0 <1.0.0" 73 | }, 74 | "engines": { 75 | "node": ">= 4", 76 | "npm": ">1.1.x" 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /devices/johnny-five-button.coffee: -------------------------------------------------------------------------------- 1 | module.exports = (env) -> 2 | 3 | Promise = env.require 'bluebird' 4 | five = require('johnny-five') 5 | commons = require('pimatic-plugin-commons')(env) 6 | 7 | 8 | # Device class representing an Johnny Five digital input 9 | class JohnnyFiveButton extends env.devices.ContactSensor 10 | 11 | # Create a new JohnnyFiveButton device 12 | # @param [Object] config device configuration 13 | # @param [JohnnyFivePlugin] plugin plugin instance 14 | # @param [Object] lastState state information stored in database 15 | constructor: (@config, @plugin, lastState) -> 16 | @id = @config.id 17 | @name = @config.name 18 | @debug = @plugin.config.debug || false 19 | @_contact = false 20 | @_base = commons.base @, @config.class 21 | @board = @plugin.boardManager.getBoard(@config.boardId) 22 | super() 23 | 24 | @_setContact(if @config.pullUp then true else false) 25 | @board.boardReady() 26 | .then( (board)=> 27 | try 28 | @button = new five.Button { 29 | pin: @config.pin 30 | pullup: @config.pullUp || false 31 | invert: @config.invert || false 32 | holdtime: @config.holdTime || 500 33 | controller: @config.controller || undefined 34 | board: board 35 | } 36 | catch error 37 | throw error 38 | 39 | @button.on("hold", => 40 | @_base.debug "#{@id} pin #{@config.pin} HOLD" 41 | @_setContact(true) 42 | ) 43 | @button.on("press", => 44 | @_base.debug "#{@id} pin #{@config.pin} PRESS" 45 | ) 46 | @button.on("release", => 47 | @_base.debug "#{@id} pin #{@config.pin} RELEASE" 48 | @_setContact(false) 49 | ) 50 | ) 51 | .catch (error) => 52 | @_base.rejectWithError null, error 53 | 54 | destroy: () -> 55 | if @button? 56 | @button.removeAllListeners 'hold' 57 | @button.removeAllListeners 'press' 58 | @button.removeAllListeners 'release' 59 | delete @button 60 | super() 61 | 62 | getContact: () -> 63 | return Promise.resolve @_contact -------------------------------------------------------------------------------- /devices/johnny-five-relay.coffee: -------------------------------------------------------------------------------- 1 | module.exports = (env) -> 2 | 3 | Promise = env.require 'bluebird' 4 | _ = env.require 'lodash' 5 | five = require('johnny-five') 6 | commons = require('pimatic-plugin-commons')(env) 7 | 8 | # Device class representing an Johnny Five digital output 9 | class JohnnyFiveRelay extends env.devices.SwitchActuator 10 | 11 | # Create a new JohnnyFiveRelay device 12 | # @param [Object] config device configuration 13 | # @param [JohnnyFivePlugin] plugin plugin instance 14 | # @param [Object] lastState state information stored in database 15 | constructor: (@config, @plugin, lastState) -> 16 | @id = @config.id 17 | @name = @config.name 18 | @debug = @plugin.config.debug || false 19 | @_base = commons.base @, @config.class 20 | @_state = lastState?.state?.value or off 21 | @boardHandle = @plugin.boardManager.getBoard(@config.boardId) 22 | super() 23 | 24 | @boardHandle.boardReady() 25 | .then( (board)=> 26 | @relay = new five.Relay { 27 | pin: @config.pin 28 | type: "NC" 29 | board: board 30 | } 31 | @changeStateTo(@_state) 32 | ) 33 | .catch ((error) => 34 | @_base.rejectWithError null, error 35 | ) 36 | 37 | 38 | destroy: () -> 39 | super() 40 | 41 | 42 | _queryState: () -> 43 | return new Promise( (resolve, reject) => 44 | @boardHandle.boardReady() 45 | .then => 46 | try 47 | resolve @relay.isOn 48 | catch e 49 | @_base.rejectWithError reject, e 50 | .catch (error) => 51 | @_base.rejectWithError reject, error 52 | ) 53 | 54 | 55 | changeStateTo: (newState) -> 56 | @_base.debug "state change requested to: #{newState}" 57 | return new Promise( (resolve, reject) => 58 | @boardHandle.boardReady() 59 | .then => 60 | if newState 61 | @relay.on() 62 | else 63 | @relay.off() 64 | @_setState newState 65 | resolve newState 66 | .catch (error) => 67 | @_base.rejectWithError reject, error 68 | ) 69 | 70 | 71 | getState: () -> 72 | return @_queryState() 73 | .then (state) => 74 | return Promise.resolve state 75 | .catch (error) => 76 | return @_base.rejectWithError Promise.reject 77 | -------------------------------------------------------------------------------- /johnny-five.coffee: -------------------------------------------------------------------------------- 1 | # Johnny Five plugin 2 | module.exports = (env) -> 3 | 4 | BoardManager = require('./board-manager')(env) 5 | deviceTypes = {} 6 | for device in [ 7 | # 'johnny-five-lcd-display' 8 | 'johnny-five-oled-display' 9 | 'johnny-five-switch' 10 | 'johnny-five-contact-sensor' 11 | 'johnny-five-presence-sensor' 12 | 'johnny-five-button' 13 | 'johnny-five-relay' 14 | 'johnny-five-pwm-output' 15 | 'johnny-five-temperature' 16 | 'johnny-five-temperature-humidity' 17 | 'johnny-five-temperature-pressure' 18 | 'johnny-five-rgb-led' 19 | 'johnny-five-servo' 20 | ] 21 | # convert kebap-case to camel-case notation with first character capitalized 22 | className = device.replace /(^[a-z])|(\-[a-z])/g, ($1) -> $1.toUpperCase().replace('-','') 23 | deviceTypes[className] = require('./devices/' + device)(env) 24 | 25 | actionProviders = {} 26 | for provider in [ 27 | 'johnny-five-rgb-color-action' 28 | ] 29 | # convert kebap-case to camel-case notation with first character capitalized 30 | className = provider.replace(/(^[a-z])|(\-[a-z])/g, ($1) -> $1.toUpperCase().replace('-','')) + 'Provider' 31 | actionProviders[className] = require('./actions/' + provider)(env) 32 | 33 | # ###JohnnyFivePlugin class 34 | class JohnnyFivePlugin extends env.plugins.Plugin 35 | 36 | init: (app, @framework, @config) => 37 | @boardManager = new BoardManager(@config, @) 38 | 39 | # register devices 40 | deviceConfigDef = require("./device-config-schema") 41 | 42 | for className, classType of deviceTypes 43 | env.logger.debug "Registering device class #{className}" 44 | @framework.deviceManager.registerDeviceClass(className, { 45 | configDef: deviceConfigDef[className], 46 | createCallback: @callbackHandler(className, classType) 47 | }) 48 | 49 | for className, classType of actionProviders 50 | env.logger.debug "Registering action provider #{className}" 51 | @framework.ruleManager.addActionProvider(new classType @framework) 52 | 53 | callbackHandler: (className, classType) -> 54 | # this closure is required to keep the className and classType context as part of the iteration 55 | return (config, lastState) => 56 | return new classType(config, @, lastState) 57 | 58 | 59 | # ###Finally 60 | # Create a instance of my plugin 61 | # and return it to the framework. 62 | return new JohnnyFivePlugin -------------------------------------------------------------------------------- /devices/johnny-five-temperature.coffee: -------------------------------------------------------------------------------- 1 | module.exports = (env) -> 2 | 3 | Promise = env.require 'bluebird' 4 | _ = env.require 'lodash' 5 | five = require('johnny-five') 6 | commons = require('pimatic-plugin-commons')(env) 7 | 8 | 9 | # Device class representing an Johnny Five temperature sensor 10 | class JohnnyFiveTemperature extends env.devices.TemperatureSensor 11 | 12 | # Create a new JohnnyFiveTemperature device 13 | # @param [Object] config device configuration 14 | # @param [JohnnyFivePlugin] plugin plugin instance 15 | # @param [Object] lastState state information stored in database 16 | constructor: (@config, @plugin, lastState) -> 17 | @id = @config.id 18 | @name = @config.name 19 | @debug = @plugin.config.debug || false 20 | @_base = commons.base @, @config.class 21 | @_temperature = lastState?.temperature?.value or null 22 | @_offset = @config.offset || 0 23 | @_temperatureKey = "celsius" 24 | if @config.units is "imperial" 25 | @attributes["temperature"].unit = '°F' 26 | @_temperatureKey = "fahrenheit" 27 | else if @config.units is "standard" 28 | @attributes["temperature"].unit = 'K' 29 | @_temperatureKey = "kelvin" 30 | @boardHandle = @plugin.boardManager.getBoard(@config.boardId) 31 | super() 32 | 33 | @boardHandle.boardReady() 34 | .then( (board) => 35 | try 36 | @thermometer = new five.Thermometer { 37 | pin: @config.pin || undefined 38 | address: if not _.isEmpty @config.address then parseInt @config.address else undefined 39 | freq: 1000 * (@config.interval || 10) 40 | controller: @config.controller || 'ANALOG' 41 | board: board 42 | } 43 | catch error 44 | throw error 45 | 46 | @thermometer.on('data', => 47 | @_base.debug "temperature (raw): #{@thermometer[@_temperatureKey]} #{@_temperatureKey} (offset) #{@_offset}" 48 | @_setTemperature @thermometer[@_temperatureKey] + @_offset 49 | ) 50 | ) 51 | .catch (error) => 52 | @_base.rejectWithError null, error 53 | 54 | 55 | destroy: () -> 56 | @thermometer.removeAllListeners 'data' if @thermometer? 57 | @boardHandle.releasePin @config.pin, @config.controller || 'ANALOG' 58 | delete @thermometer 59 | super() 60 | 61 | 62 | getTemperature: -> 63 | @boardHandle.boardReady() 64 | .then => 65 | Promise.resolve(@_temperature) -------------------------------------------------------------------------------- /devices/johnny-five-switch.coffee: -------------------------------------------------------------------------------- 1 | module.exports = (env) -> 2 | 3 | Promise = env.require 'bluebird' 4 | _ = env.require 'lodash' 5 | five = require('johnny-five') 6 | commons = require('pimatic-plugin-commons')(env) 7 | 8 | 9 | # Device class representing an Johnny Five digital output 10 | class JohnnyFiveSwitch extends env.devices.SwitchActuator 11 | 12 | # Create a new JohnnyFiveSwitch device 13 | # @param [Object] config device configuration 14 | # @param [JohnnyFivePlugin] plugin plugin instance 15 | # @param [Object] lastState state information stored in database 16 | constructor: (@config, @plugin, lastState) -> 17 | @id = @config.id 18 | @name = @config.name 19 | super() 20 | @debug = @plugin.config.debug || false 21 | @_base = commons.base @, @config.class 22 | @_state = off 23 | @boardHandle = @plugin.boardManager.getBoard(@config.boardId) 24 | #console.log("----------------------", lastState) 25 | 26 | @boardHandle.boardReady() 27 | .then (board)=> 28 | @_base.debug "initializing digital output pin #{@config.pin}" 29 | @pin = new five.Pin { 30 | pin: @config.pin 31 | type: "digital" 32 | mode: 1 33 | board: board 34 | } 35 | @changeStateTo lastState?.state?.value or off 36 | .catch (error) => 37 | @_base.rejectWithError null, error 38 | 39 | 40 | destroy: () -> 41 | super() 42 | 43 | 44 | _queryState: () -> 45 | return new Promise( (resolve, reject) => 46 | @boardHandle.boardReady() 47 | .then (board) => 48 | try 49 | if (board.remote) 50 | resolve @_state 51 | else 52 | resolve if @pin.value is 1 then true else false 53 | catch e 54 | @_base.rejectWithError reject, e 55 | .catch (error) => 56 | @_base.rejectWithError reject, error 57 | ) 58 | 59 | changeStateTo: (newState) -> 60 | @_base.debug "state change requested to: #{newState}" 61 | return new Promise (resolve, reject) => 62 | @boardHandle.boardReady() 63 | .then (board)=> 64 | stateVal = if newState then 1 else 0 65 | try 66 | @pin.write stateVal 67 | catch e 68 | @_base.rejectWithError reject, e 69 | 70 | if board.remote 71 | @_setState newState 72 | resolve() 73 | else 74 | @_queryState() 75 | .then (state) => 76 | @_setState state 77 | resolve() 78 | .catch (error) => 79 | @_base.rejectWithError reject, error 80 | 81 | 82 | getState: () -> 83 | return Promise.resolve @_state 84 | -------------------------------------------------------------------------------- /devices/johnny-five-pwm-output.coffee: -------------------------------------------------------------------------------- 1 | module.exports = (env) -> 2 | 3 | Promise = env.require 'bluebird' 4 | _ = env.require 'lodash' 5 | five = require('johnny-five') 6 | commons = require('pimatic-plugin-commons')(env) 7 | 8 | 9 | # Device class representing an Johnny Five digital PWM output 10 | class JohnnyFivePwmOutput extends env.devices.DimmerActuator 11 | 12 | # Create a new JohnnyFivePwmOutput device 13 | # @param [Object] config device configuration 14 | # @param [JohnnyFivePlugin] plugin plugin instance 15 | # @param [Object] lastState state information stored in database 16 | constructor: (@config, @plugin, lastState) -> 17 | @id = @config.id 18 | @name = @config.name 19 | @debug = @plugin.config.debug || false 20 | @_dimlevel = 0 21 | @_state = off 22 | @_base = commons.base @, @config.class 23 | @boardHandle = @plugin.boardManager.getBoard(@config.boardId) 24 | super() 25 | 26 | @boardHandle.boardReady() 27 | .then( (board)=> 28 | @pin = new five.Led { 29 | pin: @config.pin 30 | board: board 31 | } 32 | @changeDimlevelTo(lastState?.dimlevel?.value or 0) 33 | .catch (error) => 34 | @_base.rejectWithError null, error 35 | ) 36 | .catch ((error) => 37 | @_base.rejectWithError null, error 38 | ) 39 | 40 | 41 | destroy: () -> 42 | super() 43 | 44 | _queryLevel: () -> 45 | return new Promise( (resolve, reject) => 46 | @boardHandle.boardReady() 47 | .then => 48 | try 49 | resolve @pin.value * 100 / 255 50 | catch e 51 | @_base.rejectWithError reject, e 52 | .catch (error) => 53 | @_base.rejectWithError reject, error 54 | ) 55 | 56 | 57 | changeDimlevelTo: (newLevelPerCent) -> 58 | @_base.debug "dimlevel change requested to (per cent): #{newLevelPerCent}" 59 | return new Promise( (resolve, reject) => 60 | @boardHandle.boardReady() 61 | .then => 62 | try 63 | @pin.brightness newLevelPerCent * 255 / 100 64 | catch e 65 | @_base.rejectWithError reject, e 66 | @_queryLevel() 67 | .then (level) => 68 | @_setDimlevel level 69 | resolve level 70 | .catch (error) => 71 | @_base.rejectWithError reject, error 72 | ) 73 | 74 | getState: () -> 75 | @_queryLevel() 76 | .then (level) => 77 | return Promise.resolve level > 0 78 | .catch (error) => 79 | return @_base.rejectWithError Promise.reject, error 80 | 81 | getDimlevel: () -> 82 | @_queryLevel() 83 | .then (level) => 84 | return Promise.resolve level 85 | .catch (error) => 86 | return @_base.rejectWithError Promise.reject, error -------------------------------------------------------------------------------- /assets/docs/pin-naming.md: -------------------------------------------------------------------------------- 1 | # Pin Naming 2 | 3 | Note, if the device configuration is edited with a text editor pin assignments always need to be provided as string 4 | (in quotes). If the device editor of the pimatic frontend is used, no quotes are required as the editor will 5 | automatically transform the input to a string value based on the device schema. 6 | 7 | ## Raspberry Boards (raspi-io) 8 | 9 | Pin numbers can be specified using one of the following: 10 | * by function name, e.g. "GPIO7" 11 | * by header pin number, which is specified in the form "P[header]-[pin]", e.g. 'P1-40' 12 | * by Wiring Pi virtual pin number, e.g. "29" 13 | 14 | For Raspberry B+/2/3 the pinout and naming schemes are as shown in table below. Function names given in brackets 15 | cannot be used for for pin assignments. As part of the 16 | [raspi-io Wiki, more details](https://github.com/nebrius/raspi-io/wiki/Pin-Information) can be found for the various 17 | types of Raspberry Pi boards. 18 | 19 | | WiringPi| Pin Name | Header Pin | Header Pin | Pin Name | WiringPi | 20 | |:--------|:---------|:------------|-------------:|:---------|:---------| 21 | | – | (+3,3V) | P1-1 | P1-2 | (+5V) | – | 22 | | 8 | GPIO2 | P1-3 | P1-4 | (+5V) | - | 23 | | 9 | GPIO3 | P1-5 | P1-6 | (GND) | - | 24 | | 7 | GPIO4 | P1-7 | P1-8 | GPIO14 | 15 | 25 | | - | (GND) | P1-9 | P1-10 | GPIO15 | 16 | 26 | | 0 | GPIO17 | P1-11 | P1-12 | GPIO18 | 1 | 27 | | 2 | GPIO27 | P1-13 | P1-14 | (GND) | - | 28 | | 3 | GPIO22 | P1-15 | P1-16 | GPIO23 | 4 | 29 | | - | (+3,3V) | P1-17 | P1-18 | GPIO24 | 5 | 30 | | 12 | GPIO10 | P1-19 | P1-20 | (GND) | - | 31 | | 13 | GPIO9 | P1-21 | P1-22 | GPIO25 | 6 | 32 | | 14 | GPIO11 | P1-23 | P1-24 | GPIO8 | 10 | 33 | | - | (GND) | P1-25 | P1-26 | GPIO7 | 11 | 34 | | 30 | (SDA.0) | P1-27 | P1-28 | (SCL.0) | 31 | 35 | | 21 | GPIO5 | P1-29 | P1-30 | (GND) | - | 36 | | 22 | GPIO6 | P1-31 | P1-32 | GPIO12 | 26 | 37 | | 23 | GPIO13 | P1-33 | P1-34 | (GND) | - | 38 | | 24 | GPIO19 | P1-35 | P1-36 | GPIO16 | 27 | 39 | | 25 | GPIO26 | P1-37 | P1-38 | GPIO20 | 28 | 40 | | - | (GND) | P1-39 | P1-40 | GPIO21 | 29 | 41 | 42 | ## Particle Boards (particle-io) 43 | 44 | For the assignment of analog or digital pins simply use the pin names as printed on the PCB. 45 | 46 | ## Arduino Boards (arduino) 47 | 48 | For pin assignments use the logical pin numbers. For digital pins the logical number is also used as part 49 | of the pin name which is usually printed on the PCB. For example, for pin "D13" use "13". For analog pins you may 50 | also use the pin name. For example, you can use "A0" instead of the pin number "14" for Arduino Nano. 51 | 52 | ## Expander Boards (expander) 53 | 54 | For pin assignments use the logical pin numbers. For example, for MCP23017 which has 2x8 I/O ports use pin numbers 0 to 55 | 7 for GPA0 to GPA7 and numbers 8 to 15 for GPB0 to GPB7. 56 | 57 | -------------------------------------------------------------------------------- /actions/johnny-five-rgb-color-action.coffee: -------------------------------------------------------------------------------- 1 | module.exports = (env) -> 2 | 3 | Promise = env.require 'bluebird' 4 | assert = env.require 'cassert' 5 | _ = env.require 'lodash' 6 | M = env.matcher 7 | colors = require 'colornames' 8 | colorNames = colors.all().filter((v) -> v.css is true).map((v) -> v.name) 9 | 10 | class JohnnyFiveRgbColorActionHandler extends env.actions.ActionHandler 11 | constructor: (@provider, @device, @color, @variable) -> 12 | @_variableManager = @provider.framework.variableManager 13 | super() 14 | 15 | setup: -> 16 | @dependOnDevice(@device) 17 | super() 18 | 19 | executeAction: (simulate) => 20 | if @variable? 21 | @_variableManager.evaluateStringExpression([@variable]) 22 | .then (value) => 23 | if value.match(/(#[a-fA-F\d]{6})(.*)/)? or colors(value)? 24 | @setColor value, simulate 25 | else 26 | Promise.reject new Error __("variable value #{value} is not a valid color") 27 | else 28 | @setColor @color, simulate 29 | 30 | setColor: (color, simulate) => 31 | if simulate 32 | return Promise.resolve(__("would log set color #{color}")) 33 | else 34 | @device.setColor color 35 | return Promise.resolve(__("set color #{color}")) 36 | 37 | class JohnnyFiveRgbColorActionProvider extends env.actions.ActionProvider 38 | constructor: (@framework) -> 39 | super() 40 | 41 | parseAction: (input, context) => 42 | j5ColorDevices = _(@framework.deviceManager.devices).values().filter( 43 | (device) => device.config.class is 'JohnnyFiveRgbLed' 44 | ).value() 45 | 46 | # Try to match the input string with: set -> 47 | m = M(input, context).match(['j5 set color ']) 48 | 49 | device = null 50 | color = null 51 | match = null 52 | variable = null 53 | 54 | # device name -> color 55 | m.matchDevice j5ColorDevices, (m, d) -> 56 | # Already had a match with another device? 57 | if device? and device.id isnt d.id 58 | context?.addError(""""#{input.trim()}" is ambiguous.""") 59 | return 60 | 61 | device = d 62 | 63 | m.match [' to '], (m) -> 64 | m.or [ 65 | # rgb hex like #00FF00 66 | (m) -> m.match [/(#[a-fA-F\d]{6})(.*)/], (m, s) -> 67 | color = s.trim() 68 | match = m.getFullMatch() 69 | 70 | # color name like red 71 | (m) -> m.match colorNames, (m, s) -> 72 | color = colors(s) 73 | match = m.getFullMatch() 74 | 75 | # a variable holding the color value 76 | (m) -> m.matchVariable (m, s) -> 77 | variable = s 78 | match = m.getFullMatch() 79 | ] 80 | 81 | if match? 82 | assert device? 83 | # either variable or color should be set 84 | assert variable? ^ color? 85 | assert typeof match is "string" 86 | return { 87 | token: match 88 | nextInput: input.substring(match.length) 89 | actionHandler: new JohnnyFiveRgbColorActionHandler(@, device, color, variable) 90 | } 91 | else 92 | return null 93 | 94 | return JohnnyFiveRgbColorActionProvider 95 | -------------------------------------------------------------------------------- /devices/johnny-five-temperature-humidity.coffee: -------------------------------------------------------------------------------- 1 | module.exports = (env) -> 2 | 3 | Promise = env.require 'bluebird' 4 | _ = env.require 'lodash' 5 | five = require('johnny-five') 6 | commons = require('pimatic-plugin-commons')(env) 7 | 8 | 9 | # Device class representing an Johnny Five temperature and humidity sensor 10 | class JohnnyFiveTemperatureHumidity extends env.devices.TemperatureSensor 11 | 12 | attributes: 13 | temperature: 14 | description: "the measured temperature" 15 | type: "number" 16 | unit: '°C' 17 | acronym: 'T' 18 | humidity: 19 | description: "the measured relative humidity" 20 | type: "number" 21 | unit: '%' 22 | acronym: 'RH' 23 | 24 | # Create a new JohnnyFiveTemperatureHumidity device 25 | # @param [Object] config device configuration 26 | # @param [JohnnyFivePlugin] plugin plugin instance 27 | # @param [Object] lastState state information stored in database 28 | constructor: (@config, @plugin, lastState) -> 29 | @id = @config.id 30 | @name = @config.name 31 | @debug = @plugin.config.debug || false 32 | @_base = commons.base @, @config.class 33 | @_temperature = lastState?.temperature?.value or null 34 | @_humidity = lastState?.humidity?.value or null 35 | @_temperatureOffset = @config.temperatureOffset || 0 36 | @_humidityOffset = @config.humidityOffset || 0 37 | @_temperatureKey = "celsius" 38 | if @config.units is "imperial" 39 | @attributes["temperature"].unit = '°F' 40 | @_temperatureKey = "fahrenheit" 41 | else if @config.units is "standard" 42 | @attributes["temperature"].unit = 'K' 43 | @_temperatureKey = "kelvin" 44 | @boardHandle = @plugin.boardManager.getBoard(@config.boardId) 45 | super() 46 | 47 | @boardHandle.boardReady() 48 | .then( (board)=> 49 | try 50 | @multi = new five.Multi { 51 | pin: @config.pin || undefined 52 | address: if not _.isEmpty @config.address then parseInt @config.address else undefined 53 | freq: 1000 * (@config.interval || 10) 54 | controller: @config.controller || 'ANALOG' 55 | board: board 56 | } 57 | catch error 58 | throw error 59 | 60 | @multi.on("data", => 61 | temperature = if @multi.thermometer? then @multi.thermometer[@_temperatureKey] else null 62 | humidity = if @multi.hygrometer.relativeHumidity? then @multi.hygrometer.relativeHumidity else null 63 | @_base.debug "temperature (raw): #{temperature} #{@_temperatureKey} (offset) #{@_temperatureOffset}" 64 | @_base.debug "humidity (raw): #{humidity} (offset) #{@_humidityOffset}" 65 | @_setTemperature temperature + @_temperatureOffset 66 | @_base.setAttribute "humidity", humidity + @_humidityOffset 67 | ) 68 | ) 69 | .catch (error) => 70 | @_base.rejectWithError null, error 71 | 72 | 73 | destroy: () -> 74 | @multi.removeAllListeners 'data' if @multi? 75 | @boardHandle.releasePin @config.pin, @config.controller || 'ANALOG' 76 | delete @multi 77 | super() 78 | 79 | 80 | getTemperature: -> 81 | @boardHandle.boardReady() 82 | .then => 83 | Promise.resolve(@_temperature) 84 | 85 | getHumidity: -> 86 | @boardHandle.boardReady() 87 | .then => 88 | Promise.resolve(@_humidity) -------------------------------------------------------------------------------- /devices/johnny-five-temperature-pressure.coffee: -------------------------------------------------------------------------------- 1 | module.exports = (env) -> 2 | 3 | Promise = env.require 'bluebird' 4 | _ = env.require 'lodash' 5 | five = require('johnny-five') 6 | commons = require('pimatic-plugin-commons')(env) 7 | 8 | 9 | # Device class representing an Johnny Five temperature and pressure sensor 10 | class JohnnyFiveTemperaturePressure extends env.devices.TemperatureSensor 11 | 12 | attributes: 13 | temperature: 14 | description: "the measured temperature" 15 | type: "number" 16 | unit: '°C' 17 | acronym: 'T' 18 | pressure: 19 | description: "the measured pressure" 20 | type: "number" 21 | unit: 'hPa' 22 | acronym: 'P' 23 | 24 | # Create a new JohnnyFiveTemperatureHumidity device 25 | # @param [Object] config device configuration 26 | # @param [JohnnyFivePlugin] plugin plugin instance 27 | # @param [Object] lastState state information stored in database 28 | constructor: (@config, @plugin, lastState) -> 29 | @id = @config.id 30 | @name = @config.name 31 | @debug = @plugin.config.debug || false 32 | @_base = commons.base @, @config.class 33 | @_temperature = lastState?.temperature?.value or null 34 | @_pressure = lastState?.pressure?.value or null 35 | @_temperatureOffset = @config.temperatureOffset || 0 36 | @_pressureOffset = @config.pressureOffset || 0 37 | @_elevation = @config.elevation || 0 38 | @_temperatureKey = "celsius" 39 | if @config.units is "imperial" 40 | @attributes["temperature"].unit = '°F' 41 | @_temperatureKey = "fahrenheit" 42 | else if @config.units is "standard" 43 | @attributes["temperature"].unit = 'K' 44 | @_temperatureKey = "kelvin" 45 | @boardHandle = @plugin.boardManager.getBoard(@config.boardId) 46 | super() 47 | 48 | @boardHandle.boardReady() 49 | .then( (board)=> 50 | try 51 | @multi = new five.Multi { 52 | pin: @config.pin || undefined 53 | address: if not _.isEmpty @config.address then parseInt @config.address else undefined 54 | freq: 1000 * (@config.interval || 10) 55 | controller: @config.controller || 'MS5611' 56 | board: board, 57 | elevation: @_elevation 58 | } 59 | catch error 60 | throw error 61 | 62 | @multi.on("data", => 63 | temperature = if @multi.thermometer? then @multi.thermometer[@_temperatureKey] else null 64 | pressure = if @multi.barometer.pressure? then @multi.barometer.pressure else null 65 | @_base.debug "temperature (raw): #{temperature} #{@_temperatureKey} (offset) #{@_temperatureOffset}" 66 | @_base.debug "pressure (raw): #{pressure} (offset) #{@_pressureOffset}" 67 | @_setTemperature temperature + @_temperatureOffset 68 | @_base.setAttribute "pressure", pressure * 10 + @_pressureOffset 69 | ) 70 | ) 71 | .catch (error) => 72 | @_base.rejectWithError null, error 73 | 74 | 75 | destroy: () -> 76 | @multi.removeAllListeners 'data' if @multi? 77 | @boardHandle.releasePin @config.pin, @config.controller || 'ANALOG' 78 | delete @multi 79 | super() 80 | 81 | 82 | getTemperature: -> 83 | @boardHandle.boardReady() 84 | .then => 85 | Promise.resolve(@_temperature) 86 | 87 | getPressure: -> 88 | @boardHandle.boardReady() 89 | .then => 90 | Promise.resolve(@_pressure) -------------------------------------------------------------------------------- /HISTORY.md: -------------------------------------------------------------------------------- 1 | # Release History 2 | 3 | * 20170626, V0.9.12 4 | * Updated Dependencies. Now using raspi-io@^8.0.1 which uses pigpio instead of wiringPI to overcome stability 5 | issues with 4.9 kernel. 6 | 7 | * 20170123, V0.9.11 8 | * Bug fixture: added missing require statement for new action 9 | 10 | * 20170123, V0.9.10 11 | * Added support for software PWM for raspi-io 12 | * Added support for excluding pins from use with raspi-io. This might be useful if other GPIO drivers are used 13 | like pimatic-dht-sensors 14 | * Added RGBLedDevice to provide control for common cathode/common cathode LEDs and PCA9685, 15 | an I2C-bus controlled 16-channel LED controller 16 | * Revised README and docs 17 | 18 | * 20170117, V0.9.9 19 | * Improved device schema for temperature unit properties to editable with device editor 20 | * Added debug mode property to enable plugin debugging mode 21 | 22 | * 20170116, V0.9.8 23 | * Improved error handling for the expander board, i.e. handle i2c errors due to misconfiguration 24 | * Improved board configuration handling 25 | 26 | * 20170115, V0.9.7 27 | * Fixed initialization bug for expander board when used with raspi-io, issue #54 28 | * Dependency updates 29 | 30 | * 20161105, V0.9.6 31 | * Fixed handling of i2c address property, issue #47 32 | * Remove data listener on destruction of temperature device 33 | * Added helper to release pins for analog sensors on destruction 34 | 35 | * 20161105, V0.9.5 36 | * fix for invalid I2C address problem, issue 46 37 | * Revised README 38 | 39 | * 20161027, V0.9.4 40 | * Dependency updates 41 | * Added JohnnyFiveTemperaturePressure device type, thanks @kanedo 42 | 43 | * 20160512, V0.9.3 44 | * Dependency updates 45 | * Removed beta tag 46 | 47 | * 20160506, V0.9.2 (beta) 48 | * Dependency updates 49 | * Added badges and travis build descriptor 50 | 51 | * 20160503, V0.9.1 (beta) 52 | * Dependency updates 53 | 54 | * 20160427, V0.9.0 (beta) 55 | * Added ESP-8266 board support (experimental) 56 | * Pimatic 0.9 compatibility changes 57 | * Dependency updates 58 | * Moved release history to separate file 59 | * Added license info to README 60 | 61 | * 20160305, V0.8.8 62 | * Dependency updates. Now includes support for Raspberry Pi 3 63 | * Fixed some typos 64 | 65 | * 20160210, V0.8.7 66 | * Fixed initialization for "particle-io" boards, issue #3 - thanks @hoodpablo 67 | * Updated README, fixed switch example 68 | 69 | * 20160123, V0.8.6 70 | * Updated dependency on "raspi-io" to include support for enabling pull up resistors by writing HIGH to the pin while in INPUT mode 71 | * Tweaked johnny-five to allow for longer board initialization timeouts to provide for slow initialization of some Arduinos 72 | * Added note to README about installation issue 73 | 74 | * 20160121, V0.8.5 75 | * Added support for Expander boards 76 | * Improved support for setup of remote boards 77 | * Improved robustness and error handling 78 | 79 | * 20160112, V0.8.4 80 | * Fixed dependency on etherport fork, thanks to @rubenoost7 81 | 82 | * 20151229, V0.8.3 83 | * Added board config option to set baudrate 84 | * Fixed error in getBoard() function 85 | 86 | * 20151228, V0.8.2 87 | * Fix: Added missing board-manager.coffee to files property 88 | 89 | * 20151228, V0.8.1 90 | * Added experimental support for Photon boards 91 | * Updated dependency on pimatic-plugin-commons 92 | * Updated README 93 | 94 | * 20151222, V0.8.0 95 | * First release -------------------------------------------------------------------------------- /assets/fonts/default.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | monospace: true, 3 | width: 8, 4 | height: 14, 5 | fontData: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,126,0,0,0,0,0,0,6,6,0,0,1,15,1,0,15,15,0,0,0,0,0,0,0,128,144,240,190,210,252,158,144,0,7,3,4,7,1,0,8,30,54,255,194,194,0,0,6,4,4,15,6,28,34,162,254,240,216,76,198,4,6,1,0,3,7,192,192,62,126,242,158,12,192,3,7,6,4,5,7,0,0,0,15,15,0,0,0,0,0,0,0,0,0,0,0,240,252,14,3,1,1,0,0,1,7,14,24,0,1,3,6,252,248,0,0,0,16,24,12,7,3,0,8,104,46,46,104,72,0,0,0,0,0,0,0,128,128,128,240,128,128,128,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,22,30,2,0,64,64,64,64,64,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,6,0,0,0,0,192,112,28,7,1,16,28,7,1,0,0,0,252,158,2,2,6,252,248,0,3,7,4,4,6,0,4,4,4,254,254,0,0,0,4,4,4,7,7,0,2,2,130,194,126,60,0,0,6,7,5,4,4,0,2,34,34,34,126,220,0,0,4,4,4,4,6,128,192,176,152,142,254,254,128,0,0,0,0,0,7,0,0,62,34,34,226,194,0,0,0,4,4,4,7,0,248,252,38,34,98,226,192,0,3,7,4,4,4,0,2,2,194,114,30,6,0,0,4,7,1,0,0,0,220,254,50,34,118,222,128,0,3,7,4,4,6,0,60,126,66,66,102,252,248,0,4,4,4,4,7,0,0,0,48,48,0,0,0,0,0,0,6,6,0,0,0,0,48,48,0,0,0,0,0,0,22,30,0,128,128,192,64,96,32,32,16,0,0,1,1,3,2,32,32,32,32,32,32,32,32,1,1,1,1,1,1,16,48,32,96,64,192,128,128,4,6,2,3,1,1,0,6,2,194,226,54,30,8,0,0,6,6,6,0,248,28,230,242,10,206,252,0,1,3,6,5,5,5,0,128,240,60,28,248,192,0,6,7,1,1,1,1,0,252,252,68,68,188,184,0,0,7,7,4,4,6,240,248,12,4,4,4,4,0,1,3,6,4,4,4,0,252,252,4,4,12,248,248,0,7,7,4,4,6,0,252,252,68,68,68,68,0,0,7,7,4,4,4,0,252,252,68,68,68,68,4,0,7,7,0,0,0,224,248,24,12,132,132,132,140,0,3,3,6,4,4,0,252,252,64,64,64,252,252,0,7,7,0,0,0,0,4,4,252,252,4,4,0,0,4,4,7,7,4,0,0,4,4,4,252,252,0,0,4,4,4,6,3,0,252,252,224,176,24,4,4,0,7,7,0,1,3,0,252,252,0,0,0,0,0,0,7,7,4,4,4,252,60,240,192,240,60,252,0,7,0,0,1,1,0,0,252,60,112,192,128,252,252,0,7,0,0,1,3,240,248,12,4,4,12,248,240,1,3,6,4,4,6,0,252,252,132,132,204,124,48,0,7,7,0,0,0,240,248,12,4,4,12,248,240,1,3,6,4,4,14,0,252,252,68,196,252,56,0,0,7,7,0,1,3,0,56,124,100,68,196,132,132,0,6,4,4,4,6,4,4,4,252,252,4,4,4,0,0,0,7,7,0,0,252,252,0,0,0,252,252,0,3,7,4,4,4,12,60,240,192,0,192,120,28,0,0,1,7,7,3,60,252,128,240,240,224,192,252,0,7,7,3,0,7,4,12,156,240,224,184,12,4,4,6,3,1,0,3,4,12,56,240,224,112,24,12,0,0,0,7,7,0,4,4,132,228,116,28,12,0,6,7,5,4,4,4,0,0,0,255,255,1,1,1,0,0,0,31,31,16,1,7,28,112,192,0,0,0,0,0,0,0,1,7,0,1,1,1,255,255,0,0,0,16,16,16,31,31,0,192,240,60,30,120,192,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,8,8,8,8,8,8,0,0,1,1,3,2,0,0,0,0,0,0,0,0,0,16,144,144,144,240,240,0,0,7,7,4,4,7,0,255,255,48,16,48,240,192,0,7,7,4,4,6,0,224,240,48,16,16,16,16,0,3,7,6,4,4,0,224,240,16,16,48,255,255,0,3,7,4,4,6,0,224,240,144,144,176,240,192,0,3,7,4,4,4,0,16,16,254,255,17,17,17,0,0,0,7,7,0,0,224,240,16,16,48,240,240,0,35,39,36,36,54,0,255,255,48,16,16,240,224,0,7,7,0,0,0,0,16,16,19,243,243,0,0,0,0,0,0,7,7,0,16,16,16,243,243,0,0,0,32,32,32,63,31,0,255,255,192,96,48,16,16,0,7,7,1,3,6,0,1,1,1,255,255,0,0,0,0,0,0,7,7,240,240,48,240,240,48,240,240,7,7,0,7,7,0,0,240,240,48,16,16,240,224,0,7,7,0,0,0,128,224,112,16,16,48,240,224,0,3,7,4,4,6,0,240,240,16,16,48,240,192,0,63,63,4,4,6,0,224,112,16,16,48,240,240,0,3,6,4,4,6,0,240,240,48,16,48,48,0,0,7,7,0,0,0,0,96,112,144,144,144,16,0,0,4,4,4,4,7,16,16,252,252,16,16,16,0,0,0,7,7,4,4,0,240,240,0,0,240,240,0,0,7,7,4,6,7,16,112,224,0,0,192,240,48,0,0,1,7,6,3,240,240,0,224,224,192,128,240,0,7,7,1,0,7,0,16,112,224,192,96,48,16,0,4,7,1,1,3,16,112,192,0,0,128,224,48,32,32,49,31,14,3,0,16,16,144,208,112,48,16,0,6,7,7,5,4,0,64,64,254,191,1,1,0,0,0,0,15,31,16,0,0,0,255,255,0,0,0,0,0,0,31,31,0,0,1,1,187,191,64,64,0,0,16,16,27,31,0], 6 | lookup: [" ","!","\"","#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}"] 7 | }; -------------------------------------------------------------------------------- /devices/johnny-five-rgb-led.coffee: -------------------------------------------------------------------------------- 1 | module.exports = (env) -> 2 | 3 | types = env.require('decl-api').types 4 | Promise = env.require 'bluebird' 5 | _ = env.require 'lodash' 6 | five = require('johnny-five') 7 | commons = require('pimatic-plugin-commons')(env) 8 | 9 | 10 | # Device class representing an Johnny Five digital PWM output 11 | class JohnnyFiveRgbLed extends env.devices.DimmerActuator 12 | 13 | @attributes = 14 | color: 15 | description: 'RGB hex string fo the LED color value' 16 | type: types.string 17 | unit: 'hex color' 18 | acronym: 'RGB' 19 | @actions = 20 | setColor: 21 | description: 'set a light color' 22 | params: 23 | colorCode: 24 | type: types.string 25 | 26 | # Create a new JohnnyFiveRgbLed device 27 | # @param [Object] config device configuration 28 | # @param [JohnnyFivePlugin] plugin plugin instance 29 | # @param [Object] lastState state information stored in database 30 | constructor: (@config, @plugin, lastState) -> 31 | @id = @config.id 32 | @name = @config.name 33 | @debug = @plugin.config.debug || false 34 | @_dimlevel = 0 35 | @_state = off 36 | @_base = commons.base @, @config.class 37 | @boardHandle = @plugin.boardManager.getBoard(@config.boardId) 38 | @attributes = _.merge {}, @attributes, JohnnyFiveRgbLed.attributes 39 | @actions = _.merge {}, @actions, JohnnyFiveRgbLed.actions 40 | super() 41 | 42 | 43 | @boardHandle.boardReady() 44 | .then( (board)=> 45 | @pin = new five.Led.RGB { 46 | pins: @config.pins 47 | isAnode: @config.isAnode 48 | board: board 49 | } 50 | @changeDimlevelTo(lastState?.dimlevel?.value or 0) 51 | .catch (error) => 52 | @_base.rejectWithError null, error 53 | ) 54 | .catch ((error) => 55 | @_base.rejectWithError null, error 56 | ) 57 | 58 | destroy: () -> 59 | super() 60 | 61 | _queryLevel: () -> 62 | return new Promise( (resolve, reject) => 63 | @boardHandle.boardReady() 64 | .then => 65 | try 66 | resolve if @pin.isOn then @pin.intensity() else 0 67 | catch e 68 | @_base.rejectWithError reject, e 69 | .catch (error) => 70 | @_base.rejectWithError reject, error 71 | ) 72 | 73 | _componentToHex: (c) -> 74 | hex = c.toString 16 75 | if hex.length is 1 then '0' + hex else hex 76 | 77 | 78 | _rgbToHex: (r, g, b) -> 79 | '#' + @_componentToHex(r) + @_componentToHex(g) + @_componentToHex(b) 80 | 81 | _queryColor: () -> 82 | return new Promise( (resolve, reject) => 83 | @boardHandle.boardReady() 84 | .then => 85 | try 86 | color = @pin.color() 87 | resolve @_rgbToHex color.red, color.green, color.blue 88 | catch e 89 | @_base.rejectWithError reject, e 90 | .catch (error) => 91 | @_base.rejectWithError reject, error 92 | ) 93 | 94 | changeDimlevelTo: (newLevelPerCent) -> 95 | @_base.debug "dimlevel change requested to (per cent): #{newLevelPerCent}" 96 | return new Promise( (resolve, reject) => 97 | @boardHandle.boardReady() 98 | .then => 99 | try 100 | @pin.intensity newLevelPerCent 101 | catch e 102 | @_base.rejectWithError reject, e 103 | @_queryLevel() 104 | .then (level) => 105 | @_setDimlevel level 106 | resolve level 107 | .catch (error) => 108 | @_base.rejectWithError reject, error 109 | ) 110 | 111 | getState: () -> 112 | @_queryLevel() 113 | .then (level) => 114 | return Promise.resolve level > 0 115 | .catch (error) => 116 | return @_base.rejectWithError Promise.reject, error 117 | 118 | getDimlevel: () -> 119 | @_queryLevel() 120 | .then (level) => 121 | return Promise.resolve level 122 | .catch (error) => 123 | return @_base.rejectWithError Promise.reject, error 124 | 125 | getColor: () -> 126 | @_queryColor() 127 | .then (color) => 128 | return Promise.resolve color 129 | .catch (error) => 130 | return @_base.rejectWithError Promise.reject, error 131 | 132 | setColor: (color) -> 133 | @_base.debug "color change requested to: #{color}" 134 | return new Promise( (resolve, reject) => 135 | @boardHandle.boardReady() 136 | .then => 137 | try 138 | @pin.color color 139 | catch e 140 | @_base.rejectWithError reject, e 141 | @_queryColor() 142 | .then (c) => 143 | @_base.setAttribute 'color', c 144 | resolve c 145 | .catch (error) => 146 | @_base.rejectWithError reject, error 147 | ) 148 | -------------------------------------------------------------------------------- /board-manager.coffee: -------------------------------------------------------------------------------- 1 | # Class UniPiUpdateManager 2 | module.exports = (env) -> 3 | 4 | Promise = env.require 'bluebird' 5 | _ = env.require 'lodash' 6 | events = require 'events' 7 | util = require 'util' 8 | five = require('johnny-five') 9 | commons = require('pimatic-plugin-commons')(env) 10 | 11 | class ExpanderBoardMapper 12 | constructor: (@opts) -> 13 | @boardIsReady = false 14 | @debug = @opts.debug || false 15 | @id = @opts.id 16 | @_base = commons.base @, "ExpanderBoard" 17 | if not @opts.controller? 18 | throw new Error "Missing controller property for expander board" 19 | 20 | @boardInit = new Promise((resolve, reject) => 21 | @_boardReadyListener = @_boardReadyHandler(resolve, reject) 22 | @_boardNotReadyListener = @_boardNotReadyHandler(resolve, reject) 23 | if @opts.board.isReady 24 | @_boardReadyListener() 25 | else 26 | @opts.board.once "ready", @_boardReadyListener 27 | @opts.board.once "error", @_boardNotReadyListener 28 | ) 29 | .catch (error) => 30 | @_base.error error 31 | 32 | _boardReadyHandler: (resolve, reject) -> 33 | return () => 34 | expanderOptions = 35 | controller: @opts.controller 36 | board: @opts.board 37 | if @opts.address? 38 | expanderOptions.address = parseInt @opts.address 39 | try 40 | @virtual = new five.Board.Virtual({ 41 | io: new five.Expander(expanderOptions), 42 | board: @opts.board 43 | }) 44 | catch error 45 | return reject new Error "Expander board initialization failed: #{error}" 46 | 47 | @opts.board.removeListener "error", @_boardNotReadyListener if @_boardNotReadyListener? 48 | @virtual.remote = false 49 | @_base.debug "Board Ready" 50 | @boardIsReady = true 51 | resolve @virtual 52 | 53 | _boardNotReadyHandler: (resolve, reject) -> 54 | return (error) => 55 | @opts.board.removeListener "ready", @_boardReadyListener if @_boardReadyListener? 56 | @_base.rejectWithErrorString(reject, error) 57 | 58 | boardReady: () -> 59 | return new Promise( (resolve, reject) => 60 | Promise.settle([@boardInit]) 61 | .then () => 62 | if @boardIsReady 63 | resolve @virtual 64 | else 65 | @_base.rejectWithErrorString(reject, new Error "Board not ready") 66 | .catch (error) => 67 | @_base.rejectWithErrorString(reject, error) 68 | ) 69 | 70 | releasePin: (pin, controller) -> 71 | # nothing to do 72 | 73 | 74 | class BoardWrapper extends five.Board 75 | constructor: (opts) -> 76 | super(opts) 77 | @boardIsReady = false 78 | @debug = opts.debug || false 79 | @_base = commons.base @, "Board" 80 | 81 | @boardInit = new Promise((resolve, reject) => 82 | @_boardReadyListener = @_boardReadyHandler(resolve, reject) 83 | @_boardNotReadyListener = @_boardNotReadyHandler(resolve, reject) 84 | if @isReady 85 | @_boardReadyListener() 86 | else 87 | @once "ready", @_boardReadyListener 88 | @once "error", @_boardNotReadyListener 89 | @on "message", (event) => 90 | @_base.debug "Message received:", event.message 91 | @on "error", (error) => 92 | @_base.error "Board not ready:", error.message.replace("\n", "") 93 | @on "ready", => 94 | @_base.debug "Board Ready" 95 | ) 96 | 97 | _boardReadyHandler: (resolve, reject) -> 98 | return () => 99 | @boardIsReady = true 100 | @removeListener "error", @_boardNotReadyListener if @_boardNotReadyListener? 101 | resolve @board 102 | 103 | _boardNotReadyHandler: (resolve, reject) -> 104 | return (error) => 105 | @removeListener "ready", @_boardReadyListener if @_boardReadyListener? 106 | @_base.rejectWithError(reject, error) 107 | 108 | boardReady: () -> 109 | return new Promise( (resolve, reject) => 110 | Promise.settle([@boardInit]) 111 | .then () => 112 | if @boardIsReady 113 | resolve @ 114 | else 115 | @_base.rejectWithError(reject, new Error "Board not ready") 116 | .catch (error) => 117 | @_base.rejectWithError(reject, error) 118 | ) 119 | 120 | releasePin: (pin, controller) -> 121 | if not _.isEmpty pin 122 | checkController = not _.isEmpty controller 123 | for index, slot of @occupied 124 | if checkController 125 | match = slot.controller? and slot.controller is controller 126 | else 127 | match = true 128 | 129 | if slot.value is pin and slot.type is 'pin' and match 130 | @occupied.splice index, 1 131 | break 132 | 133 | 134 | class BoardManager extends events.EventEmitter 135 | 136 | constructor: (@config, plugin) -> 137 | @boards = {} 138 | @debug = plugin.config.debug || false 139 | @_base = commons.base @, "BoardManager" 140 | @piGpioInitialized = false 141 | super() 142 | 143 | boardConfigs = @config.boards 144 | if boardConfigs? and boardConfigs.length isnt 0 145 | defaultBoardConfig = 146 | debug: @debug 147 | repl: false 148 | timeout: 40000 149 | for boardConfig in @config.boards 150 | if boardConfig.id? 151 | try 152 | @boards[boardConfig.id] = @createBoard(_.assign {}, defaultBoardConfig, boardConfig) 153 | @_base.debug "Created board #{boardConfig.id}" 154 | catch e 155 | @_base.error "Creation of board #{boardConfig.id} raised exception:" + e 156 | else 157 | @_base.error "Invalid plugin configuration. Missing board id" 158 | else 159 | @_base.error "Invalid plugin configuration. No boards configured" 160 | 161 | plugin.framework.once 'destroy', (context) => 162 | promise = new Promise( (resolve, reject) => 163 | @_base.info "pimatic is shutting down" 164 | if @piGpioInitialized 165 | (require('pigpio').terminate)() 166 | @_base.info "pigpio terminated" 167 | @piGpioInitialized = false 168 | resolve() 169 | ) 170 | context.waitForIt promise 171 | 172 | createBoard: (options) -> 173 | switch options.boardType || 'arduino' 174 | when 'arduino' then ( 175 | if options.port? and options.baudrate? 176 | fiveModule = require.cache[require.resolve 'johnny-five'] 177 | SerialPort = fiveModule.require 'serialport' 178 | options.port = new SerialPort(options.port, {baudrate: options.baudrate}) 179 | @board = new BoardWrapper options 180 | ) 181 | when 'raspi-io' then ( 182 | unless @piGpioInitialized 183 | @piGpioInitialized = true 184 | @_base.info "pigpio hardwareRevision #{(require('pigpio')).hardwareRevision()}" 185 | (require('pigpio').initialize)() 186 | @_base.info "pigpio initialized" 187 | raspi = require 'raspi-io' 188 | raspiOptions = 189 | enableSoftPwm: true 190 | if options.address? 191 | try 192 | raspiOptions = _.assign({}, JSON.parse(options.address), raspiOptions) 193 | catch e 194 | env.logger.error "Property address does not contain stringified JSON options for raspi-io - ignored." 195 | @board = new BoardWrapper(_.assign({}, options, {io: new raspi(raspiOptions)})) 196 | ) 197 | when 'particle-io' then ( 198 | Particle = require 'particle-io' 199 | @board = new BoardWrapper(_.assign({}, options, {io: new Particle({ 200 | token: options.token, deviceId: options.deviceId })})) 201 | ) 202 | when 'etherport' then ( 203 | EtherPort = require 'etherport' 204 | @board = new BoardWrapper(_.assign({}, options, {port: new EtherPort({ 205 | port: options.port, reset: options.port || false})})) 206 | ) 207 | when 'etherport-client', 'esp8266' then ( 208 | EtherPortClient = require('etherport-client').EtherPortClient 209 | @board = new BoardWrapper(_.assign({}, options, { 210 | port: new EtherPortClient({ 211 | port: options.port, 212 | host: options.address 213 | }) 214 | })) 215 | ) 216 | when 'expander' then ( 217 | parentBoard = @getBoard options.port 218 | @board = new ExpanderBoardMapper(_.assign({}, options, {board: parentBoard})) 219 | ) 220 | else 221 | throw new Error "Unsupported boardType #{options.boardType}" 222 | 223 | return @board 224 | 225 | getBoard: (id) -> 226 | if @boards[id] 227 | board=@boards[id] 228 | if board? 229 | return board 230 | else 231 | error = new Error "Board not found" 232 | @_base.error error 233 | throw error -------------------------------------------------------------------------------- /device-config-schema.coffee: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | title: "pimatic-johnny-five device config schemas" 3 | JohnnyFivePwmOutput: { 4 | title: "Johnny Five PWM Output" 5 | description: "Johnny Five PWM Output" 6 | type: "object" 7 | properties: 8 | boardId: 9 | description: "Id of the board to be used" 10 | type: "string" 11 | pin: 12 | description: "The pin address" 13 | type: "string" 14 | } 15 | JohnnyFiveSwitch: { 16 | title: "Johnny Five Switch" 17 | description: "Johnny Five Switch" 18 | type: "object" 19 | properties: 20 | boardId: 21 | description: "Id of the board to be used" 22 | type: "string" 23 | pin: 24 | description: "The pin address" 25 | type: "string" 26 | } 27 | JohnnyFiveContactSensor: { 28 | title: "Johnny Five Contact Sensor" 29 | description: "Johnny Five Contact Sensor for a digital input" 30 | type: "object" 31 | extensions: ["xConfirm", "xLink", "xClosedLabel", "xOpenedLabel"] 32 | properties: 33 | boardId: 34 | description: "Id of the board to be used" 35 | type: "string" 36 | pin: 37 | description: "The pin address" 38 | type: "string" 39 | invert: 40 | description: "If true, invert the contact states, i.e. 'on' state on LOW. " 41 | type: "boolean" 42 | default: false 43 | } 44 | JohnnyFivePresenceSensor: { 45 | title: "Johnny Five Presence Sensor" 46 | description: "Johnny Five Presence Sensor for a digital input" 47 | type: "object" 48 | extensions: ["xLink", "xPresentLabel", "xAbsentLabel"] 49 | properties: 50 | boardId: 51 | description: "Id of the board to be used" 52 | type: "string" 53 | pin: 54 | description: "The pin address" 55 | type: "string" 56 | invert: 57 | description: "If true, invert the presence states, i.e. 'present' state on LOW. " 58 | type: "boolean" 59 | default: false 60 | } 61 | JohnnyFiveButton: { 62 | title: "Johnny Five Button" 63 | description: "Johnny Five Digital Input" 64 | type: "object" 65 | extensions: ["xLink", "xClosedLabel", "xOpenedLabel"] 66 | properties: 67 | boardId: 68 | description: "Id of the board to be used" 69 | type: "string" 70 | pin: 71 | description: "The pin address" 72 | type: "string" 73 | pullUp: 74 | description: "If true, activate the internal pull-up. As a result, a high signal will be read if push-button is open" 75 | type: "boolean" 76 | default: false 77 | invert: 78 | description: "If true, invert the button state." 79 | type: "boolean" 80 | default: false 81 | holdTime: 82 | description: "Time in milliseconds that the button must be held until triggering an event" 83 | type: "number" 84 | default: 500 85 | controller: 86 | description: "Controller interface type if an EVshield is used. Supports EVS_EV3 and EVS_NXT shields" 87 | type: "string" 88 | default: "" 89 | } 90 | JohnnyFiveRelay: { 91 | title: "Johnny Five Relay" 92 | description: "Johnny Five Relay" 93 | type: "object" 94 | properties: 95 | boardId: 96 | description: "Id of the board to be used" 97 | type: "string" 98 | pin: 99 | description: "The pin address" 100 | type: "string" 101 | type: 102 | description: "Whether the relay is wired to be 'normally open' (NO), or 'normally closed' if pin output is LOW" 103 | enum: ["NO", "NC"] 104 | default: "NO" 105 | } 106 | JohnnyFiveTemperature: { 107 | title: "Johnny Five Temperature" 108 | description: "Johnny Five Temperature" 109 | type: "object" 110 | extensions: ["xLink", "xAttributeOptions"] 111 | properties: 112 | boardId: 113 | description: "Id of the board to be used" 114 | type: "string" 115 | controller: 116 | description: "Controller interface type to be used, one of TINKERKIT, LM35, TMP36, DS18B20, MPU6050, GROVE, BMP180, MPL115A2, MPL3115A2, HTU21D, SI7020" 117 | type: "string" 118 | default: "TINKERKIT" 119 | pin: 120 | description: "The pin address. Required if controller is ANALOG, optional otherwise" 121 | type: "string" 122 | default: "" 123 | address: 124 | description: """ 125 | The I2C address. If controller is an I2C device and address is not provided the device-specfic 126 | default address applies. 127 | """ 128 | type: "string" 129 | default: "" 130 | interval: 131 | description: "The time interval in seconds at which the sensor will be read" 132 | type: "number" 133 | default: 10 134 | units: 135 | description: "Defines whether \"metric\", \"imperial\", or \"standard\" units shall be used" 136 | format: "enum" 137 | enum: ["metric", "imperial", "standard"] 138 | default: "metric" 139 | offset: 140 | description: "A positive or negative offset value to adjust a deviation of the temperature sensor" 141 | type: "number" 142 | default: 0 143 | } 144 | JohnnyFiveTemperatureHumidity: { 145 | title: "Johnny Five Temperature & Humidity" 146 | description: "Johnny Five Temperature & Humidity" 147 | type: "object" 148 | extensions: ["xLink", "xAttributeOptions"] 149 | properties: 150 | boardId: 151 | description: "Id of the board to be used" 152 | type: "string" 153 | controller: 154 | description: "Controller interface type to be used, one of ANALOG, LM35, TMP36, DS18B20, MPU6050, GROVE, BMP180, MPL115A2, MPL3115A2, HTU21D" 155 | type: "string" 156 | default: "ANALOG" 157 | pin: 158 | description: "The pin address. Required if controller is ANALOG, optional otherwise" 159 | type: "string" 160 | default: "" 161 | address: 162 | description: """ 163 | The I2C address. If controller is an I2C device and address is not provided the device-specfic 164 | default address applies. 165 | """ 166 | type: "string" 167 | default: "" 168 | interval: 169 | description: "The time interval in seconds at which the sensor will be read" 170 | type: "number" 171 | default: 10 172 | units: 173 | description: "Defines whether \"metric\", \"imperial\", or \"standard\" units shall be used" 174 | format: "enum" 175 | enum: ["metric", "imperial", "standard"] 176 | default: "metric" 177 | temperatureOffset: 178 | description: "A positive or negative offset value to adjust a deviation of the temperature sensor" 179 | type: "number" 180 | default: 0 181 | humidityOffset: 182 | description: "A positive or negative offset value to adjust a deviation of the humidity sensor" 183 | type: "number" 184 | default: 0 185 | } 186 | JohnnyFiveTemperaturePressure: { 187 | title: "Johnny Five Temperature & Pressure" 188 | description: "Johnny Five Temperature & Pressure" 189 | type: "object" 190 | extensions: ["xLink", "xAttributeOptions"] 191 | properties: 192 | boardId: 193 | description: "Id of the board to be used" 194 | type: "string" 195 | controller: 196 | description: "Controller interface type to be used, one of MS5611" 197 | type: "string" 198 | default: "MS5611" 199 | pin: 200 | description: "The pin address. Required if controller is ANALOG, optional otherwise" 201 | type: "string" 202 | default: "" 203 | address: 204 | description: """ 205 | The I2C address. If controller is an I2C device and address is not provided the device-specfic 206 | default address applies. 207 | """ 208 | type: "string" 209 | default: "" 210 | interval: 211 | description: "The time interval in seconds at which the sensor will be read" 212 | type: "number" 213 | default: 10 214 | units: 215 | description: "Defines whether \"metric\", \"imperial\", or \"standard\" units shall be used" 216 | format: "enum" 217 | enum: ["metric", "imperial", "standard"] 218 | default: "metric" 219 | temperatureOffset: 220 | description: "A positive or negative offset value to adjust a deviation of the temperature sensor" 221 | type: "number" 222 | default: 0 223 | pressureOffset: 224 | description: "A positive or negative offset value to adjust a deviation of the humidity sensor" 225 | type: "number" 226 | default: 0 227 | elevation: 228 | description: "The elevation of the current location in meters" 229 | type: "number" 230 | default: 0 231 | } 232 | JohnnyFiveRgbLed: { 233 | title: "Johnny Five RGB LED" 234 | description: "Johnny Five RGB LED" 235 | type: "object" 236 | properties: 237 | boardId: 238 | description: "Id of the board to be used" 239 | type: "string" 240 | controller: 241 | description: "Controller interface type. One of DEFAULT, PCA9685, BLINKM" 242 | type: "string" 243 | default: "DEFAULT" 244 | pins: 245 | description: "The pins assigned to the RGB LED" 246 | type: "object" 247 | properties: 248 | red: 249 | description: "The pin for red" 250 | type: "string" 251 | green: 252 | description: "The green for green" 253 | type: "string" 254 | blue: 255 | description: "The pin for blue" 256 | type: "string" 257 | isAnode: 258 | description: "If set to true the LED is a common anode LED. Defaults to false, indicating a common cathode LED" 259 | type: "boolean" 260 | default: "false" 261 | } 262 | JohnnyFiveOledDisplay: { 263 | title: "JohnnyFive LED" 264 | description: "JohnnyFive LED" 265 | type: "object" 266 | properties: 267 | boardId: 268 | description: "Id of the board to be used" 269 | type: "string" 270 | address: 271 | description: "The I2C address. If omitted SPI mode is assumed" 272 | type: "string" 273 | default: "" 274 | slavePin: 275 | description: "The slave select pin used in SPI mode" 276 | type: "string" 277 | default: "12" 278 | } 279 | JohnnyFiveLcdDisplay: { 280 | title: "JohnnyFive LED" 281 | description: "JohnnyFive LED" 282 | type: "object" 283 | properties: 284 | boardId: 285 | description: "Id of the board to be used" 286 | type: "string" 287 | controller: 288 | description: "The I2C controller. If omitted the parallel interface will be used." 289 | type: "string" 290 | default: "" 291 | address: 292 | description: "The I2C address. If omitted the default address will be used in I2C mode" 293 | type: "string" 294 | default: "" 295 | pins: 296 | description: "The comma separated list of pins used for the parallel interface." 297 | type: "string" 298 | default: "" 299 | backlight: 300 | description: "The pin driving the backlight for the parallel interface." 301 | type: "string" 302 | default: "" 303 | rows: 304 | description: "The number of rows on the device" 305 | type: "number" 306 | default: 2 307 | cols: 308 | description: "The number of columns on the device" 309 | type: "number" 310 | default: 16 311 | } 312 | JohnnyFiveServo: { 313 | title: "JohnnyFive Servo" 314 | description: "JohnnyFive Servo" 315 | type: "object" 316 | properties: 317 | boardId: 318 | description: "Id of the board to be used" 319 | type: "string" 320 | controller: 321 | description: "Controller interface type: DEFAULT, PCA9685" 322 | type: "string" 323 | default: "DEFAULT" 324 | address: 325 | description: "The I2C address if controller is PCA9685. If omitted the default address will be used in I2C mode" 326 | type: "string" 327 | default: "" 328 | pin: 329 | description: "The pin address" 330 | type: "string" 331 | type: 332 | description: "The type of servo, one of standard or continuous" 333 | type: "string" 334 | default: "standard" 335 | range: 336 | description: "The range of motion in degrees" 337 | type: "array" 338 | default: [ 339 | 0, 340 | 180 341 | ] 342 | format: "table" 343 | items: 344 | type: "number" 345 | buttons: 346 | description: "The inputs to select from" 347 | type: "array" 348 | default: [ 349 | { 350 | id: "min" 351 | } 352 | { 353 | id: "max" 354 | } 355 | { 356 | id: "center" 357 | } 358 | { 359 | id: "stop" 360 | } 361 | ] 362 | format: "table" 363 | items: 364 | type: "object" 365 | properties: 366 | id: 367 | enum: [ 368 | "min", "max", "center", "home", "sweep", "stop", "cw", "ccw" 369 | ] 370 | description: "The input ids switchable by the AVR" 371 | text: 372 | type: "string" 373 | description: """ 374 | The button text to be displayed. The id will be displayed if not set 375 | """ 376 | required: false 377 | confirm: 378 | description: "Ask the user to confirm the input select" 379 | type: "boolean" 380 | default: false 381 | } 382 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # pimatic-johnny-five 3 | 4 | [![npm version](https://badge.fury.io/js/pimatic-johnny-five.svg)](http://badge.fury.io/js/pimatic-johnny-five) 5 | [![Build Status](https://travis-ci.org/mwittig/pimatic-johnny-five.svg?branch=master)](https://travis-ci.org/mwittig/pimatic-johnny-five) 6 | 7 | Pimatic Plugin for [Johnny Five](http://johnny-five.io), a Robotics and IoT programming framework. 8 | 9 | ![Logo](https://github.com/mwittig/pimatic-johnny-five/raw/master/assets/images/johnny-five-icon.png) 10 | 11 | Thanks to Johnny Five, you can easily integrate a wide range of sensors and actuators attached to 12 | * an Arduino board, 13 | * an ESP8266 board, 14 | * a Photon board, or 15 | * your Raspberry Pi. Generally, it is possible to use multiple boards at the same time which may be local boards, 16 | i.e. the host running pimatic or a board attached via USB to the pimatic host, or remote boards connected via LAN, 17 | WiFi or some proxy device on the local network. 18 | 19 | For Arduino, the universal Firmata library is used which implements a protocol for the 20 | communication with host computer. Thus, there is no need to modify the Arduino sketch when new sensors or actuators 21 | are connected to your Arduino. Johnny Five also supports a variety of [I2C](https://en.wikipedia.org/wiki/I%C2%B2C) and 22 | [1-Wire](https://en.wikipedia.org/wiki/1-Wire) devices. 23 | 24 | Support for ESP8266 is experimental at the moment as it requires the 25 | ["esp" development branch](https://github.com/firmata/arduino/tree/esp) of Firmata. 26 | 27 | ## Status of implementation 28 | 29 | This version supports the following devices 30 | * ContactSensor, PresenceSensor, and ButtonSensor (digital input) 31 | * Dimmer (digital output with PWM) 32 | * Switch (digital output) 33 | * Relay Switch (relay boards attached to digital output) 34 | * Temperature Sensor (analog, I2C and 1-Wire) 35 | * Temperature & Humidity Sensor (analog, I2C - sorry, no 1-Wire support, to date) 36 | * Temperature & Barometric Pressure Sensor (I2C devices such as BMP180, MPL115A2, MPL3115A2) 37 | * RGB LED (common cathode/common cathode LEDs and PCA9685, an I2C-bus controlled 16-channel LED controller) 38 | 39 | The OLED and LCD display devices are incomplete and, thus, should not be used. 40 | They won't do anything useful anyway. 41 | 42 | Board-support has been tested with "arduino", "raspi-io", "particle-io", "etherport" and "expander" board types. 43 | Support for "etherport-client" and "esp8266" is experimental. 44 | 45 | ### Contributions 46 | 47 | If you like this plugin, please consider ★ starring 48 | [the project on github](https://github.com/mwittig/pimatic-johnny-five). Contributions to the project are welcome. You can simply fork the project and create a pull request with 49 | your contribution to start with. 50 | 51 | 52 | ### Platform Support 53 | 54 | The plugin currently supports Arduino, Raspberry Pi boards, and tethering. More boards can be 55 | added on request. The Johnny Five project provides a detailed 56 | [list of supported platforms](https://johnny-five.io/platform-support/) with 57 | detailed information on supported features and how to set up the board. 58 | 59 | 60 | 61 | ## Plugin Configuration 62 | 63 | You can load the plugin by editing your `config.json` to include the following 64 | in the `plugins` section. You need to configure the boards you wish to use to control 65 | your devices. Generally, a board is a control system as part of pimatic to drive the 66 | hardware board you use, for example, 67 | * your Raspberry Pi, 68 | * an Arduino board attached to your Raspberry Pi via USB, 69 | * an I2C Expander chip connected to to your Raspberry Pi or Arduino, or 70 | * a remote board connected via etherport. 71 | 72 | The following configuration is an example for pimatic with an Arduino Nano 73 | connected via USB on ttyUSB1 and an Expander connected to the Arduino: 74 | 75 | { 76 | "plugin": "johnny-five", 77 | "boards": [ 78 | { 79 | "id": "1", 80 | "boardType": "arduino", 81 | "port": "/dev/ttyUSB1", 82 | "baudrate": 57600 83 | }, 84 | { 85 | "id": "2", 86 | "boardType": "raspi-io" 87 | }, 88 | { 89 | "id": "3", 90 | "boardType": "expander", 91 | "port": "1", 92 | "controller": "MCP23017" 93 | } 94 | ] 95 | } 96 | 97 | The plugin has the following configuration properties: 98 | 99 | | Property | Default | Type | Description | 100 | |:----------|:---------|:--------|:--------------------------------------------| 101 | | debug | false | Boolean | Provide additional debug output if true | 102 | | boards | - | Array | An Array of board configuration objects | 103 | 104 | The configuration for a board is an object comprising the following properties. 105 | 106 | | Property | Default | Type | Description | 107 | |:----------|:----------|:--------|:--------------------------------------------| 108 | | id | - | String | Unique identifier used as a reference by a device configuration | 109 | | boardType | "arduino" | String | The type of board, see supported types below | 110 | | port | - | String | Path or name of device port | 111 | | token | - | String | Particle token. Only required for particle-io board type | 112 | | deviceId | - | String | Particle device id. Only required for particle-io board type | 113 | | controller | - | String | Expander controller type (see below). Only required for expander board type | 114 | | address | - | String | Expander I2C address for expander board type or IP address/hostname for esp8266 or etherport-client board type | 115 | 116 | Supported `boardTypes` 117 | * "arduino" - see [Platform Support](http://johnny-five.io/platform-support/) 118 | * "raspi-io" - works with all Raspberry Pi models (Zero has not been tested yet). Note, wiringPi must be installed 119 | * "particle-io" - known to work for 120 | [Particle Photon](http://johnny-five.io/platform-support/#particle-photon) and 121 | [Sparkfun Photon RedBoard](http://johnny-five.io/platform-support/#sparkfun-photon-redboard) 122 | * "etherport" - works for Arduinos with ethernet or wifi shields, a software relay to integrate a remote Raspberry will be provided soon. 123 | * "expander" - see supported controller types below 124 | * "esp8266" and "etherport-client" - works for remote boards like ESP6266 which provide a listener socket pimatic needs 125 | to connect to 126 | 127 | Supported Expander `controller` types: 128 | 129 | * "MCP23017" 130 | * "MCP23008" 131 | * "PCF8574" 132 | * "PCF8574A" 133 | * "PCF8575" 134 | * "PCA9685" 135 | * "PCF8591" 136 | * "MUXSHIELD2" 137 | * "GROVEPI" 138 | * "CD74HC4067" 139 | 140 | The `address` needs only to be set if an I2C address other than the default 141 | address is used. 142 | 143 | | Controller | Address Range | Default | 144 | |--------------|---------------|--------| 145 | | "MCP23017" | "0x20"-"0x27" | "0x20" | 146 | | "MCP23008" | "0x20"-"0x27" | "0x20" | 147 | | "PCF8574" | "0x20"-"0x27" | "0x20" | 148 | | "PCF8574A" | "0x38"-"0x3F" | "0x38" | 149 | | "PCF8575" | "0x20"-"0x27" | "0x20" | 150 | | "PCF8591" | "0x48"-"0x4F" | "0x48" | 151 | | "PCA9685" | "0x40"-"0x4F" | "0x40" | 152 | | "GROVEPI" | "0x04" | "0x04" | 153 | | "CD74HC4067" | "0x0A"-"0x0D" | "0x0A" | 154 | 155 | ## Device Configuration 156 | 157 | Devices must be added manually to the device section of your pimatic config. For pin assignment conventions 158 | see the [document on pin naming](https://github.com/mwittig/pimatic-johnny-five/blob/master/assets/docs/pin-naming.md). 159 | 160 | ### Switch Device 161 | 162 | `JohnnyFiveSwitch` is based on the PowerSwitch device class. You need to provide 163 | the address of the output `pin`. The device is mapped to a [JF "digital output" Pin](http://johnny-five.io/api/pin/). 164 | 165 | { 166 | "id": "jf-do-1", 167 | "class": "JohnnyFiveSwitch", 168 | "name": "Digital Output (pin 13)", 169 | "pin": "13", 170 | "boardId": "1" 171 | } 172 | 173 | It has the following configuration properties: 174 | 175 | | Property | Default | Type | Description | 176 | |:----------|:---------|:--------|:--------------------------------------------| 177 | | pin | | String | Pin address of the digital output | 178 | | boardId | - | String | Id of the board to be used | 179 | 180 | The Digital Output Device exhibits the following attributes: 181 | 182 | | Property | Unit | Type | Acronym | Description | 183 | |:--------------|:------|:--------|:--------|:---------------------------------------| 184 | | state | - | Boolean | - | Switch State, true is on, false is off | 185 | 186 | The following predicates and actions are supported: 187 | 188 | * {device} is turned on|off 189 | * switch {device} on|off 190 | * toggle {device} 191 | 192 | ### PWM Output (Dimmer) 193 | 194 | `JohnnyFivePwmOutput` is based on the DimmerActuator device class. You need to provide 195 | the address of the output `pin`. The device is mapped to a [JF Led](http://johnny-five.io/api/led/). 196 | 197 | { 198 | "id": "jf-pwm-1", 199 | "class": "JohnnyFivePwmOutput", 200 | "name": "Digital PWM Output (pin 3)", 201 | "pin": "3", 202 | "boardId": "1" 203 | } 204 | 205 | It has the following configuration properties: 206 | 207 | | Property | Default | Type | Description | 208 | |:----------|:---------|:--------|:--------------------------------------------| 209 | | pin | | String | Pin address of the (PWM capable) digital output | 210 | | boardId | - | String | Id of the board to be used | 211 | 212 | The Digital Output Device exhibits the following attributes: 213 | 214 | | Property | Unit | Type | Acronym | Description | 215 | |:--------------|:------|:--------|:--------|:---------------------------------------| 216 | | state | - | Boolean | - | Switch State, true is on, false is off | 217 | | dimlevel | % | Number | - | A percentage value of the PWM duty cycle | 218 | 219 | The following predicates and actions are supported: 220 | 221 | * {device} is turned on|off 222 | * switch {device} on|off 223 | * toggle {device} 224 | * dim {device} to {value} 225 | 226 | ### RGB LED 227 | 228 | `JohnnyFiveRgbLed` is based on the DimmerActuator device class. You need to provide 229 | the address of the output `pins` for red, green, and blue. The property `isAnode` is 230 | used to specify whether the LED has common anode or cathode. 231 | The device is mapped to a [JF Led.RGB](http://johnny-five.io/api/led.rgb/). 232 | 233 | { 234 | "id": "jf-pwm-1", 235 | "class": "JohnnyFiveRgbLed", 236 | "name": "RGB LED", 237 | "boardId": "2", 238 | "pins": { 239 | "red": "GPIO16", 240 | "green": "GPIO20", 241 | "blue": "GPIO21" 242 | }, 243 | "isAnode": true, 244 | } 245 | 246 | It has the following configuration properties: 247 | 248 | | Property | Default | Type | Description | 249 | |:----------|:---------|:--------|:--------------------------------------------| 250 | | pins | | Object | The pins assigned to the RGB LED, defined by an object with the following properties. | 251 | | pins.red | | String | The pin for red | 252 | | pins.green | | String | The pin for green | 253 | | pins.blue | | String | The pin for blue | 254 | | isAnode | false | Boolean | If set to true the LED is a common anode LED. Defaults to false, indicating a common cathode LED | 255 | | boardId | - | String | Id of the board to be used | 256 | 257 | The Digital Output Device exhibits the following attributes: 258 | 259 | | Property | Unit | Type | Acronym | Description | 260 | |:--------------|:------|:--------|:--------|:---------------------------------------| 261 | | state | - | Boolean | - | Switch State, true is on, false is off | 262 | | dimlevel | % | Number | - | A percentage value of the PWM duty cycle | 263 | | color | - | String | RGB | A 6-digit RGB hex string starting with, or a CSS color name, or a variable reference | 264 | 265 | The following predicates and actions are supported: 266 | 267 | * {device} is turned on|off 268 | * switch {device} on|off 269 | * toggle {device} 270 | * dim {device} to {value} 271 | * j5 set color {device} to {value} 272 | 273 | ### Presence Sensor 274 | 275 | `JohnnyFivePresenceSensor` is a digital input device based on the `PresenceSensor` device class. You need 276 | to provide the address of the input `pin` and the `boardId`. 277 | 278 | { 279 | "id": "jf-cs-1", 280 | "class": "JohnnyFiveContactSensor", 281 | "name": "Digital Input (pin 4)", 282 | "pin": "4", 283 | "boardId": "1" 284 | } 285 | 286 | It has the following configuration properties: 287 | 288 | | Property | Default | Type | Description | 289 | |:----------|:---------|:--------|:--------------------------------------------| 290 | | pin | - | String | Pin address of the digital output | 291 | | boardId | - | String | Id of the board to be used | 292 | | invert | false | Boolean | If true, invert the presence sensor state | 293 | 294 | The presence sensor exhibits the following attributes: 295 | 296 | | Property | Unit | Type | Acronym | Description | 297 | |:--------------|:------|:--------|:--------|:---------------------------------------| 298 | | presence | - | Boolean | - | Presence State, true is present, false is absent | 299 | 300 | The following predicates are supported: 301 | 302 | * {device} is present|absent 303 | 304 | 305 | ### Contact Sensor 306 | 307 | `JohnnyFiveContactSensor` is a digital input device based on the `ContactSensor` device class. You need 308 | to provide the address of the input `pin`. 309 | 310 | { 311 | "id": "jf-cs-1", 312 | "class": "JohnnyFiveContactSensor", 313 | "name": "Digital Input (pin 4)", 314 | "pin": "4", 315 | "boardId": "1" 316 | } 317 | 318 | It has the following configuration properties: 319 | 320 | | Property | Default | Type | Description | 321 | |:----------|:---------|:--------|:--------------------------------------------| 322 | | pin | | String | Pin address of the digital output | 323 | | boardId | - | String | Id of the board to be used | 324 | | invert | false | Boolean | If true, invert the contact sensor state | 325 | 326 | The presence sensor exhibits the following attributes: 327 | 328 | | Property | Unit | Type | Acronym | Description | 329 | |:--------------|:------|:--------|:--------|:---------------------------------------| 330 | | contact | - | Boolean | - | Contact State, true is opened, false is closed | 331 | 332 | 333 | The following predicates are supported: 334 | 335 | * {device} is opened|closed 336 | 337 | ### Button Device 338 | 339 | The Button Device is a digital input device based on the ContactSensor device class. You need 340 | to provide the address of the input `pin`. 341 | 342 | { 343 | "id": "jf-b-1", 344 | "class": "JohnnyFiveButton", 345 | "name": "Button (pin 2)", 346 | "pin": "2", 347 | "boardId": "1" 348 | } 349 | 350 | The Button Device has the following configuration properties: 351 | 352 | | Property | Default | Type | Description | 353 | |:-----------|:---------|:--------|:------------------------------------------------------------------------------| 354 | | pin | - | String | Pin address of the digital output | 355 | | boardId | - | String | Id of the board to be used | 356 | | pullUp | false | Boolean | If true, activate the internal pull-up. As a result, a high signal will be read if push-button is open | 357 | | invert | false | Boolean | If true, invert the button state | 358 | | holdTime | 500 | Number | Time in milliseconds that the button must be held until triggering an event | 359 | | controller | "" | String | Controller interface type if an EVshield is used. Supports 'EVS_EV3' and 'EVS_NXT' shields | 360 | 361 | For wiring examples, see: 362 | 363 | * [Button](http://johnny-five.io/examples/button/) 364 | * [Button - Pull-up](http://johnny-five.io/examples/button-pullup/) 365 | * [Button - EVShield NXT](http://johnny-five.io/examples/button-EVS_NXT/) 366 | 367 | The following predicates are supported: 368 | 369 | * {device} is opened|closed 370 | 371 | ### Relay 372 | 373 | The Relay Device represents a single digital Relay attached to the physical board. You need 374 | to provide the address of the output `pin` controlling the relay. 375 | 376 | { 377 | "id": "jf-r-1", 378 | "name": "Johnny Five Relay", 379 | "class": "JohnnyFiveRelay", 380 | "boardId": "1", 381 | "pin": "12", 382 | "type": "NO" 383 | } 384 | 385 | The Relay Device supports two wiring options: 386 | 387 | * "NO", Normally Open: When provided with any voltage supply, the output is on. The default mode is LOW or "off", 388 | requiring a HIGH signal to turn the relay off. 389 | * "NC", Normally Closed: When provided with any voltage supply, the output is off. The default mode is LOW or “off”, 390 | requiring a HIGH signal to turn the relay on. 391 | 392 | For wiring examples, see: 393 | 394 | * [Relay "NO" and "NC" wiring](http://johnny-five.io/examples/relay/) 395 | 396 | 397 | The Relay Device has the following configuration properties: 398 | 399 | | Property | Default | Type | Description | 400 | |:-----------|:---------|:--------|:------------------------------------------------------------------------------| 401 | | pin | - | String | Pin address of the digital output | 402 | | boardId | - | String | Id of the board to be used | 403 | | type | "NO" | String | Whether the relay is wired to be normally open ("NO"), or normally closed ("NC") if pin output is LOW | 404 | 405 | ### Temperature Sensor 406 | 407 | The Temperature Sensor is an input device based on the TemperatureSensor device class. It currently 408 | supports 4,7k NTC thermistors ("TINKERKIT"), various I2C sensors, and the DS18B20 1Wire sensor. 409 | Depending on type of sensor different properties are required. 410 | 411 | { 412 | "id": "jf-t-1", 413 | "name": "Johnny Five Temperature", 414 | "class": "JohnnyFiveTemperature", 415 | "boardId": "1", 416 | "controller": "SI7020", 417 | "address": "0x40", 418 | "temperatureOffset": -1 419 | }, 420 | { 421 | "id": "jf-t-2", 422 | "name": "Johnny Five Temperature 2", 423 | "class": "JohnnyFiveTemperature", 424 | "boardId": "1", 425 | "pin": "A0", 426 | "controller": "TINKERKIT", 427 | "offset": -2.75, 428 | "units": "metric" 429 | } 430 | 431 | The Temperature Sensor has the following configuration properties: 432 | 433 | | Property | Default | Type | Description | 434 | |:-----------|:------------|:---------|:------------------------------------------------------------------------------| 435 | | controller | "TINKERKIT" | String | Controller interface type to be used, one of TINKERKIT, LM35, TMP36, DS18B20, MPU6050, GROVE, BMP180, MPL115A2, MPL3115A2, HTU21D, SI7020 | | 436 | | pin | "" | String | The pin address. Required if controller is TINKERKIT, optional otherwise | | 437 | | address | "" | String | If controller is an I2C device and address is not provided the device-specfic default address applies | | 438 | | boardId | - | String | Id of the board to be used | 439 | | interval | 10 | Number | The time interval in seconds at which the sensor will be read | 440 | | units | "metric" | String | Defines whether metric, imperial, or standard units shall be used | 441 | | offset | 0 | Number | A positive or negative offset value to adjust a deviation of the temperature sensor | 442 | | controller | "" | String | Controller interface type if an EVshield is used. Supports 'EVS_EV3' and 'EVS_NXT' shields | 443 | 444 | address: 445 | description: """ 446 | The I2C address. If controller is an I2C device and address is not provided the device-specfic 447 | default address applies. 448 | """ 449 | type: "string" 450 | required: false 451 | 452 | For wiring examples, see: 453 | * [Temperature TINKERKIT](http://johnny-five.io/examples/tinkerkit-thermistor/) 454 | * If you don't have the tinkerkit shield, here's a 455 | [wiring sketch](https://github.com/mwittig/pimatic-johnny-five/raw/master/assets/sketches/arduino-temperature-4k7-thermistor.png) 456 | for the thermistor. 457 | * [Temperature MPU6050](http://johnny-five.io/examples/temperature-mpu6050/) 458 | 459 | ## Release History 460 | 461 | See [Release History](https://github.com/mwittig/pimatic-johnny-five/blob/master/HISTORY.md). 462 | 463 | ## Credits 464 | 465 | The 'johnny-five-icon' files have been created with [Inkscape](https://inkscape.org) using artwork 466 | by [Mike Sgier](http://msgierillustration.com/) published as part of the Johnny Five project. 467 | 468 | Copyright (c) 2012, 2013, 2014 Rick Waldron 469 | Copyright (c) 2014, 2015, 2016 The Johnny-Five Authors 470 | 471 | MIT-License: https://github.com/rwaldron/johnny-five/blob/master/LICENSE-MIT 472 | 473 | ## License 474 | 475 | Copyright (c) 2015-2017, Marcus Wittig and contributors. All rights reserved. 476 | 477 | [AGPL-3.0](https://github.com/mwittig/pimatic-johnny-five/blob/master/LICENSE) 478 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | 663 | --------------------------------------------------------------------------------