(Last Updated: May 19, 2020)

Virtual Rain Sensor using Site Sensor and Weatherbit API

  • With all the acquisition of Dark Sky by Apple in the plans, I thought I would share my rain sensor setting which is used as input for my irrigation system:

    1. Install @toggledbits site sensor
    2. Register for a free tier account from http://weatherbit.io an pick up the API key
    3. the url I use is using forecast over 2 days (replace with your coordinates and key):
    1. The trip expression is as follows as I also pull a variable from within the sensor variable for the calculation:
    tonumber(response.data[1].precip)+ tonumber(response. data[2].precip) + tonumber(getstate( 67, "urn:toggledbits-com:serviceId:SiteSensor1", "PastRain"))> 5
    1. For display I also pull these value expressions:
    "Total Rain "+(tonumber(response.data[1].precip)+ tonumber(response.data[2].precip) + tonumber(getstate( 67, "urn:toggledbits-com:serviceId:SiteSensor1", "PastRain")))+" mm"
    "Tomorrow "+response.data[2].precip+" mm"
    "Today Probability "+response.data[1].pop+"%"
    "Tomorrow Probability "+response.data[2].pop+"%"
    "Today "+response.data[1].precip+" mm"
    "Accumulated "+getstate( 67, "urn:toggledbits-com:serviceId:SiteSensor1", "PastRain")
    1. Add a time based scene with the following lua code to record the past day rain accumulation every night at the time of your choosing (I use 23:00). Replace the sensorid variable with your sensor id)
    local sensorid=**yoursitesensorid**
    local siteid= "urn:toggledbits-com:serviceId:SiteSensor1"
    local current =luup.variable_get(siteid,"Value5", sensorid)
    luup.variable_set(siteid,"PastRain", current, sensorid)

    With this, my yard irrigation only turns on when the sensor is not tripped... meaning less than 5mm of water is accumulating across 3 days (yesterday, today and tomorrow). Adjustments in value can easily be made.

Log in to reply