Heavy Rain Detection - based on Rain Counter Sensor

Hello,
i want to create a Heavy Rain Detection to recognizes based on a Weather Sensor installed outside of my build the precipitation. This Weather Sensor from Homematic IP has a Rain Counter integrated. This Sensor delivered every 4 minutes a value of falen rain in this time. Based on this value I want to generated a 1 hour value to estimate the precipitation per hour per square meter - l/m2/h.
Can anyone give a good advice of an automation / script how I can set up such a variable which is kind of a shifting integral with the range of one hour?

I would recommend to use the statistics sensor platform (Statistics - Home Assistant) like that:

sensor:
  - platform: statistics
    name: "Rainfall last hour"
    entity_id: sensor.rainfall_sensor
    state_characteristic: sum
    max_age:
      hours: 1

The code is untested, but should guide you into the right direction.
If you not have Code Server installed, I would recomment to install it to edit the configuration.yaml of Home Assistant.

Have fun.

1 Like

thank you very much for such a fast replay. I will check your suggestion immediately :slight_smile:

So I played a little around with it and figured out one issue.
The input sensor for this statistics is incrementing. So those values delivered for the new sensor is way too big.

So I created a second sensor which should be the delta of the last loop value and the current value to get the increment between two sensor signals.

 - platform: statistics
    name: "Niederschlag_delta_last_loop_current_loop"
    entity_id: sensor.wetterstation_regenzahler
    state_characteristic: change
    sampling_size: 2

could that work?

Could you please make a screenshot of the sensor.wetterstation_regenzahler diagram?
Not sure how this sensor behaves. I want to see if the values go back to 0.

For example the period between 17:00 and 21:00 of April 20th would be interesting to be compared. Please add the sensor and the statistic sensor to the same dashboard and make a screenshot of both at the same time to be able to compare the data.

Would be nice to have more details about the weather station itself and how the sensor behaves. A link to the documentation of the integration used would be helpful.

So here you can find the documentation of the weather station itself:

The rain will be counted by a rocker. Every 4 minutes the sensor sent the counted rain.
The rain counter sensor.wetterstation_regenzahler is incrementing and will never get smaller values.

I try to creat the view in the next hours. But it want to simulate rain by my self where I now the amount of water flown through the sensor.

If the original sensor increases over time, I would try the following state_characteristic: sum_differences_nonnegative

Try this setting with 1 hour and check if it matches your need.

Thank you I will do this.
I want to give this new Sensor a UniqueID can this ID be a name as well or are there any constraints regarding a syntax?

yes, ss for all sensors you can define „unique_id“ with a unique value. Usually UUIDs are used. If you are using the code server addon, which I recommend, you can generate one with right click.

I am a bit late to this but I use Utility Meter for my rain sensor

utility_meter: #-----------------------------------------------------------------------
  rain_hourly:
    source: sensor.tubpit_rain_total
    name: Hourly Rainfall
    cycle: hourly
    delta_values: false
  rain_daily:
    source: sensor.tubpit_rain_total
    name: Daily Rainfall
    cycle: daily
    delta_values: false
  rain_weekly:
    source: sensor.tubpit_rain_total
    name: Weekly Rainfall
    cycle: weekly
    delta_values: false
  rain_monthly:
    source: sensor.tubpit_rain_total
    name: Monthly Rainfall
    cycle: monthly
    delta_values: false
  rain_yearly:
    source: sensor.tubpit_rain_total
    name: Yearly Rainfall
    cycle: yearly
    delta_values: false

Is this a web service or a local sensor?

I am trying some measurements at the moment but those values does not fit at the moment. Tomorrow heavy rain is forecasted i will post those values so we have real life data.

This integration provides sensors. It works well for me.