node-red-contrib-homebridge-automation: Accessories with Duplicate Names - continuation of #30

Hi,

I’ve been trying to use the homebridge-automation plugin to access devices created by a second plugin - homebridge-kumo (Mitsubishi Kumo Cloud devices - i.e., Heating/Cooling devices). This is essentially the same problem reported by #30 .

image

As part of #30, support for Nest was added with the following changes in Service.js:

if (this.name) {
  // Fix for #30
  if (context.manufacturer === "Nest" && (this.name === "Fan" || this.name === "Eco Mode")) {
    fullName = context.name + " - " + this.name;
  } else {
    context.name = this.name;
    fullName = context.name;
  }
}

A simple workaround to fix this issue is as follows:

if (this.name) {
  // Fix for #30
  if (context.manufacturer === "Nest" && (this.name === "Fan" || this.name === "Eco Mode")) {
    fullName = context.name + " - " + this.name;
  } else if (context.manufacturer === "Mitsubishi" && !fullName.includes(this.name)) {
    fullName = context.name + " - " + this.name;
  } else {
    context.name = this.name;
    fullName = context.name;
  }
}

however I’m not sure I totally understand why the else clause is arranged the way it is. I would like to propose a “fix” as follows which attempts to preserve context.name if different from this.name and only do the final else clause as a final gasp. Perhaps I’m missing something though.

if (this.name) {
  // Fix for #30
  if (context.manufacturer === "Nest" && (this.name === "Fan" || this.name === "Eco Mode")) {
    fullName = context.name + " - " + this.name;
  } else if (context.name != null && context.name.trim() != "" && !context.name.includes(this.name)) {
    // Since we have two names, let them stand
    fullName = context.name;
  } else {
    context.name = this.name;
    fullName = context.name;
  }
}

In my testing this seems to result in the desired output: image

Thanks, -Jeff

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15 (9 by maintainers)

Most upvoted comments

Glad to hear you solved this