Wolfram Language

Open live version

Email Freeze Alerts

Create a task in the Wolfram Cloud that checks the forecast every day and sends you an alert if freezing weather is forecast.


code

X
X
X
X

how it works

To send yourself an email message when a freeze is forecast, (1) write a function that sends an alert email with temperature data, (2) write a function that checks the forecast for freezing weather the next day and invokes the alert mail function if it is expected, (3) save those functions in the Wolfram Cloud, and (4) schedule a task in the Wolfram Cloud that wakes up every day at 18:00 and loads and executes those functions.

The function to send an alert email is a straightforward invocation of SendMail:

In[1]:=
X

The body of the message gets a plot of temperatures from Wolfram|Alpha. To obtain the expression that returns that data, evaluate == temperature Urbana IL (without quotes), and choose Formatted pod from the + menu to the right of the temperature plot in the output:

The CheckForFreeze function gets forecasted temperatures from Wolfram|Alpha and sends an alert message if any of tomorrows temperatures are below freezing:

In[2]:=
X

To obtain the expression that returns the forecast, evaluate == temperature Urbana IL (without quotes), and choose Computable data from the + menu to the right of the temperature plot in the output:

Temperature data in the forecast are of the form {{y, m, d, h, m, s}, t}, for example,

In[3]:=
X
Out[3]=

Extract the temperatures from the forecast that are tagged with tomorrow's date by forming a pattern that matches just those elements whose {y, m, d} match tomorrow's date, as follows.

DateList[] gives the current date:

In[4]:=
X
Out[4]=

Taking the first three elements of that list and adding 1 to the day gives tomorrows date:

In[5]:=
X
Out[5]=

Make a pattern that matches just those temperature forecast elements whose {y, m, d} match tomorrows date:

In[6]:=
X
Out[6]=

Extract those temperatures with Cases and take the minimum:

In[7]:=
X

That code is all that is necessary to check the forecast and send an alert message. To deploy it in the cloud, first save the CheckForFreeze function in the Wolfram Cloud:

In[8]:=
X
Out[8]=

Then schedule a task to run at 18:00 every day that loads and executes CheckForFreeze:

In[9]:=
X
Out[9]=