From cd67e50062a6f9381e7ac45324473701515a2fa0 Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Tue, 15 Jan 2013 16:34:18 +0300 Subject: [PATCH] In presets, ignore config parameters that don't exist in the device --- common.coffee | 9 ++++++--- presets.coffee | 7 ++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/common.coffee b/common.coffee index ea0a705..f07d33f 100644 --- a/common.coffee +++ b/common.coffee @@ -38,9 +38,12 @@ exports.extend = (obj, mixin) -> exports.getParamValueFromPath = (obj, path) -> pp = path.split('.') ref = obj - for p in pp - ref = ref[p] - return ref + try + for p in pp + ref = ref[p] + return ref + catch err + return undefined exports.matchType = (src, dst) -> diff --git a/presets.coffee b/presets.coffee index a8f3156..cf82d56 100644 --- a/presets.coffee +++ b/presets.coffee @@ -73,9 +73,10 @@ exports.assertPresets = (deviceId, presetsHash, callback) -> switch c.type when 'value' src = common.getParamValueFromPath(device, "#{c.name}._value") - dst = common.matchType(src, c.value) - if src != dst - setParameterValues.push([c.name, dst]) + if src isnt undefined # ignore parameters that don't exist + dst = common.matchType(src, c.value) + if src != dst + setParameterValues.push([c.name, dst]) when 'age' timeDiff = (now - common.getParamValueFromPath(device, "#{c.name}._timestamp")) / 1000 if (c.age - timeDiff < config.PRESETS_TIME_PADDING)