Skip to content

Commit

Permalink
Updates for gateway 0.10.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrstegeman committed Jan 8, 2020
1 parent a0d7afc commit 8d44a66
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.tgz
SHA256SUMS
node_modules/
*.tgz
package-lock.json
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Telnet-Adapter for [Mozilla-Gateway](https://github.com/mozilla-iot/gateway)
# nanoleaf-adapter

Nanoleaf light adapter for Mozilla WebThings Gateway

## Install
- set Gateway Download-uri to [https://raw.githubusercontent.com/roderm/addon-list/master/list.json](https://raw.githubusercontent.com/roderm/addon-list/master/list.json) (or use current stable-version)
- Add plugin
- Goto "things"
- Press Power-Button on Nanoleaf for 5-7 seconds until 3 dots begin blinking
- click on "+" on Gateway-Things page

- Install add-on in the UI via _Settings -> Add-ons_.
- Go to Things screen
- Press Power Button on Nanoleaf for 5-7 seconds until 3 dots begin blinking
- Click "+" button on Things screen
- Your nanoleaf should be connected
8 changes: 4 additions & 4 deletions lib/nanoleaf-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ const { Adapter } = require('gateway-addon');
const { NanoleafDevice, RegisterDevice } = require('./nanoleaf-device');
const { NanoleafDatabase } = require('./nanoleaf-db');
const { NanoleafScanner } = require('./nanoleaf-scanner');
const manifest = require('../manifest.json');

class NanoleafAdapter extends Adapter {
/**
* Initialize the object.
*
* @param {Object} addonManager - AddonManagerProxy object
* @param {Object} manifest - Package manifest
* @param {function(string, string)} errorCallback - returns an error
*/
constructor(addonManager, manifest, errorCallback) {
super(addonManager, manifest.name, manifest.name);
constructor(addonManager, errorCallback) {
super(addonManager, manifest.id, manifest.id);
addonManager.addAdapter(this);
this.db = new NanoleafDatabase(this.packageName)
this.scannedDevices = new Array();
Expand Down Expand Up @@ -73,4 +73,4 @@ class NanoleafAdapter extends Adapter {

module.exports = {
NanoleafAdapter
}
}
6 changes: 3 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

const { NanoleafAdapter } = require('./lib/nanoleaf-adapter');

module.exports = function(adapterManager, manifest, errorCallback) {
new NanoleafAdapter(adapterManager, manifest, errorCallback);
};
module.exports = function(adapterManager, _, errorCallback) {
new NanoleafAdapter(adapterManager, errorCallback);
};
19 changes: 19 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"author": "Roman Odermatt",
"description": "Adapter for Nanoleaf devices",
"gateway_specific_settings": {
"webthings": {
"exec": "{nodeLoader} {path}",
"primary_type": "adapter",
"strict_max_version": "*",
"strict_min_version": "0.10.0"
}
},
"homepage_url": "https://github.com/roderm/nanoleaf-adapter",
"id": "nanoleaf-adapter",
"license": "MPL-2.0",
"manifest_version": 1,
"name": "Nanoleaf",
"short_name": "Nanoleaf",
"version": "0.1.1"
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
},
"files": [
"LICENSE",
"README.md",
"SHA256SUMS",
"main.js",
"manifest.json",
"node_modules",
"lib/nanoleaf-adapter.js",
"lib/nanoleaf-db.js",
Expand Down
5 changes: 3 additions & 2 deletions package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
rm -rf node_modules
npm install --production
rm -f SHA256SUMS
sha256sum package.json *.js LICENSE > SHA256SUMS
sha256sum manifest.json package.json *.js lib/*.js LICENSE README.md > SHA256SUMS
rm -rf node_modules/.bin
find node_modules -type f -exec sha256sum {} \; >> SHA256SUMS
TARFILE=$(npm pack)
tar xzf ${TARFILE}
cp -r node_modules ./package
tar czf ${TARFILE} package
rm -rf package
echo "Created ${TARFILE}"
echo "Created ${TARFILE}"

0 comments on commit 8d44a66

Please sign in to comment.