thing-it Node Server
[thing-it-node] is a scalable Operating System for Things and allows you to
All of the above is controlled by a nodejs server which is bootstrapped from a simple JSON Configuration File, which allows you to e.g. configure a complex Device control in minutes.
More details can be found on the thing-it-node Wiki.
You can use www.thing-it.com to create and simulate your setup for [thing-it-node] and then just push the configuration file or connect your Device Gateways safely to the Internet.
[thing-it-node] is available under the MIT License and the Eclipse Public License.
Let's set up a simple Smart Home scenario leveraging the easy-to-configure Z-Wave standard with
In our scenario we will
Not interested in Smart Home Experiments with Z-Wave?
If you are not interested in tinkering with Z-Wave Devices and just intend to e.g. control your
then maybe stop reading. Check what we have on github/npm under
Or check the thing-it.com Mesh Market.
But wait! May be you want to switch on your Sonos if the Z-Wave Sensor detected motion, switch on your vents for you Aquaponics greenhouse if the ambient temperature is above a certain threshold. Or the fish pond's water temperature. Or you want to have your drone flying over the fish pond while your Sonos is playing "Girl from Ipanema", but only if the Foscam camera detects an intruder?
OK, keep reading ...
As Z-Wave communication is a standard component of [thing-it-node], you need to install Open Z-Wave on your Device Gateway Computer.
For all Raspberry Pi/C.H.I.P/BeagleBone - and yes, OSX - users:
You will need to ensure the OpenZWave library and headers are installed first. You can do this one of two ways:
Since there is no standard installation location for Open Z-Wave on Windows, it will be automatically downloaded, compiled, and installed when you install openzwave-shared via npm (which we will be installing with [thing-it-node]).
To install, configure and run [thing-it-node], first install nodejs on your computer (e.g. your PC, your Raspberry Pi Zero or your C.H.I.P.).
Then install [thing-it-node] via
npm -g install thing-it-node which will install [thing-it-node] in your global /node_modules directory and makes it available via the command line program tin.
Note, that depending on the access right settings on your file system you may need to invoke
sudo npm -g install thing-it-node instead.
Now create an arbitrary Installation Directory installDir and make it your current working directory, e.g.
mkdir ~/thing-it-testcd ~/thing-it-testThen invoke
tin example -f z-wavewhich will create a directory installDir/configurations and copy the sample [thing-it-node] Node Configuration z-wave-empty.js into it from which [thing-it-node] can be booted.
If you are interested, have a look at this Node Configuration File - the content should be self-explanatory.
The important part is
autoDiscoveryDeviceTypes: plugin: "z-wave/zWaveNetwork" confirmRegistration: false persistRegistration: true defaultConfiguration: {} options: {} which tells [thing-it-node] to auto-discover Z-Wave networks and add them (and their devices) to the Configuration permanently and without user confirmation.
You need to purchase a Z-Wave controller, e.g. an Aeotec Z-Stick.
Also purchase a few Z-Wave devices, e.g.
Pair these devices with you Z-Wave Controller in the above order by following the documentation which comes with the Controller. It usually involves just clicking the pairing button close to the Device.
Start the thing-it-node server with
tin runThe output should look like
Running [thing-it-node] from Default Options.
---------------------------------------------------------------------------
Protocol : http
Port : 3001
Node Configurations Directory: /Users/marcgille/git/thing-it-node/configurations
Simulated : false
Log Level : debug
-----------------------------------------------------------------------------
12/1/2015 6:32:01 AM INFO NodeManager ===> Scanning directory [/Users/marcgille/git/thing-it-node/lib/../node_modules] for Device Plugins: Actor [LED1] started.
...
12/1/2015 6:32:01 AM INFO Node[The Node] Event Processors started.
12/1/2015 6:32:01 AM INFO Node[The Node] Jobs activated.
12/1/2015 6:32:01 AM INFO Node[The Node] Node [The Node] started.
If you check the content of your configuration file after you saw the Device discovery in the output, you will see that it contains Device and Actor definitions for the discovered components.
...devices: label: "Z-Wave Network" id: "zWaveNetwork" plugin: "z-wave/zWaveNetwork" configuration: {} actors: id: "multilevelSensor1" label: "Multilevel Sensor 1" type: "multilevelSensor" configuration: nodeId: 2 id: "binaryPowerSwitch1" label: "Binary Power Switch 1" type: "binaryPowerSwitch" configuration: nodeId: 3 id: "binaryPowerSwitch2" label: "Binary Power Switch 2" type: "binaryPowerSwitch" configuration: nodeId: 4 sensors: ...Extend the services section in the Configuration with something like
...services: id: "toggleAll" label: "Toggle All" type: "script" content: script: "if ([node].zWaveNetwork.lightBulb.state.light == 'on') {[node].zWaveNetwork.lightBulb.off(); [node].zWaveNetwork.switch.off();} else {[node].zWaveNetwork.lightBulb.on(); [node].zWaveNetwork.switch.on();}" id: "lightsOff" label: "Lights Off" type: "script" content: script: "[node].zWaveNetwork.lightBulb.off(); [node].zWaveNetwork.switch.off();" ...Stop tin via Ctrl-C and restart. You can now invoke both services via REST against your [thing-it-node] Device Gateway computer. Test e.g. with
curl -X POST http://localhost:3001/services/toggleAllor
curl -X POST http://localhost:3001/services/lightsOffExtend the eventProcessors section with something like
...eventProcessors: id: "eventProcessor1" label: "Event Processor 1" observables: "zWaveNetwork.multiSensor" trigger: type: "timeInterval" content: interval: 10000 conditions: observable: "zWaveNetwork.multiSensor" cumulation: "maximum" stateVariable: "luminousIntensity" compareOperator: "<" compareValue: 600 action: type: "nodeService" "content": "service": "toggleAll" ...to the configuration.js file and restart tin again.
Now, covering the light sensor for a few seconds should switch on your light bulb and your switch.
Connect your browser to
http://localhost:3001/mobile/index.html
Instead of the browser-based UI - mobile or on your computer - you can use the [thing-it] Mobile App from Apple Appstore or Google Play.
Let us recap what we did:
With
but no programming we were able to access a not too trivial Actor/Sensor setup.
However, in real live you would usually not directly edit the Configuration File. You would either modify the configuration with the Mobile App or use thing-it.com as described below.
The Simple Lighting solution presented here is available as a Mesh under
http://www.thing-it.com/thing-it/index.html?offer=54d417205a538cc81b0d31c9#/meshOfferPanel
You can find other Meshes in the [thing-it] Mesh Market for free simulation and download.
To create your own solutions on www.thing-it.com you would define Nodes and Devices
put Actors, Sensors, Services and Event Processors together,
edit the logic of Event Processors
and Services and then simulate and test the configuration before you download it to your [thing-it-node] deployment.
Consider the [thing-it] Documentation to configure the scenario described above.