{"_id":"59d8127f47ed910010adab30","project":"568bdc1483d2061900d86cdc","version":{"_id":"59a72290d61777001b6c42c3","project":"568bdc1483d2061900d86cdc","__v":19,"createdAt":"2017-08-30T20:39:44.453Z","releaseDate":"2017-08-30T20:39:44.453Z","categories":["59a7236e3fe4d90025117c10","59a72eb6cb0db3001b84cfe2","59a734eb757d030019b85af8","59c0243b1b2d07001a9d2b76","59c035e42126e10028effb12","59c06c40df5b3c0010584a13","59c1a5852cabe5002641a3e7","59c2fb00b2b45c0010b7a3d7","59c32ceb9aea850010ac4130","59c32e6e190c90003cb0d12f","59c33affb2b45c0010b7aa23","59c7dfa457bd8200105444dc","59c7e975c50cf30010d712a0","59cffdef0cd4dd0010294d54","59d0622ca91a810032c8f60c","59d06733c1aec60026253065","59d174d44ac471001a07b123","59d5a5e323e6e800103defb2","59ecf1d8ed507c001c52b255"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"0.0.0","version":"0"},"category":{"_id":"59d0622ca91a810032c8f60c","project":"568bdc1483d2061900d86cdc","version":"59a72290d61777001b6c42c3","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2017-10-01T03:34:04.474Z","from_sync":false,"order":4,"slug":"edge-server-plugins","title":"Edge Server"},"user":"58cc41f21751ce2f003be3b7","__v":0,"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-10-06T23:32:15.185Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"# Overview\n\nThe Droplit Edge server connects the Droplit cloud with a device hub, and then with devices themselves. The hub is typically an embedded device, and is the software the creates a connection to the Droplit cloud to control devices on the local network.\n\nBefore installing the Edge server, NodeJS must be downloaded and properly configured. See the “Getting Started” for instructions on how to set up NodeJS on the operating system, if it hasn't been done already.\n\n# Download the Droplit Edge Server\n\nThe Droplit Edge server should be cloned directly from its Git repository.\n\n`git clone https://github.com/droplit/droplit.io-edge --depth 1`\n\nMove to the project root folder.\n\n`cd ~/droplit.io-edge`\n\nInstall the Edge server and its dependencies with the following two commands.\n\n```\nnpm install\ngulp setup\n```\n\nDepending on system configuration, setup may need to be run as a super user, so run the following command for gulp instead.\n\n```\nsudo gulp setup\n```\n\nIf an error occurs, this may mean that gulp was installed in the wrong place, or has not been installed at all.\n\nEnsure that the NPM root is set in the global NPM folder (/usr/local/node_modules) by running the following command, and setting the new location if necessary.\n\n```\nnpm root\nnpm config set prefix /usr/local\n```\n\nReinstall gulp and check its location. The second command should confirm that gulp is installed in the correct folder.\n```\nsudo npm install -g gulp\nnpm root -g\n```\n\n# Local Configuration\n\nThe Droplit Edge server has a master settings file that ensures all plugins supplied with the Droplit system are enabled by default. This file can be changed to disable existing plugins or add new ones, as the user wishes. Make a copy of the local settings file and rename it. This renamed file should be the one changed for plugins, not the master.\n\n```\ncd ~/droplit.io-edge/projects/droplit-edge\ncp localsettings.master.json localsettings.json\n```\n\nThe new localsettings.json file should have the following structure. See the “Local Settings” page for more details on this structure.\n\n```\n{\n    \"transport\": {\n        \"host\": \"wss://edge-ws.droplit.io/edge\"\n    },\n    \"ecosystemId\": \"INSERT_YOUR_ECOSYSTEMID_HERE\",\n    \"plugins\": {\n        \"droplit-plugin-philips-hue\": {\n            \"enabled\": true\n        },\n        \"droplit-plugin-lifx\": {},\n        \"droplit-plugin-sonos\": {},\n        \"droplit-plugin-wemo\": {}\n    }\n}\n```\n\nTo find the relevant ecosystem ID value, go to the Droplit portal.\n\nThe following plugins are available by default:\n* droplit-plugin-lifx\n* droplit-plugin-philps-hue\n* droplit-plugin-sonos\n* droplit-plugin-wemo\n* droplit-plugin-voyager\n\nUse the following two commands to build the server (with linting) and continuously watch it for changes. If it is not necessary to watch the server for changes, omit the second command.\n\n```\ngulp build\ngulp watch\n```\n\n# Running the Edge Server\n\nOpen a terminal and navigate to the project root (`cd ~/droplit.io-edge`).\n\nTo see the debug logs of the edge running in the environment, use one of the following commands, depending on the environment.\nUnix/Linux: `export DEBUG=droplit:*`\nWindows: `set DEBUG=droplit:*`\n\nRun the Droplit Edge server by using the command: `node droplit-edge`.\n\nIf any of the aforementioned devices are on the local network, they will be auto discovered and accessible in the default environment.\n\n![droplit-edge-example](https://droplit.box.com/shared/static/x0mjv0byklkr4i28q8lsr90du90i4a2s.png)\n\nUse the service classes attributed to the devices to determine the functionality of each. The device states can be manipulated from the Droplit portal or from the command line.\n\nClick here to see a video of the Edge in action: https://youtu.be/JEfuwwzX050","excerpt":"","slug":"edge-setup","type":"basic","title":"Setting Up The Edge Server"}

Setting Up The Edge Server


# Overview The Droplit Edge server connects the Droplit cloud with a device hub, and then with devices themselves. The hub is typically an embedded device, and is the software the creates a connection to the Droplit cloud to control devices on the local network. Before installing the Edge server, NodeJS must be downloaded and properly configured. See the “Getting Started” for instructions on how to set up NodeJS on the operating system, if it hasn't been done already. # Download the Droplit Edge Server The Droplit Edge server should be cloned directly from its Git repository. `git clone https://github.com/droplit/droplit.io-edge --depth 1` Move to the project root folder. `cd ~/droplit.io-edge` Install the Edge server and its dependencies with the following two commands. ``` npm install gulp setup ``` Depending on system configuration, setup may need to be run as a super user, so run the following command for gulp instead. ``` sudo gulp setup ``` If an error occurs, this may mean that gulp was installed in the wrong place, or has not been installed at all. Ensure that the NPM root is set in the global NPM folder (/usr/local/node_modules) by running the following command, and setting the new location if necessary. ``` npm root npm config set prefix /usr/local ``` Reinstall gulp and check its location. The second command should confirm that gulp is installed in the correct folder. ``` sudo npm install -g gulp npm root -g ``` # Local Configuration The Droplit Edge server has a master settings file that ensures all plugins supplied with the Droplit system are enabled by default. This file can be changed to disable existing plugins or add new ones, as the user wishes. Make a copy of the local settings file and rename it. This renamed file should be the one changed for plugins, not the master. ``` cd ~/droplit.io-edge/projects/droplit-edge cp localsettings.master.json localsettings.json ``` The new localsettings.json file should have the following structure. See the “Local Settings” page for more details on this structure. ``` { "transport": { "host": "wss://edge-ws.droplit.io/edge" }, "ecosystemId": "INSERT_YOUR_ECOSYSTEMID_HERE", "plugins": { "droplit-plugin-philips-hue": { "enabled": true }, "droplit-plugin-lifx": {}, "droplit-plugin-sonos": {}, "droplit-plugin-wemo": {} } } ``` To find the relevant ecosystem ID value, go to the Droplit portal. The following plugins are available by default: * droplit-plugin-lifx * droplit-plugin-philps-hue * droplit-plugin-sonos * droplit-plugin-wemo * droplit-plugin-voyager Use the following two commands to build the server (with linting) and continuously watch it for changes. If it is not necessary to watch the server for changes, omit the second command. ``` gulp build gulp watch ``` # Running the Edge Server Open a terminal and navigate to the project root (`cd ~/droplit.io-edge`). To see the debug logs of the edge running in the environment, use one of the following commands, depending on the environment. Unix/Linux: `export DEBUG=droplit:*` Windows: `set DEBUG=droplit:*` Run the Droplit Edge server by using the command: `node droplit-edge`. If any of the aforementioned devices are on the local network, they will be auto discovered and accessible in the default environment. ![droplit-edge-example](https://droplit.box.com/shared/static/x0mjv0byklkr4i28q8lsr90du90i4a2s.png) Use the service classes attributed to the devices to determine the functionality of each. The device states can be manipulated from the Droplit portal or from the command line. Click here to see a video of the Edge in action: https://youtu.be/JEfuwwzX050