   configurations = {}
   for p in presets
     for c in p.configurations
-      configurationHash = if c.name? then "#{c.type}_#{c.name}" else c.type
+      configurationHash = switch c.type
+        when 'add_tag', 'delete_tag'
+          "tag_#{c.tag}"
+        when 'add_object', 'delete_object'
+          "object_#{c.object}_#{c.object}"
+        when 'firmware'
+          'firmware'
+        else
+          "#{c.type}_#{c.name}"
 
       if not maxWeights[configurationHash]? or p.weight > maxWeights[configurationHash]
         configurations[configurationHash] = c

      expiry = config.PRESETS_CACHE_DURATION
      getParameterValues = []
      setParameterValues = []
      for c in configurations
        param = common.getParamValueFromPath(device, c.name)
        continue if not param? # ignore parameters that don't exist

        switch c.type
          when 'value'
            dst = common.matchType(param._value, c.value)
            if param._value != dst
              setParameterValues.push([c.name, dst, param._type])
          when 'age'
            timeDiff = (now - param._timestamp) / 1000
            if (c.age - timeDiff < config.PRESETS_TIME_PADDING)
              expiry = Math.min(expiry, c.age)
              getParameterValues.push(c.name)
            else
              expiry = Math.min(expiry, c.age - timeDiff)
          else
            throw new Error('Unknown configuration type')

      if getParameterValues.length
        taskList.push {device : deviceId, name : 'getParameterValues', parameterNames: getParameterValues, timestamp : new Date()}
      if setParameterValues.length
        taskList.push {device : deviceId, name : 'setParameterValues', parameterValues: setParameterValues, timestamp : new Date()}


db = require './db'
mongoQuery = require './mongo-query'
query = require './query'
log = require('util').log


getPresets = (callback) ->
