Zetta Device

31 views
Skip to first unread message

kedia.y...@gmail.com

unread,
Jun 20, 2017, 6:57:02 AM6/20/17
to zetta-discuss

Device1

Device1.prototype.init =  function(config) {
config
.type('device')
.state('START')
.name('my-device1'); 
config
.when('START', { allow: ['start']})
.when('END', { allow: ['end']})
.map('start', this.start)
.map('end', this.end); 
};

Device1.prototype.start = function(cb){
***********************************************
        this.state = 'END';
        cb();
};

Device1.prototype.end = function(cb){
this.state = 'START';
        cb();
};
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Device2

Device2.prototype.init =  function(config) {
config
.type('device')
.state('OFF')
.name('my-device2'); 
config
.when('OFF', { allow: ['turn-on']})
.when('ON', { allow: ['turn-off']})
.map('turn-on', this.turnOn)
.map('turn-off', this.turnOff); 
};

Device2.prototype.turnOn = function(cb){
this.state = 'ON';
        cb();
};

Device2.prototype.turnOff = function(cb){
this.state = 'OFF';
        cb();
};

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Is it possible to call Device2 transaction turnOn from the ************************ marked place in Device1?


kedia.y...@gmail.com

unread,
Jun 20, 2017, 8:05:52 AM6/20/17
to zetta-discuss
In other words I want to communicate between devices without using apps.
Is it possible to do so?

Thank you

Scott Erholm

unread,
Jun 20, 2017, 9:08:21 AM6/20/17
to zetta-discuss
Sorry not to answer your question directly, but I am pondering the motivation for performing such an action.  The architecture of a device seems to be designed so that it is decoupled from other devices.  Then if some event on Device1 should need to propagate to an action on Device2, that connection is handled higher up, typically in an app.  That way, Device1 doesn't have to know about each and every other device and what transitions it should call.

An app can set up a server.observe([device1Query, device2Query], function (dev1, dev2) { ... } and within that function respond to events and initiate a device transition via call(dev2, [args])

Adam Magaluk

unread,
Jun 20, 2017, 9:51:23 AM6/20/17
to Scott Erholm, zetta-discuss
As Scott mentioned generally devices should not be dependent on others to function so there is no direct way of doing it within a device.

However one approach we've used in the past, to do things like grouping (group 5 lights together), is create a separate device with transitions that acts as the group. Then use a scout to find devices that you want to control and pass the device instances into "group" device you are creating so it has a reference to all devices. At that point you are free to call dev1.call("transition"), dev2.call("transition"), etc...

The difference between this approach and a zetta app is apps do not have state/transitions so they cannot be added to the zetta api.

On Tue, Jun 20, 2017 at 9:08 AM Scott Erholm <sc...@agilatech.com> wrote:
Sorry not to answer your question directly, but I am pondering the motivation for performing such an action.  The architecture of a device seems to be designed so that it is decoupled from other devices.  Then if some event on Device1 should need to propagate to an action on Device2, that connection is handled higher up, typically in an app.  That way, Device1 doesn't have to know about each and every other device and what transitions it should call.

An app can set up a server.observe([device1Query, device2Query], function (dev1, dev2) { ... } and within that function respond to events and initiate a device transition via call(dev2, [args])

--
You received this message because you are subscribed to the Google Groups "zetta-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zetta-discus...@googlegroups.com.
To post to this group, send email to zetta-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/zetta-discuss/900c0c62-dca9-43c5-ae8b-0a1e5008fc49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages