Home

Awesome

slock-js

the backend of the slock framework

Module-Configuration

Each Module will be created only if used within the config. The key is the filename without the ending:

 "modules" : {
	  "eth"   : { ... },  // -> will load the file modules/eth.js
	  "zwave" : { ... }   // -> will load the file modules/zwave.js
  }

For more details on the different Modules and their config, see the module-directory.

Module Creation

Each Module which is specified in the config will be created during startup. A Module will be loaded by searching within the modules-Directory and requiring this file. The module.export must be class which will be used to create the instance.

function Eth() {}
module.exports = Eth;

Events

Each Module can define any kind of event in order tocommunicate with eachother, but these are the ones created from the main-modules:

Events from the core-Module

"init"-Event

After creating all Instances the Init-Method (if existing) will be called. This is a special behavior, because it will give you an easier start-point. The object passed as argument will give you the following properties:

the init-Method may be called more than once, if the Config-file has changed and was reloaded. In this there the oldConfig will set.

Events from the eth-Module

"watchContract"-Event

This Event will be triggered if the eth-Module starts watching for the open/close-Event from the contract. This event will be triggered for each contract.

The object passed as argument will give you the following properties:

"changeState"-Event

This Event will be triggered if a contract tells the device, that it needs to change its state.

The object passed as argument will give you the following properties:

Events from the websocket-Module

"message" - Event

Whenever a Message is received for one of the contract being watched. This event will be triggered.

The Object passed as argument will give you the following properties:

Events from the admin-Module

"adminMsg" - Event

sending a adminMsg-Event will cause the receiver to deliver the message to the admin.

The Object passed as argument will give you the following properties:

"adminCmd" - Event

sending a adminCmd-Event will cause the admin-Module (if loaded) to execute this cmd.

The Object passed as argument will give you the following properties:

"adminAddCmd" - Event

sending a adminCmd-Event will cause the admin-Module (if loaded) to add another command

The Object passed as argument will give you the following properties: