I selected the OpenWeather module and entered my desired info and selected Fahrenheit as the display type. I noticed that the temperarure was off by a few degrees. I looked into the index.js file itself and found it odd on how the calculation was being performed. The line below is from the original index.js file
Code: Select all
var temp = Math.round((self.config.units === "celsius" ? res.data.main.temp - 273.15 : res.data.main.temp) * 10) / 10,
Now, OpenWeather.org provides the temperature in measurement of Kelvin, the formula to convert Kelvin to Celsius is straight forward. K - 273.15. And as you see in the above line of code; if Celsius is selected it performs that math correctly. But the Fahrenheit formula being used here is (K * 10) / 10 when the actual formula is (K * 9) / 5 - 459.67 (yes I did google it and there are a couple of ways to convert Kelvin to Fahrenheit but I found this method to implement to be the easiest).
My new line of code is provided below.
Code: Select all
var temp = Math.round(self.config.units === "celsius" ? res.data.main.temp - 273.15 : res.data.main.temp * 9) / 5 - 459.67,
I did make PoltoS aware of this. It will be verified, he also wanted me to share it here.