diff --git a/accessories/fan.js b/accessories/fan.js index eccf587e..6d656cad 100644 --- a/accessories/fan.js +++ b/accessories/fan.js @@ -22,12 +22,21 @@ class FanAccessory extends SwitchAccessory { foundSpeeds.push(parts[1]) }) - if (foundSpeeds.length === 0) return log(`${name} setFanSpeed: No fan speed hex codes provided.`) + if (foundSpeeds.length === 0) { + + return log(`${name} setFanSpeed: No fan speed hex codes provided.`) + } // Find speed closest to the one requested const closest = foundSpeeds.reduce((prev, curr) => Math.abs(curr - state.fanSpeed) < Math.abs(prev - state.fanSpeed) ? curr : prev); log(`${name} setFanSpeed: (closest: ${closest})`); + if (this.lastFanSpeed === closest) { + return; + } + + this.lastFanSpeed = closest; + // Get the closest speed's hex data hexData = data[`fanSpeed${closest}`]; diff --git a/package.json b/package.json index 3929ccbc..433bfb42 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-broadlink-rm", - "version": "3.0.2", + "version": "3.0.3", "description": "Broadlink RM plugin (including the mini and pro) for homebridge: https://github.com/nfarina/homebridge", "license": "ISC", "keywords": [