Added _timestamp for parameters
This commit is contained in:
1 parent
2ace65d2ea
commit
c2877e4ca2
1 file changed
+7
-5
+7
-5
@@ -32,9 +32,10 @@ updateDevice = (deviceId, actions, callback) ->
|
|||||||
callback() if callback?
|
callback() if callback?
|
||||||
return
|
return
|
||||||
|
|
||||||
|
now = new Date(Date.now())
|
||||||
updates = {}
|
updates = {}
|
||||||
if actions.inform
|
if actions.inform
|
||||||
updates['_last_inform'] = new Date(Date.now())
|
updates['_last_inform'] = now
|
||||||
|
|
||||||
if actions.parameterValues?
|
if actions.parameterValues?
|
||||||
for p in actions.parameterValues
|
for p in actions.parameterValues
|
||||||
@@ -45,14 +46,15 @@ updateDevice = (deviceId, actions, callback) ->
|
|||||||
else
|
else
|
||||||
updates["#{path}_value"] = v
|
updates["#{path}_value"] = v
|
||||||
updates["#{path}_orig"] = p[1]
|
updates["#{path}_orig"] = p[1]
|
||||||
|
updates["#{path}_timestamp"] = now
|
||||||
|
|
||||||
if actions.parameterNames?
|
if actions.parameterNames?
|
||||||
for p in actions.parameterNames
|
for p in actions.parameterNames
|
||||||
|
path = if common.endsWith(p[0], '.') then p[0] else "#{p[0]}."
|
||||||
if common.endsWith(p[0], '.')
|
if common.endsWith(p[0], '.')
|
||||||
updates["#{p[0]}_writable"] = p[1]
|
updates["#{path}_object"] = true
|
||||||
updates["#{p[0]}_object"] = true
|
updates["#{path}_writable"] = p[1]
|
||||||
else
|
updates["#{path}_timestamp"] = now
|
||||||
updates["#{p[0]}._writable"] = p[1]
|
|
||||||
|
|
||||||
if Object.keys(updates).length > 0
|
if Object.keys(updates).length > 0
|
||||||
devicesCollection.update({'_id' : deviceId}, {'$set' : updates}, {upsert: true, safe: true}, (err) ->
|
devicesCollection.update({'_id' : deviceId}, {'$set' : updates}, {upsert: true, safe: true}, (err) ->
|
||||||
|
|||||||
Reference in new issue
Block a user