Controlling a switch based on the probability of rain

I like to control a switch if the probability of rain is >60% . This probability number is to be taken from the local weather website. Based on the number, the switch will be turned "ON" or "OFF".

Is there app or any idea? BTW, which program is being use to write the script for Hubitat app?
Thanks in advance.

1 Like

You'd have to write a 'Switch-like' Driver for that that polled the website and 'scraped' the value. Then set the switch to the correct state. Alternately you could make it 'dimmer like" and just directly deposit the scraped value. Then RM or an app can evaluate and set a virtual switch.

There's samples of how to poll a weather service (via API) :slight_smile:


Or from @snell use the great driver for AmbientWeather API and with a refresh rate set to one hour. Then a pretty easy rule in RM like mentioned below that control a virtual switch for you to use.

1 Like

Thank you csteele. I will try

Thanks Carl, thank you.

If there's an already built Driver to get Weather that actually has the data you want, I'd go with that. If the data is unreliable, or doesn't update often enough, then investing in writing one might be worth it. But I think I'd start as @Carl suggested and use AmbientWeather from @snell and see if it works for your needs.

1 Like

Unfortunately the built-in driver does not include any prediction of rain, therefore I suggest to use the AmbientWeather instead.

Depending on your country, the Weather Service Monitor could work for you also.

1 Like

Thanks for the helpful suggestion.

Thanks for your help

I will try this one also. Thanks

This is how I do it using the Darksky weather app (although this will only work through to the end of 2021 when their API will close due to them having been bought out by Apple)

It polls the weather service twice a day. At other times, I can request a weather update by pressing buttons. In these cases it reads the weather forecast to me using a Google Home device and sends me a notification with the weather summary. I also get a nice notification when the probability for rain tomorrow will be quite high. It works beautifully and I hope may give you ideas!

I will migrate to another weather service when I must :rage:

Thank you very much for sharing your idea. Is there any way to know what to write in pullData()?

Requesting one more help. How can write a I script in Groovy Apache to turn a switch "ON" and turn "OFF" after 5 minutes? Specially I need help with time delay with certain hours. Is there any document available with syntax ? Thanks in advance.

Why not just use Rule Machine for this simple case?