Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ronie-z-wave committed Oct 24, 2016
2 parents aa74186 + 4c87201 commit 1f3d488
Showing 1 changed file with 7 additions and 28 deletions.
35 changes: 7 additions & 28 deletions classes/AutomationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ AutomationController.prototype.init = function () {

function pushNamespaces(device, locationNspcOnly) {
self.generateNamespaces(function (namespaces) {
ws.push({
type: 'me.z-wave.namespaces.update',
data: JSON.stringify(namespaces)
});
ws.push('me.z-wave.namespaces.update', JSON.stringify(namespaces));
}, device, locationNspcOnly);
}

Expand All @@ -92,56 +89,38 @@ AutomationController.prototype.init = function () {

// update namespaces if device title has changed
self.devices.on('change:metrics:title', function (device) {
ws.push({
type: "me.z-wave.devices.title_update",
data: JSON.stringify(device.toJSON())
});
ws.push("me.z-wave.devices.title_update", JSON.stringify(device.toJSON()));
pushNamespaces(device, false);
});

// update only location namespaces if device location has changed
self.devices.on('change:location', function (device) {
ws.push({
type: "me.z-wave.devices.location_update",
data: JSON.stringify(device.toJSON())
});
ws.push("me.z-wave.devices.location_update", JSON.stringify(device.toJSON()));
pushNamespaces(device, true);
});

// update namespaces if device permanently_hidden status has changed
self.devices.on('change:permanently_hidden', function (device) {
ws.push({
type: "me.z-wave.devices.visibility_update",
data: JSON.stringify(device.toJSON())
});
ws.push("me.z-wave.devices.visibility_update", JSON.stringify(device.toJSON()));
pushNamespaces(device, false);
});

// update namespaces if structure of devices collection changed
self.devices.on('created', function (device) {
ws.push({
type: "me.z-wave.devices.add",
data: JSON.stringify(device.toJSON())
});
ws.push("me.z-wave.devices.add", JSON.stringify(device.toJSON()));
pushNamespaces(device);
});

self.devices.on('destroy', function (device) {
ws.push({
type: "me.z-wave.devices.destroy",
data: JSON.stringify(device.toJSON())
});
ws.push("me.z-wave.devices.destroy", JSON.stringify(device.toJSON()));
});

self.devices.on('removed', function (device) {
pushNamespaces(device);
});

self.on("notifications.push", function (notice) {
ws.push({
type: "me.z-wave.notifications.add",
data: JSON.stringify(notice)
});
ws.push("me.z-wave.notifications.add", JSON.stringify(notice));
});
});
};
Expand Down

0 comments on commit 1f3d488

Please sign in to comment.