├── .gitignore ├── README.md ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # homebridge-foscam-ng 2 | 3 | Foscam camera plugin for [Homebridge](https://github.com/nfarina/homebridge) 4 | 5 | ## Configuration 6 | 7 | Configuration sample: 8 | 9 | ``` 10 | "platforms": [ 11 | { 12 | "platform": "Foscam-NG", 13 | "username": "username", 14 | "password": "password", 15 | "host": "192.168.0.121", 16 | "port": 88, 17 | "gain": 6, 18 | "motionDetector": { 19 | "schedule": { 20 | "monday": [["0:00", "24:00"]], 21 | "tuesday": [["0:00", "24:00"]], 22 | "wednesday": [["0:00", "24:00"]], 23 | "thursday": [["0:00", "24:00"]], 24 | "friday": [["0:00", "24:00"]], 25 | "saturday": [["0:00", "24:00"]], 26 | "sunday": [["0:00", "24:00"]] 27 | }, 28 | 29 | "areas": [ 30 | [[0, 0], [9, 9]] 31 | ] 32 | }, 33 | "speaker": { 34 | "enabled": true, 35 | "compression": true, 36 | "gain": 1 37 | } 38 | } 39 | 40 | ``` 41 | 42 | Fields: 43 | 44 | * "platform": Must always be "Foscam-NG" (required) 45 | * "username": The username for your Foscam camera. Manufacturer default is "admin". (required) 46 | * "password": The password for your Foscam camera. Manufacturer default for "admin" is "". (required) 47 | * "host": The local IP address of your camera. (required) 48 | * "port": The HTTP port for the camera. Manufacturer default is 88. (required) 49 | * "rtspPort": The RTSP port for the camera. Will automatically detect if possible, and will default to HTTP port if not possible. (optional) 50 | * "gain": Foscam audio output tends to be on the quiet side. This is the gain in decibels to boost the audio. Use 0 for no gain. (required) 51 | * "streamType": Video setting to overwrite for iOS's dynamic configuration. Defaults to 3 ("user-defined"). (optional) 52 | * "maxMainStreams": Number of simultaneous streams to allow from the camera's "main" stream. Defaults to 2. (optional) 53 | * "maxSubStreams": Number of simultaneous streams to allow from the camera's "main" stream. Defaults to 2. (optional) 54 | * "motionDetector": Add if motion detector feature is desired. Note that enabling this will overwrite any existing motion detection settings on the Foscam. (optional) 55 | * "schedule": If not present, motion detector is always active. If present, specifies the days and time intervals during which the motion detector is active. 56 | Each day is a list of one or more time intervals. Time intervals are a list with two items, a start time (inclusive) and a stop time (exclusive). All time 57 | is in 24 hour format, with 24:00 denoting the end of the day. Due to Foscam limitations, minutes are only honored in 30 minute increments. (optional) 58 | * "areas": If not present, the motion detector will work on the entire image. If present, specifies the areas of the image the motion detector should pay attention to. 59 | This is a list of rectangular areas. Each rectangular area is a list with two items, a top left coordinate and a bottom right coordinate. Each coordinate is a list 60 | with two items, an x coordinate and a y coordinate. Foscam divides the image into a 10x10 grid, with the top left grid being 0, 0 and the bottom right being 9, 9. 61 | * "triggerInterval": Time in seconds (5-15) to consider the motion detection triggered after detecting a motion, suppressing additional detection of motion during that 62 | time period. Defaults to 5. (optional) 63 | * "sensitivity": 0 for low, 1 for normal, 2 for high, 3 for lower, 4 for lowest. Defaults to 1. (optional) 64 | * "speaker": Add to configure speaker settings. Defaults to enabled. (optional) 65 | * "enabled": Set to false to disable. Defaults to true. (optional) 66 | * "compression": Set to false to disable compression. No compression can result in better quality at the cost of 8 times more bandwidth. Defaults to true. (optional) 67 | * "gain": This is gain in decibels to boost the speaker volume. Defaults to 0. (optional) 68 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var Accessory, hap, UUIDGen; 3 | 4 | const FoscamAccessory = require('homebridge-foscam-stream').FoscamAccessory; 5 | 6 | class FoscamPlatform { 7 | constructor(log, config, api) { 8 | let self = this; 9 | 10 | self.config = config; 11 | self.log = log; 12 | 13 | if (api) { 14 | self.api = api; 15 | 16 | if (api.version < 2.1) { 17 | throw new Error("Unexpected API version."); 18 | } 19 | 20 | self.api.on('didFinishLaunching', self.didFinishLaunching.bind(this)); 21 | } 22 | } 23 | 24 | configureAccessory(accessory) { 25 | } 26 | 27 | didFinishLaunching() { 28 | let self = this; 29 | 30 | let cameraSource = new FoscamAccessory(hap, self.config, self.log); 31 | cameraSource.info().then(info => { 32 | let name = info.devName; 33 | let uuid = UUIDGen.generate('Foscam-NG:' + info.mac); 34 | let cameraAccessory = new Accessory(name, uuid, hap.Accessory.Categories.CAMERA); 35 | cameraAccessory.configureCameraSource(cameraSource); 36 | 37 | self.api.publishCameraAccessories("Foscam-NG", [cameraAccessory]); 38 | }); 39 | } 40 | } 41 | 42 | module.exports = function(homebridge) { 43 | Accessory = homebridge.platformAccessory; 44 | hap = homebridge.hap; 45 | UUIDGen = homebridge.hap.uuid; 46 | 47 | homebridge.registerPlatform("homebridge-foscam-ng", "Foscam-NG", FoscamPlatform, true); 48 | } 49 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "homebridge-foscam-ng", 3 | "version": "0.3.11", 4 | "description": "Foscam plugin for homebridge.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [ 10 | "homebridge-plugin", 11 | "foscam" 12 | ], 13 | "author": "David Wang (https://planetbei.ng/)", 14 | "repository": { 15 | "type": "git", 16 | "url": "https://github.com/planetbeing/homebridge-foscam-ng.git" 17 | }, 18 | "license": "ISC", 19 | "dependencies": { 20 | "homebridge-foscam-stream": "^0.3.11" 21 | }, 22 | "engines": { 23 | "node": ">=6.6.0", 24 | "homebridge": ">=0.4.3", 25 | "hap-nodejs": ">=0.4.11" 26 | } 27 | } 28 | --------------------------------------------------------------------------------