Code: Alles auswählen
var chillCount = 4
rule "Windchill_Calculate" // thx to @Udo_Hartmann for the Rule-Body and @dmaillie for the math-stuff - 2019-01-13
when
Item LocalWeatherAndForecast_Current_OutdoorTemperature received update
then
if(!(LocalWeatherAndForecast_Current_WindSpeed.state instanceof Number))
{
logWarn("windchill","Windspeed not of Type Number!")
return;
}
if(!(LocalWeatherAndForecast_Current_OutdoorTemperature.state instanceof Number))
{
logWarn("windchill","Temperature not of Type Number!")
return;
}
var speedCurrent = Math.pow((((LocalWeatherAndForecast_Current_WindSpeed.state as Number).floatValue) * 1.0), 0.16)
//logInfo("windchill","Speed: " + speedCurrent)
var tempCurrent = (LocalWeatherAndForecast_Current_OutdoorTemperature.state as Number).floatValue
//logInfo("windchill","Temp: " + tempCurrent)
owm_localCurrentWindchill.postUpdate(13.12 + 0.6215 * tempCurrent - 11.37 * speedCurrent + 0.3965 * tempCurrent * speedCurrent )
chillCount ++
if (chillCount >= 4) // logInfo every 2 hours (or every 4th time) - Temperature is updated every 30 Minutes by another Rule/Binding(LocalWeatherAndForecast_Current_OutdoorTemperature)
{
logInfo("windchill"," I'm still alive")
chillCount = 0
}
end