New Home Automation engine and New UI

Discussions about RaZberry - Z-Wave board for Raspberry computer
User avatar
PoltoS
Posts: 7562
Joined: 26 Jan 2011 19:36

New Home Automation engine and New UI

Post by PoltoS »

We would like to present here the new engine we are working on. It is a home automation engine and UI for it. Both are stored on github and are under GNU GPL. The project is still under development, but will soon enter mature state.

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
  • 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.
Modules and Rules
  • 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.
Notifications
  • 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).
Events
  • Global events are generated on each virtual device change.
    Modules can emit and trap events.
    Events are used for inter-modules communications.
New API Available UI
  • New Web UI
    Native iOS APP
    Android App soon
Get latest updates

Code: Select all

rm -Rf automation
git clone https://github.com/Z-Wave-Me/home-automation.git automation
cd automation
git checkout develop
How to create your own virtual devices

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
        });  
Device type can be any, but the UI currently handles only:
  • sensroBinary
    sensorMultilevel
    switchBinary
    switchMultilevel
    switchRGBW
    switchControl
    toggleButton
    thermostat
    battery
    camera
    fan
Each type requires it's own list of metrics and handles them specifically.

Unregister device:

Code: Select all

    this.controller.devices.remove(vDevId);
Find by Id, filter and map:

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
Get/Set metrics:

Code: Select all

    vDev.set("metrics:...", ...); // metric can be level, title, icon and some other device specific like scale
    vDev.get("metrics:...");
Catch device updates:

Code: Select all

    vDev.on('change:metrics:...", function (vDev) { ... });
Execute command on virtual device:

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) { ... });
[/size]
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
Modules
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 should use stop method to release all resources aquired in init function.

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
    }
}
Glabal namespace
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....) {});
Unbind from event:

Code: Select all

    controller.off("....", function(....eventObject....) {});
What's next?

More information will be added soon. See modules provided with the system to understatand modules system.
Last edited by PoltoS on 06 May 2014 22:38, edited 6 times in total.
etrust
Posts: 27
Joined: 24 Feb 2014 20:27

Re: New Home Automation engine and New UI

Post by etrust »

Hi,

wow clients are waiting for actions and notifications. When are you "planing" to release it?
vwirus
Posts: 12
Joined: 25 Feb 2014 00:12

Re: New Home Automation engine and New UI

Post by vwirus »

It looks very promissing. That's what we were waiting for however... it looks like it's not working. UI won't allow to use this module. There is nothing I can do beside creating new rooms there. I'm using lastes firmware (1.5). Is it final there?
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: New Home Automation engine and New UI

Post by pz1 »

If I understood correctly (viewtopic.php?f=3422&t=20271#p49883) it is NOT the final version
Since 29-12-2016 I am no longer a moderator for this forum
User avatar
PoltoS
Posts: 7562
Joined: 26 Jan 2011 19:36

Re: New Home Automation engine and New UI

Post by PoltoS »

It is not final, we will release this next week during CeBIT exhibition. This will be first stable code with automation.

But still we will ontinue to improve it more and more.
vwirus
Posts: 12
Joined: 25 Feb 2014 00:12

Re: New Home Automation engine and New UI

Post by vwirus »

I found very interesting restfull API
http://docs.zwayhomeautomation.apiary.io/#devices
would it be also any update for that? It looks like it not have full functionality? am I right?
peec2
Posts: 4
Joined: 09 Mar 2014 14:40

Re: New Home Automation engine and New UI

Post by peec2 »

I really like the new UI. Good job. I have been following the development on GitHub, i'm a JS developer myself with, so i'm familiar with some of the stack you are using such as Backbone etc.. Great project.

I'm going to play around with the API etc. now, forked the repo just now https://github.com/peec/home-automation/tree/develop .Going to create a new feature branch to try to create a module that can connect to a web stream to see the camera as a "Widget" :)
peec2
Posts: 4
Joined: 09 Mar 2014 14:40

Re: New Home Automation engine and New UI

Post by peec2 »

I have one question regarding modules / widgets.

So this is my idea: I have a video stream service running with RTMP and Nginx. I want to have a widget that just has a div tag in it that i can use jwplayer to initialize the stream in that specific div tag. Check the screenshot attachment.

Standalone i could forexample create a simple html page:

Code: Select all

<!doctype html>
<html>
 
<head>
        <script type="text/javascript" src="/jwplayer/jwplayer.js"></script>
 
</head>
<body>
 
<div id="myElement">Loading the player...</div>
 
<script type="text/javascript">
    jwplayer("myElement").setup({
        file: "rtmp://myvps.com/myapp/live",
 
    });
</script>
 
</body>
 
</html>

However i see that you have two main divs in the app:

Code: Select all

<div class="main-container">
    <div id="main-region" class="main wrapper clearfix">
        <section id="devices-container" class="widgets"></section><!-- .devices-container -->
        <section id="widgets-container" class="widgets"></section><!-- .widgets -->
    </div> <!-- #main -->
</div> <!-- #main-container -->
I see that the devices are listed in the devices-container using the "WidgetsView" backbone view. Buy i see nothing is connected to the widgets-container. I belive this might be upcomming functionality to have custom widget templates?
Attachments
Custom widgget (&quot;non device&quot;)
Custom widgget ("non device")
z-wave-me-custom-widget.png (485.2 KiB) Viewed 38901 times
User avatar
PoltoS
Posts: 7562
Joined: 26 Jan 2011 19:36

Re: New Home Automation engine and New UI

Post by PoltoS »

In fact this is a legacy stuff. Should be cleaned.

Now widgets and devices are same = virtual device.

As for your wish, this is to be in Applications tab in future - not implemented yet. The difference between widget (virt device) and application is that the former is typed and has a unified form for all platforms, while applications will be platform dependant. Means, you can not use your aproach on all platforms (in fact you can, but via broswer embedding).

I think we can easily and fastly add a widget for video streaming and add PTZ buttons for it. We are still thinking on the best design for this.
etrust
Posts: 27
Joined: 24 Feb 2014 20:27

Re: New Home Automation engine and New UI

Post by etrust »

Hi PoltoS,

we have two questions:

1) When is the official release date for that exaclty? We want to wait for the official release to test.

2) Which version is this exactly?
Post Reply