Skip navigation.

Water the lawn if temperature exceeded 80 degrees

I read somewhere that you should do extra watering of lawn (after sunset), if the temperature exceeded 80° F during the day.

So, a really quick hack works like this:

A bash script

TEMP="`/usr/bin/mysql -ss open2300 -e \"SELECT FLOOR(MAX(temp_out)) FROM weather GROUP BY (rec_date) ORDER BY rec_date DESC LIMIT 1;\"`"
if [ "$TEMP" -ge 80 ]; then
/root/water2.exp 120 1
/root/water3.exp 120 1

The query will take the highest (MAX) "temp_out" (outside temperature), for each day (GROUP BY rec_date), sort them chronologically reverse, i.e. today first (ORDER BY recdate DESC), and take only one -- last (LIMIT 1)... i.e. get the highest temperature of the last day.
The "-ss" option is for short x2, i.e. don't print headers, or anything... just the column in the SELECT statement... hence the query will yield only the one value, the maximum temperature for the day, which is then easily compared against the value 80, it became too trivial to use anything fancier than a bash shell to parse the result.

Stick it in cron:
0 20 * * * /root/

Since the cron runs at 8pm (2000), the highest temperature has already happened (unless suddenly sun starts shining after 8pm).

So, if the temperature was over 80° (if [ "$TEMP" -ge 80 ]) then run the lawn watering, but only 120 seconds, and only once.