From 43fc722615125cb826cc354bd530649d1a6fcbe8 Mon Sep 17 00:00:00 2001 From: pathec Date: Wed, 12 Oct 2016 09:35:30 +0200 Subject: [PATCH] Fix default WebSocket notifications. --- classes/AutomationController.js | 35 +++++++-------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/classes/AutomationController.js b/classes/AutomationController.js index 3e7ddb44b..d073b8756 100644 --- a/classes/AutomationController.js +++ b/classes/AutomationController.js @@ -70,10 +70,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); } @@ -82,45 +79,30 @@ 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) { @@ -128,10 +110,7 @@ AutomationController.prototype.init = function () { }); 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)); }); }); };