Rule to detect/mange Weather Warnings

I had the idea to define a rule that recognizes weather changes (storm/thunder). Most relevant for me is if the outside temperature would change within a certain time…lets say 1h over a certain temp-delta…

Is there a way/function in OH Rules that would help me to do so…


    val currTemp = OutsideTemp.state as Number
    val oldTemp = OutsideTemp.historicState(now.minusHours(1))
    val difference = Math::abs((currTemp-oldTemp).floatValue)
    if(difference > threshold) // send alert

The above depends on OutsideTemp to be saved to persistence.

OutsideTemp would be populated by the Weather binding or what ever way you are getting weather data into OH.

Thanks Rich!!! always a real pleasure to see what is possible especially with history. was not aware of this historicstate…really nice blueprint code!!!

In my case right now weather station WH1080 connected to USB uses PYWWS to post values via MQTT.
Right now i’m in the process to switch to LaCrosse/Technoline sensors and grab my values directly with JeeLink receiver…the old setup drives me crazy somethimes…(stuck,… too many hops in between and WH1080 not always to stable arround USB).