No longer storing or relying on object instance names as that proved to be unnecessary and can potentially cause unpredictable behavior in certain edge cases.
This commit is contained in:
1 parent
22b11d6103
commit
ff68553bd7
3 files changed
+3
-24
No files matched your search
+3
-19
@@ -155,15 +155,7 @@ exports.getDevicePreset = (deviceId, presets, objects, aliases, callback) ->
|
|||||||
devicePreset.objects[c.name][c.object].current ?= {}
|
devicePreset.objects[c.name][c.object].current ?= {}
|
||||||
for k,p of param
|
for k,p of param
|
||||||
continue if k[0] == '_'
|
continue if k[0] == '_'
|
||||||
if p._name?
|
if matchObject(objects[c.object], p)
|
||||||
if p._name == c.object
|
|
||||||
devicePreset.objects[c.name][c.object].current[k] = p
|
|
||||||
else if matchObject(objects[c.object], p)
|
|
||||||
u = {}
|
|
||||||
u["#{c.name}.#{k}._name"] = c.object
|
|
||||||
db.devicesCollection.update({'_id' : deviceId}, {'$set' : u}, {}, (err, count) ->
|
|
||||||
throw err if err
|
|
||||||
)
|
|
||||||
devicePreset.objects[c.name][c.object].current[k] = p
|
devicePreset.objects[c.name][c.object].current[k] = p
|
||||||
|
|
||||||
when 'delete_object'
|
when 'delete_object'
|
||||||
@@ -174,15 +166,7 @@ exports.getDevicePreset = (deviceId, presets, objects, aliases, callback) ->
|
|||||||
devicePreset.objects[c.name][c.object].current ?= {}
|
devicePreset.objects[c.name][c.object].current ?= {}
|
||||||
for k,p of param
|
for k,p of param
|
||||||
continue if k[0] == '_'
|
continue if k[0] == '_'
|
||||||
if p._name?
|
if matchObject(objects[c.object], p)
|
||||||
if p._name == c.object
|
|
||||||
devicePreset.objects[c.name][c.object].current[k] = p
|
|
||||||
else if matchObject(objects[c.object], p)
|
|
||||||
u = {}
|
|
||||||
u["#{c.name}.#{k}._name"] = c.object
|
|
||||||
db.devicesCollection.update({'_id' : deviceId}, {'$set' : u}, {}, (err, count) ->
|
|
||||||
throw err if err
|
|
||||||
)
|
|
||||||
devicePreset.objects[c.name][c.object].current[k] = p
|
devicePreset.objects[c.name][c.object].current[k] = p
|
||||||
|
|
||||||
when 'custom_command_value'
|
when 'custom_command_value'
|
||||||
@@ -273,7 +257,7 @@ exports.processDevicePreset = (deviceId, devicePreset, callback) ->
|
|||||||
vals = []
|
vals = []
|
||||||
for k,v of flatObject
|
for k,v of flatObject
|
||||||
vals.push([k, v]) if k[0] != '_'
|
vals.push([k, v]) if k[0] != '_'
|
||||||
taskList.push({device : deviceId, name : 'addObject', objectName : parameterPath, parameterValues : vals, instanceName : objectName})
|
taskList.push({device : deviceId, name : 'addObject', objectName : parameterPath, parameterValues : vals})
|
||||||
else if Object.keys(objectDetails.current).length > 0
|
else if Object.keys(objectDetails.current).length > 0
|
||||||
for i, obj of objectDetails.current
|
for i, obj of objectDetails.current
|
||||||
taskList.push({device : deviceId, name : 'deleteObject', objectName : "#{parameterPath}.#{i}"})
|
taskList.push({device : deviceId, name : 'deleteObject', objectName : "#{parameterPath}.#{i}"})
|
||||||
|
|||||||
@@ -221,7 +221,6 @@ this.addObject = (task, methodResponse, callback) ->
|
|||||||
task.session.subtask = {device : task.device, name : 'getParameterNames', parameterPath : "#{task.objectName}.#{task.session.instanceNumber}.", nextLevel : false}
|
task.session.subtask = {device : task.device, name : 'getParameterNames', parameterPath : "#{task.objectName}.#{task.session.instanceNumber}.", nextLevel : false}
|
||||||
task.session.appliedParameterValues = []
|
task.session.appliedParameterValues = []
|
||||||
task.session.parameterNames = []
|
task.session.parameterNames = []
|
||||||
allDeviceUpdates.instanceName = [["#{task.objectName}.#{task.session.instanceNumber}", task.instanceName]] if task.instanceName?
|
|
||||||
else
|
else
|
||||||
callback(null, STATUS_OK, {type : 'AddObject', objectName : "#{task.objectName}."})
|
callback(null, STATUS_OK, {type : 'AddObject', objectName : "#{task.objectName}."})
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -75,10 +75,6 @@ commitUpdates = (deviceId, deviceUpdates, commitQueue, callback) ->
|
|||||||
for p in updatesBatch.deletedObjects
|
for p in updatesBatch.deletedObjects
|
||||||
update['$unset'][p] = 1
|
update['$unset'][p] = 1
|
||||||
|
|
||||||
if updatesBatch.instanceName?
|
|
||||||
for i in updatesBatch.instanceName
|
|
||||||
update['$set']["#{i[0]}._name"] = i[1]
|
|
||||||
|
|
||||||
if updatesBatch.parameterNames?
|
if updatesBatch.parameterNames?
|
||||||
presentPaths ?= {}
|
presentPaths ?= {}
|
||||||
projection ?= {}
|
projection ?= {}
|
||||||
|
|||||||
Reference in new issue
Block a user