Skip to content
This repository has been archived by the owner on Nov 5, 2021. It is now read-only.

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sibartlett committed May 11, 2017
0 parents commit 4e3797a
Show file tree
Hide file tree
Showing 31 changed files with 4,822 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"presets": [
[
"env", {
"targets": {
"node": 6
}
}],
"babel-preset-stage-2"
],
"plugins": [
"add-module-exports"
]
}
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

[*.{js,json}]
charset = utf-8
indent_style = space
indent_size = 2
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
12 changes: 12 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"root": true,
"extends": [
"eslint:recommended",
"prettier"
],
"env": {
"es6": true,
"node": true
},
"parser": "babel-eslint"
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
Empty file added .npmignore
Empty file.
96 changes: 96 additions & 0 deletions DEVICES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Device support

## Air Conditioners

_Wink Aros_

* Change between cool, auto and off.
* Set temperature.

Limitations:

* Direct fan control is not yet available.

## Binary Switches

_Z-Wave non-dimming switches, Wink Outlink, Wink Relay_

* On/Off Functions.
* For the Outlink, uses the power usage to determine if on or off.
* Can be added to HomeKit as a fan:
* using `fan_ids` optional configuration field, or
* automatically if device's name contains the word "fan" (such as "Living Room Fan")

Limitations:

* Does not report actual power usage due to limitation in HomeKit Interface.

## Garage Doors

* Open/Close Wink-connected garage doors.
* Reports Battery Level (where available).

Limitations:

* Does not identify blocked doors due to limitation in Wink Interface.

## Light Bulbs

_Light Bulbs and dimmable switches_

* On/Off and Dimming.
* Bulbs with support allow Hue and Saturation.

## Locks

* Lock/Unlock and report current status.
* Reports Battery Level (where available).

Limitations:

* Does not support tamper detection due to limitation in developer's locks and/or Wink API.

## Propane Tank

* Reports as a battery

## Sensors

_Spotter, Tripper and other PIR and Door/Window Sensors_

* PIR reports as Motion Detector
* Tripper and other Door Sensors report as Doors by default. However, can be added to HomeKit as a window:
* using `window_ids` optional configuration field, or
* automatically if device's name contains the word "window" (such as "Living Room Window")
* Spotter reports Temperature and Humidity to HomeKit.
* Reports Battery Level (where available).

Limitations:

* Spotter does not report brightness, vibration or loudness to HomeKit. Apple expects values and these are simply reported as yes/no concerning if it changed.
* Door/Window Tamper Detection is not available in HomeKit.

## Shades

* Open and close.
* Reports Battery Level (where available).

## Siren

_GoControl Siren_

* Enable/disable siren and strobe independently of each other.

## Smoke Detectors

* Reports CO and Smoke Alarms as available by the detector
* Reports Battery Level.

Limitations:

* Only Kiddie detectors are supported?

## Thermostats

* Should be fully functional.
* Reports Battery Level (where available).
15 changes: 15 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ISC License

Copyright (c) 2017, Simon Bartlett

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
70 changes: 70 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# homebridge-wink3

