Giter Site home page Giter Site logo

alisamfp / gateblu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from octoblu/legacy-gateway

0.0 2.0 0.0 275 KB

Octoblu Gateway for your LAN-based IoT devices

Home Page: http://skynet.im

License: MIT License

Shell 6.23% JavaScript 93.38% CSS 0.39%

gateblu's Introduction


  GGGG          tt           bb      lll         
 GG  GG   aa aa tt      eee  bb      lll uu   uu 
GG       aa aaa tttt  ee   e bbbbbb  lll uu   uu 
GG   GG aa  aaa tt    eeeee  bb   bb lll uu   uu 
 GGGGGG  aaa aa  tttt  eeeee bbbbbb  lll  uuuu u 
                                                                                               

======

Gateblu

======

Gateblu (SkyNet Hub) allows you to connect devices with or without IP addresses to SkyNet (i.e. Phillips Hue, Belkin WeMo, Insteon, Blink1, Raspberry Pi, etc.).

The Octoblu gateway has an extensible plugin architecture allowing you to create plugins for devices that we have not had a chance to connect yet. You can search NPMJS.org for a list of active SkyNet Hub plugins.

For example if you wish to install the SkyNet plugin for the Philips hue, you can simply npm install skynet-hue in the directory your hub installed.


Installing

Clone the git repository, then:

$ npm install
$ node server.js

If you would like to connect your SkyNet Hub to a private SkyNet cloud, then:

$ env SKYNET_SERVER=127.0.0.1 SKYNET_PORT=3000 GATEBLU_PORT=8888 node server.js

Subdevices

An Octoblu gateway can have subdevices attached to it. A subdevice is a configured instance of a plugin. It could be anything from a Philips hue lighting system to an arduino to a simple javascript function that just calls a shell script on the Octoblu gateway itself.

You can have as many subdevices on the gateway as you wish, as long as gateway has the plugin type installed that you want to use for your subdevice.

If you have direct access to your gateway, then a simple way to create an subdevice is with a curl command. For example if you wish to create a subdevice of type skynet-hue:

curl -X POST http://192.168.1.110:8888/subdevices -H "Content-Type: application/json" -d '{"name":"living_Room_Lights", "type":"skynet-hue", "options":{"ipAddress": "192.168.1.115", "apiUsername": "newdeveloper"}}'

You can then message subdevices directly from skynet by sending a normal skynet message to the Octoblu gateway and specifing:

{
  devices: 'xxxxxx-uuid-of-a-skynet-hub-xxx',
  subdevice: 'living_Room_Lights',
  payload: { setState: {lightNumber: 1, on: true} }
}

gatewayConfig API

Gateblu has a websocket API called gatewayConfig that allows you to query, configure, install, and uninstall plugins and subdevices.

Once you are connected to Meshblu (formerly SkyNet.im), you can call gatewayConfig with the following methods:

  • configurationDetails - Returns an array of all plugins and subdevices installed on the gateway
  • getSubdevices - Returns an array of all subdevices installed on the gateway
  • createSubdevice - Creates a subdevice on the gateway
  • updateSubdevice - Updates a subdevice on the gateway
  • deleteSubdevice - Deletes a subdevice on the gateway
  • reloadSubdevice - Reloads all subdevices on the gateway
  • getPlugins - Returns an array of all plugins installed on the gateway
  • installPlugin - Installs a plugin on the gateway
  • updatePlugin - Updates a plugin on the gateway
  • uninstallPlugin - Uninstalls a plugin on the gateway
  • getDefaultOptions - Returns an array of default options for configuring your subdevice

Here are sample gatewayConfig websocket API calls:

conn.gatewayConfig({
  uuid:  'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX',
  token: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  method: 'configurationDetails'
}, function(results){ console.log(results); });

conn.gatewayConfig({
  uuid:  'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX',
  token: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  method: 'getSubdevices'
}, function(results){ console.log(results); });

conn.gatewayConfig({
  uuid:  'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX',
  token: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  method: 'createSubdevice',
  type: 'skynet-greeting',
  name: 'hellos',
  options: {"greetingPrefix": 'hello'}
}, function(results){ console.log(results); });

conn.gatewayConfig({
  uuid:  'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX',
  token: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  method: 'updateSubdevice',
  type: 'skynet-greeting',
  name: 'hellos',
  options: {"greetingPrefix": 'yes'}
}, function(results){ console.log(results); });

conn.gatewayConfig({
  uuid:  'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX',
  token: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  method: 'deleteSubdevice',
  type: 'skynet-greeting',
  name: 'hellos'
}, function(results){ console.log(results); });

conn.gatewayConfig({
  uuid:  'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX',
  token: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  method: 'reloadSubdevice'
  name: 'greeting'
}, function(results){ console.log(results); });

conn.gatewayConfig({
  uuid:  'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX',
  token: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  method: 'getPlugins'
}, function(results){ console.log(results); });

conn.gatewayConfig({
  uuid:  'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX',
  token: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  method: 'installPlugin',
  name: 'skynet-insteon'
}, function(results){ console.log(results); });

conn.gatewayConfig({
  uuid:  'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX',
  token: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  method: 'updatePlugin',
  name: 'skynet-insteon'
}, function(results){ console.log(results); });

conn.gatewayConfig({
  uuid:  'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX',
  token: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  method: 'uninstallPlugin',
  name: 'skynet-insteon'
}, function(results){ console.log(results); });

conn.gatewayConfig({
  uuid:  'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX',
  token: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  method: 'getDefaultOptions',
  name: 'skynet-hue'
}, function(results){ console.log(results); });

LICENSE

(MIT License)

Copyright (c) 2014 Octoblu [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.