potmat / homebridge-google-nest-sdm

A Homebridge plugin for Google Nest devices that uses the Google Smart Device Management API. Supports Cameras, Doorbells, Displays, and Thermostats. Includes support for HomeKit Secure Video.
ISC License
148 stars 17 forks source link

Fans are only created for the first thermostat that is found when the home has multiple thermostats #106

Closed ic04n closed 12 months ago

ic04n commented 12 months ago

If the home has multiple thermostats, then only the first thermostat has a fan accessory created.

I believe the issue is in src/Platform.ts.

This code:

const thermostatDevice = devices.find(device => device instanceof Thermostat);
 if (thermostatDevice && this.config.showFan) {
     const uuid = this.api.hap.uuid.generate(thermostatDevice + ' Fan');
     deviceInfos.push({
         device: thermostatDevice,
         uuid: uuid,
         category: this.api.hap.Categories.FAN,
         existingAccessory: this.accessories.find(accessory => accessory.UUID === uuid)
     })
 }

Should be:

devices.filter(device => device instanceof Thermostat).forEach(thermostatDevice => {
     if (this.config.showFan) {
         const uuid = this.api.hap.uuid.generate(thermostatDevice + ' Fan');
         deviceInfos.push({
             device: thermostatDevice,
             uuid: uuid,
             category: this.api.hap.Categories.FAN,
             existingAccessory: this.accessories.find(accessory => accessory.UUID === uuid)
         })
     }
 });
potmat commented 12 months ago

Thank you @ic04n! Nice PR, it's now merged and 1.1.17 is released.

ic04n commented 12 months ago

Thanks! Great plugin by the way, glad to contribute. I just sent another pull request actually, because there was an issue with unique uuid generation. I think the original code was not properly converting the thermostat name to a string when generating the uuid for the fan, but it never was an issue because there never was more than one fan.

potmat commented 12 months ago

Also merged and released.

potmat commented 12 months ago

Oops, screwed that up a bit (this is the first real PR I've gotten for this repo). v.1.1.19 should be good to go

ic04n commented 12 months ago

Nice! It looks like it's working now. Great teamwork :)