Yet another Wink plugin for [homebridge](https://github.com/nfarina/homebridge).

* Uses Wink API v2, and local control.
* Subscribes to Wink push notifications, instead of polling for device updates.
* Written in ES7 (arrow functions, async/await, classes).
* Accessory services and characteristics are defined declaratively.

## Installation

1. Install homebridge: `npm install -g homebridge`
2. Install this plugin: `npm install -g homebridge-wink3`
3. Update your configuration file. See sample config.json snippet below.

## Configuration

```json
"platforms": [
{
"platform": "Wink",
"name": "Wink",
"username": "[email protected]",
"password": "WINK_PASSWORD",
"hide_groups": [
"garage_door",
"thermostat"
]
}
]
```

| Parameter | Required | Second Header |
| --------------- | -------- | ---------------------------------------------- |
| `platform` | X | Must always be "Wink". |
| `name` | X | Can be anything. |
| `username` | X | |
| `password` | X | |
| `client_id` | | Client ID permitted to use password grant. |
| `client_secret` | | Only required if you're providing a Client ID. |
| `hide_groups` | | List of Wink Device Groups/Types that will be hidden from Homebridge. (see Device Support table below) |
| `hide_ids` | | List of Wink IDs that will be hidden from Homebridge. |
| `fan_ids` | | List of Wink IDs (for binary switches) that will be added as fans to Homebridge. |
| `window_ids` | | List of Wink IDs that will be added as windows (instead of doors) to Homebridge. |
| `direct_access` | | Attempt to establish direct communication with the Wink hub. Defaults to `true`. |

## Device support

See [DEVICES.md](DEVICES.md) for more detailed information.

| Category | Device Type | Device Group |
|-------------------------------------------------|-------------------|--------------------|
| [Air Conditioners](DEVICES.md#air-conditioners) | `air_conditioner` | `air_conditioners` |
| [Binary Switches](DEVICES.md#binary-switches) | `binary_switch` | `binary_switches` |
| [Garage Doors](DEVICES.md#garage-doors) | `garage_door` | `garage_doors` |
| [Light Bulbs](DEVICES.md#light-bulbs) | `light_bulb` | `light_bulbs` |
| [Locks](DEVICES.md#locks) | `lock` | `locks` |
| [Propane Tanks](DEVICES.md#propane-tanks) | `propane_tank` | `propane_tanks` |
| [Sensors](DEVICES.md#sensors) | `sensor_pod` | `sensor_pods` |
| [Shades](DEVICES.md#shades) | `shade` | `shades` |
| [Sirens](DEVICES.md#sirens) | `siren` | `sirens` |
| [Smoke Detectors](DEVICES.md#smoke-detectors) | `smoke_detector` | `smoke_detectors` |
| [Thermostats](DEVICES.md#thermostats) | `thermostat` | `thermostats` |

## Acknowledgements

This plugin is a crazy rewrite of those that came before:

* The original [homebridge-wink](https://github.com/KraigM/homebridge-wink) plugin, maintained by [KraigM](https://github.com/KraigM)
* A [fork](https://github.com/pdlove/homebridge-wink), maintained by [pdlove](https://github.com/pdlove)
54 changes: 54 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "homebridge-wink3",
"version": "1.0.0",
"description": "Homebridge plugin for wink.com",
"homepage": "https://github.com/sibartlett/homebridge-wink3",
"repository": "git://github.com/sibartlett/homebridge-wink3",
"author": "Simon Bartlett <[email protected]>",
"license": "ISC",
"main": "dist/index.js",
"preferGlobal": true,
"keywords": [
"homebridge-plugin",
"wink"
],
"engines": {
"node": ">=6.0.0",
"homebridge": ">=0.2.5"
},
"scripts": {
"build": "rimraf dist/ && babel src/ --out-dir dist/",
"dropcache": "rm /usr/local/lib/node_modules/homebridge/node_modules/node-persist/storage/accessories/cachedAccessories",
"lint": "eslint .",
"prettier": "prettier --write src/**/*.js",
"precommit": "lint-staged",
"start": "homebridge -D -P . -U ."
},
"lint-staged": {
"*.js": [
"prettier --write",
"git add"
]
},
"dependencies": {
"lodash": "^4.17.4",
"pubnub": "^4.8.0",
"request": "^2.81.0",
"request-promise-native": "^1.0.3",
"require-all": "^2.2.0"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-eslint": "^7.2.3",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-env": "^1.3.3",
"babel-preset-stage-2": "^6.24.1",
"eslint": "^3.19.0",
"eslint-config-prettier": "^1.7.0",
"eslint-plugin-prettier": "^2.0.1",
"husky": "^0.13.3",
"lint-staged": "^3.4.0",
"prettier": "^1.2.2",
"rimraf": "^2.6.1"
}
}
55 changes: 55 additions & 0 deletions src/Accessories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import _ from "lodash";

export default class Accessories {
constructor() {
this.comparator = this.comparator.bind(this);
this._accessories = {};
}

getAccessoryKey(accessory) {
const context = accessory.context || accessory;
return `${context.object_type}/${context.object_id}`;
}

get(device) {
const key = this.getAccessoryKey(device);
return this._accessories[key];
}

add(accessory) {
const key = this.getAccessoryKey(accessory);
return (this._accessories[key] = accessory);
}

remove(accessory) {
const key = this.getAccessoryKey(accessory);
const _accessory = this._accessories[key];
delete this._accessories[key];
return _accessory;
}

forEach(fn) {
return _.forEach(this._accessories, fn);
}

intersection(devices) {
const accessories = _.values(this._accessories);
return _.intersectionWith(devices, accessories, this.comparator);
}

diffAdd(devices) {
const accessories = _.values(this._accessories);
return _.differenceWith(devices, accessories, this.comparator);
}

diffRemove(devices) {
const accessories = _.values(this._accessories);
return _.differenceWith(accessories, devices, this.comparator);
}

comparator(accessory1, accessory2) {
return (
this.getAccessoryKey(accessory1) === this.getAccessoryKey(accessory2)
);
}
}
Loading

0 comments on commit 4e3797a

Please sign in to comment.