Skip to content

Commit

Permalink
Missing fan speeds error
Browse files Browse the repository at this point in the history
  • Loading branch information
lprhodes committed May 21, 2017
1 parent f847905 commit 7ea58c3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions accessories/fan.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class FanAccessory extends BroadlinkRMAccessory {
foundSpeeds.push(parts[1])
})

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})`);
Expand Down

0 comments on commit 7ea58c3

Please sign in to comment.