In presets, ignore config parameters that don't exist in the device
This commit is contained in:
1 parent
77d1c86b86
commit
cd67e50062
2 files changed
+10
-6
No files matched your search
+6
-3
@@ -38,9 +38,12 @@ exports.extend = (obj, mixin) ->
|
|||||||
exports.getParamValueFromPath = (obj, path) ->
|
exports.getParamValueFromPath = (obj, path) ->
|
||||||
pp = path.split('.')
|
pp = path.split('.')
|
||||||
ref = obj
|
ref = obj
|
||||||
for p in pp
|
try
|
||||||
ref = ref[p]
|
for p in pp
|
||||||
return ref
|
ref = ref[p]
|
||||||
|
return ref
|
||||||
|
catch err
|
||||||
|
return undefined
|
||||||
|
|
||||||
|
|
||||||
exports.matchType = (src, dst) ->
|
exports.matchType = (src, dst) ->
|
||||||
|
|||||||
+4
-3
@@ -73,9 +73,10 @@ exports.assertPresets = (deviceId, presetsHash, callback) ->
|
|||||||
switch c.type
|
switch c.type
|
||||||
when 'value'
|
when 'value'
|
||||||
src = common.getParamValueFromPath(device, "#{c.name}._value")
|
src = common.getParamValueFromPath(device, "#{c.name}._value")
|
||||||
dst = common.matchType(src, c.value)
|
if src isnt undefined # ignore parameters that don't exist
|
||||||
if src != dst
|
dst = common.matchType(src, c.value)
|
||||||
setParameterValues.push([c.name, dst])
|
if src != dst
|
||||||
|
setParameterValues.push([c.name, dst])
|
||||||
when 'age'
|
when 'age'
|
||||||
timeDiff = (now - common.getParamValueFromPath(device, "#{c.name}._timestamp")) / 1000
|
timeDiff = (now - common.getParamValueFromPath(device, "#{c.name}._timestamp")) / 1000
|
||||||
if (c.age - timeDiff < config.PRESETS_TIME_PADDING)
|
if (c.age - timeDiff < config.PRESETS_TIME_PADDING)
|
||||||
|
|||||||
Reference in new issue
Block a user