We suggest to wait till start of CeBIT before writing your own modules, since we might change some structure meanwhile.
UPD 30.04.2014: this description was updated to fit lates code on github.
What's new compared to old UIs?
No Z-Wave configuration at all
- All Z-Wave configs will remain in the Blue UI (we will fork it and clean a bit soon).
- Virtual devices (also called widgets).
Each virtual device represents Z-Wave device functionality and can have it's own name, position and number of tags.
Virtual device can be based on Z-Wave devices (created automatically) and on any custom JavaScript code.
- Automation scripts are provided as modules
Module provide functionality - Rule (instance of module) applies module functionality to your devices according to defined parameters. Module can be instanciated many times with different parameters.
Easy to combine together and extend, easy to copy to other users.
- User notifications are possible from modules.
System wide notifications. Modules can also trp them and deliver them to the user via other transports (SMS, E-mail).
- Global events are generated on each virtual device change.
Modules can emit and trap events.
Events are used for inter-modules communications.
- REST API for access via HTTP: http://docs.zwayhomeautomation.apiary.io
Server side API (see below and in the source code for more details)
- New Web UI
Native iOS APP
Android App soon
Code: Select all
rm -Rf automation
git clone https://github.com/Z-Wave-Me/home-automation.git automation
cd automation
git checkout develop
Register device:
Code: Select all
vDev = this.controller.devices.create(vDevId, {
deviceType: "deviceType",
metrics: {
level: "level",
icon: "icon from lib or url"
title: "Default title"
}
}, function (command, ...) {
// handles actions with the widget
});
- sensroBinary
sensorMultilevel
switchBinary
switchMultilevel
switchRGBW
switchControl
toggleButton
thermostat
battery
camera
fan
Unregister device:
Code: Select all
this.controller.devices.remove(vDevId);
Code: Select all
vdevId = vdev.id;
vDev = this.controller.devices.get(vdevId);
vDevList = this.controller.devices.filter(function(x) { return x.get("deviceType") === "switchBinary"; }); // filter by type
vDevTypes = this.controller.devices.map(function(x) { return x.get("deviceType"); }); // return types
Code: Select all
vDev.set("metrics:...", ...); // metric can be level, title, icon and some other device specific like scale
vDev.get("metrics:...");
Code: Select all
vDev.on('change:metrics:...", function (vDev) { ... });
Code: Select all
vDev.performCommand("....");
NB! API changed
Device creation/deletion changes. Calls listed below should be changed to new equivalent.
Code: Select all
this.controller.findVirtualDeviceById(vdevId); -----> this.controller.devices.get(vdevId);
vDev.getMetricValue("...."); -----> vDev.get("metrics:...");
vDev.setMetricValue("....", "..."); -----> vDev.set("metrics:...", ...);
controller.on('device.metricUpdated', function (vdevId, name, value) { .... }); -----> vDev.on('change:metrics:...", function (vDev) { ... });
Make sure to update your modules!
[/color]
Notifications
Code: Select all
controller.addNotification("....severity....", "....message....", "....origin...."); // severity is error, info, debug; origin describes which part of the system it is about: core, module, device, battery.
controller.on("notification.pushs.push", function({timestamp, severity, message, type}) {....}); // catch notification
Module folder name should be same as module name (JavaScript object, DemoModule in the example below).
index.js file should containt the code, any additional file can be executed using executeFile(). module.json contains module descrtiption and configuration UI builder.
Minimal module:
index.js:
Code: Select all
function DemoModule (id, controller) {
DemoModule.super_.call(this, id, controller);
....
}
inherits(DemoModule, AutomationModule);
_module = DemoModule;
DemoModule.prototype.init = function (config) {
DemoModule.super_.prototype.init.call(this, config);
....
};
DemoModule.prototype.stop = function () {
DemoModule.super_.prototype.stop.call(this);
....
};
module.json:
Code: Select all
{
"autoload": false, // allows to autoload singleton modules on start
"singleton": false, // if the module is allowed to be loaded only once
"userView": true, // should it be visible in the configurtor UI?
"defaults": {
"title": "Demo module", // default title
"description": "Long description of Demo module", // default long description
.... // some parameters
},
"schema": {
.... // some parameters, see other modules for more details // Alpaca is used for UI renderinf
},
"options": {
.... // some parameters, see other modules for more details
}
}
Module params can refer to glabal lists shared by different modules. This allows to use in module configuraion lists of devices, scenes, ... and other objects that depends on configuration of other modules.
Events
Bind to event:
Code: Select all
controller.on("....", function(....eventObject....) {});
Code: Select all
controller.off("....", function(....eventObject....) {});
More information will be added soon. See modules provided with the system to understatand modules system.