kate-hall / alexa-icomfort

Alexa Smart Home Skill for Lennox iComfort Thermostat
MIT License
22 stars 7 forks source link

Rounding error? #18

Closed ut666 closed 6 years ago

ut666 commented 7 years ago

There seems to be a precision/rounding error. I successfully installed this and queried the current temperature downstairs, the alexa spoken reply I got was: 24.44444444444444443 instead of 24.5.

My 2yr old found it hilarious though :) And great work btw!

yungwesl commented 6 years ago

I edited the ftoc and ctof functions to include a rounding function that rounds to the nearest 0.5C

I also removed the Math.round wrapped around each ftoc and ctof and this seems to fix the issue.

// function to convert Celcius (Alexa default) to Farenheit function cToF(celsius) { return Math.round((celsius 9 / 5 + 32)2)/2; }

// function to convert Farenheit to Celcius (Alexa default) function fToC(fahrenheit) { return Math.round(((fahrenheit - 32) 5 / 9)2)/2;

//return (fahrenheit - 32) * 5 / 9; }

kate-hall commented 6 years ago

Thank you @yungwesl! Your edits will be included in the latest release.