Closed T011235 closed 1 week ago
Hi, I now have looked at your code and found out why I only got zeros. You only implemented the heat index calculation for temperatures above 80F.
So I added some calculations to your function.
My GO skills aren't the best. So please look at my code and if you think my code is Ok please add it to your Repo so we all can use it for our weather stations.
func calculateHeatIndex(temperature, humidity float64) float64 {
// define vars
var heatIndex float64
var adjustment float64
// convert temperature to Fahrenheit
temperature = (temperature * 1.8) + 32
// https://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml
// calculate Steadmans result
heatIndex = 0.5 * (temperature + 61.0 + ((temperature - 68.0) * 1.2) + (humidity * 0.094))
// use Rothfusz regression if Steadmans result yields an heatIndex greate 80F
if heatIndex >= 80.0 {
// calculate the heat index using the Rothfusz regression
heatIndex = -42.379 + 2.04901523*temperature + 10.14333127*humidity - 0.22475541*temperature*humidity - 6.83783e-3*math.Pow(temperature, 2) - 5.481717e-2*math.Pow(humidity, 2) + 1.22874e-3*math.Pow(temperature, 2)*humidity + 8.5282e-4*temperature*math.Pow(humidity, 2) - 1.99e-6*math.Pow(temperature, 2)*math.Pow(humidity, 2)
// calculate any necessary adjustment
adjustment = 0
if humidity < 13 && temperature >= 80 && temperature <= 112 {
adjustment = -1.0 * ((13.0 - humidity) / 4.0) * math.Sqrt((17.0-math.Abs(temperature-95.0))/17.0)
}
if humidity > 85 && temperature >= 80 && temperature <= 87 {
adjustment = ((humidity - 85.0) / 10.0) * ((87.0 - temperature) / 5.0)
}
// add adjustment to heatIndex
heatIndex = heatIndex + adjustment
}
// convert heat index back to Celsius and return
heatIndex = (heatIndex - 32) * (5.0 / 9.0)
return heatIndex
}
With best regards, T011235
Thank you for catching this, and for your proposed solution. I tested your change against https://www.wpc.ncep.noaa.gov/html/heatindex.shtml and noticed inconsistencies in the < 80F range. (I think your code is correct, the inconsistencies come from rounding errors.) Instead of tweaking this algo I decided to instead use an external library to calculate the heat index:
https://github.com/peterzen/hass-pws-mqtt-addon/pull/39
I'll merge and release this soon.
Thanks again!
Thank you for the update. Im looking forward to test the update.
Thank you for your great work.
Thank you for the update. Im looking forward to test the update.
It's out, you should be able to apply the update (0.1.26) in the add-on screen.
Please let me know if you see any issues.
The Heat Index Value mostly shows only 0. I'm using a Renkforce (Froggit) WH2600. Outdoor Temperature and Outdoor Humidity both greater than 0. For example see Picture.