message: fix(discovery): prioritized CCs discovery order
diff: @@ -375,7 +375,8 @@ function onNodeStatus (node) {
  nodeDevices.forEach(device => this.discoverDevice(node, device))
  // discover node values (that are not part of a device)
  - for (const id in node.values) {
  + // iterate prioritized first, then the remaining
  + for (const id of getPriorityCCFirst(node.values)) {
  this.discoverValue(node, id)
  }
  }
  @@ -567,6 +568,27 @@ function getNodeName (node, ignoreLoc) {
  )
  }
  +/**
  + * Return re-arranged based on critical CCs
  + *
  + * @param {Map<string, import('../types').Z2MValueId>} node values map
  + * @returns {string[]} Array of values Ids sorteb by CC discovery priority
  + */
  +
  +function getPriorityCCFirst (values) {
  + const priorityCC = [CommandClasses['Color Switch']]
  + const prioritizedValueIds = []
  +
  + for (const id in values) {
  + if (priorityCC.includes(values[id].commandClass)) {
  + prioritizedValueIds.unshift(id)
  + } else {
  + prioritizedValueIds.push(id)
  + }
  + }
  + return prioritizedValueIds
  +}
  +
  /**
  * Deep copy of an object
  *
  @@ -1080,7 +1102,8 @@ Gateway.prototype.rediscoverNode = function (nodeID) {
  nodeDevices.forEach(device => this.discoverDevice(node, device))
  // discover node values (that are not part of a device)
  - for (const id in node.values) {
  + // iterate prioritized first, then the remaining
  + for (const id of getPriorityCCFirst(node.values)) {
  this.discoverValue(node, id)
  }
  