Irrigation rule: Has it rained yesterday and will it rain tomorrow?

Assuming that there was measurable rain detected by whatever weather stations OWM uses sometime during that time period there should be a some values in the graph.

You can search through events.log and see if that Item has changed at all during that time period.

I’ve never used OWM’s precipitation Channels. In my area the forecast precipitation is kind of meaningless for anything more than a very rough idea that there will be precipitation somewhere in the neighborhood, maybe. But that’s not unique to OWM, none of the weather companies do any better.

Why don’t you use Buienradar as a source?

I had no idea there was a binding…

How should this “speed” be interpreted…? Rain doesn’t have speed, does it? :stuck_out_tongue:

they do forecasts for today or the upcoming hours.

for forecasts I use the free api of mesteoserver.nl, they give you a json respons with a forecast of 8 days for temp, rain, sun etc. quick example of two days:

{
    "plaatsnaam": [
        {
            "plaats": "Wezep"
        }
    ],
    "data": [
        {
            "dag": "10-07-2024",
            "avg_temp": "20",
            "min_temp": "16",
            "max_temp": "23",
            "windr": "238",
            "windrltr": "ZW",
            "winds": "5",
            "windb": "3",
            "windkmh": "18",
            "windknp": "10",
            "tot_neersl": "3.2",
            "neersl_perc_dag": "80",
            "tot_zond": "576",
            "zond_perc_dag": "80",
            "sup": "05:24",
            "sunder": "21:58",
            "toestand": "regen"
        },
        {
            "dag": "11-07-2024",
            "avg_temp": "17",
            "min_temp": "13",
            "max_temp": "21",
            "windr": "255",
            "windrltr": "ZW",
            "winds": "4",
            "windb": "3",
            "windkmh": "14.4",
            "windknp": "8",
            "tot_neersl": "0",
            "neersl_perc_dag": "0",
            "tot_zond": "583",
            "zond_perc_dag": "81",
            "sup": "05:25",
            "sunder": "21:57",
            "toestand": "halfbewolkt"
        },
        {
            "dag": "12-07-2024",
            "avg_temp": "16",
            "min_temp": "11",
            "max_temp": "21",
            "windr": "236",
            "windrltr": "ZW",
            "winds": "4",
            "windb": "3",
            "windkmh": "14.4",
            "windknp": "8",
            "tot_neersl": "0",
            "neersl_perc_dag": "0",
            "tot_zond": "504",
            "zond_perc_dag": "70",
            "sup": "05:26",
            "sunder": "21:56",
            "toestand": "halfbewolkt"
        },

Looks good. I assume the unit of tot_neersl is mm (so in your example “3.2 mm”)?

How do you get this JSON, and integrate it in openHAB?

I assume you use Nederland Extended: uitgebreide actuele weermetingen API and then Weersverwachtingen per dag? (Where I would need to use De actuele weermetingen voor iedere locatie in Europa and then Weersverwachtingen per dag, as I live in Flanders.)

I use something similar in Australia.
Here is my rule that grabs the json data and I put that into a string item called BOMdata

//because icon names with dashes in them are reserved I replace the dash with underscore
function input(i) {
    return i.replace(/-/g,'_');
}

var DATA = actions.HTTP.sendHttpGetRequest("https://api.weather.bom.gov.au/v1/locations/r67rt9q/forecasts/daily", 2000).replace(/icon_descriptor...\w+/g,input);

items.getItem("BOMdata").postUpdate(DATA);

I have a widget that displays the data:

uid: BOM-widget-with-temps
tags: []
props:
  parameters: []
  parameterGroups: []
timestamp: Mar 26, 2021, 11:17:01 AM
component: oh-list
config:
  style:
    min-width: 250px
    --f7-list-item-after-font-size: 12px
    --f7-list-item-after-font-weight: bold
    --f7-list-item-after-text-color: var(--f7-text-color)
slots:
  default:
    - component: oh-repeater
      config:
        sourceType: range
        rangeStart: 0
        rangeStop: 6
        for: index
        fragment: true
      slots:
        default:
          - component: oh-list-item
            config:
              title: =dayjs(JSON.parse(items.BOMdata.state).data[loop.index_idx].date).format('dddd
                MMM D')
              footer: =JSON.parse(items.BOMdata.state).data[loop.index_idx].extended_text
              after: =(JSON.parse(items.BOMdata.state).data[loop.index_idx].temp_min  == null)
                ? " Min --- " + " Max " +
                JSON.parse(items.BOMdata.state).data[loop.index_idx].temp_max
                :"Min " +
                JSON.parse(items.BOMdata.state).data[loop.index_idx].temp_min +
                " Max " +
                JSON.parse(items.BOMdata.state).data[loop.index_idx].temp_max
              icon: ="oh:"+JSON.parse(items.BOMdata.state).data[loop.index_idx].icon_descriptor
    - component: f7-segmented
      slots:
        default:
          - component: oh-button
            config:
              text: Refresh BOM data
              outline: true
              actionRule: 1a2e6bfd0c
              action: rule

This is what it looks like:
Screenshot from 2024-07-10 16-32-56

Maybe some of the code I have used you can modify to get what you want to work.

Good luck.

1 Like

Right, it’s winter now over there… :slight_smile:

Is that code Java? Javascript?

Its is ECMAScript 262 Edition 11.
It is what OH4 is using.

Nothing special.

configuration: {}
triggers:
  - id: "5"
    configuration:
      cronExpression: 0 15 0/2 * * ? *
    type: timer.GenericCronTrigger
conditions: []
actions:
  - inputs: {}
    id: "1"
    label: Refresh the BOM data
    configuration:
      type: application/javascript
      script: >-
        
        //because icon names with dashes in them are reserved I replace the dash
        with underscore

        function input(i) {
            return i.replace(/-/g,'_');
        }


        var DATA =
        actions.HTTP.sendHttpGetRequest("https://api.weather.bom.gov.au/v1/locations/r67rt9q/forecasts/daily",
        2000).replace(/icon_descriptor...\w+/g,input);


        items.getItem("BOMdata").postUpdate(DATA);

        //console.log("BOMdata refreshed ")
    type: script.ScriptAction

You might be able to get what you need and maybe the code I have will give you some clues?

1 Like

The data even gives you the chances of rain:
Screenshot from 2024-07-10 16-47-00

Which is in the json data. I don’t use that though but I could. I also have my own weather station so I know when it does rain here as well. The official BOM site is about 20km away from me.

aha, Flanders, that could be a bit different.

I us an http call to the meteoserver api and ik returns json data. I pick that up with an item where the channel has a State Transformation with something like this: JSONPATH:$.data[1].tot_neersl

1 Like

Hi Eric,

I saw this post today and fwiwo wanted to quickly tell you what I am doing.
Basically I am using a similar approach to the one you are describing in your initial post.
To get the amount of rain for the last 24h I am using the data from my Netatmo rain sensor.
To get the forcast data I am using the classical openweathermap api to get the 3h forcasts and sum up the consecutive 3h forecasts to the forecast for the next day.
In addition I am using the outside temperature from my Netatmo outside sensor, based on those value, I have defined the length of the irrigation cycle.
So if the max day temperature is above 21 degrees i am watering 10 min, if it is above 25 degrees i am watering 20 min and if it is above 31 degrees i am watering for 30 min.
If it is under 21 degree i am not watering.
I am watering only if the today’s rain was under a certain threshold, f.e. 3mm/qm and if the forecast is below a certain threshold.
To avoid the problem that i don’t water for a couple of consecutive days based on a wrong forcast i introduced a flag that tells me if i watered yesterday.
If I did not water yesterday based on forecast I am watering even if the forcast for the next day says it will rain.
I have installed 3 watering circuits using tuya base valves (was a bit tricky to get them running using their local API with OH, but the forum was of great help here) and I am running this basically since 1 year now without major problems.
What helped me a lot (especially in the debugging phase) were the historical data which I am keeping in InfluxDB and analyzing it with Grafana.
I separated the rule to calculate if I need to water from the actual rule driving the valves.
That allows me to change the algorithm to calculate watering if needed (f.e. use an ml based algorithm for that).
But for now the rule based approach works good enough for me.

1 Like