☔ DIY Zigbee rain gauge

I think there is an InfluxDB integration for Home Assistant

It will allow you to add entities that you want to send to the influxdb database

You just configure the entities like in the original post and then add them to influxdb

I don’t think any of the original entities would work for this instance. I’m looking for something that simply triggers on every flip and enters a defined amount of rain (0.30303) in as a single entry in InfluxDB. As it is it’ll just record “1” and then “0” every time it flips, which is usable just not ideal.

Why don’t you then include the ‘rainfall today’ sensor?
You can also try to modify the history stats sensor in something that never resets so you get the all-time rain amount if that’s what you need

I appreciate this is slightly outside of the realm of the original post, but how would one… modify the yaml code if it’si just on-off ?

If you use an Aqara door sensor instead of the reed switch that came with the board placement seems to become more tricky, i can only achieve on-off it seems.

What does offset -29d do ?

What does

Number(hass.states['sensor.rainfall_today'].state)

Do? I have never seen a reference to hass before, but maybe you have a different HA install type?

Also, what is the best buienalarm integration? I see various:
GitHub - gieljnssns/buienalarm-sensor-homeassistant: Buienalarm custom_component for Home-Assistant or
Neerslag Card (rain forecast) (Buienalarm and/or Buienradar) - #34 by chrisV

Which one is the best one ? It looks like buienalarm at least supports the UK as well, which is great.

Right now the history_stats sensor only counts the ‘off’ state. If you want to count both on and off states you would have to modify that sensor so it will count both.

What does offset -29d do ?

That was needed to make the 30 days graph to work

What does Number(hass.states['sensor.rainfall_today'].state) Do?
I have never seen a reference to hass before, but maybe you have a different HA install type?

It’s Javascript. In Javascript that’s the way to access home assistant states. And the piece of code converts the state to a Javascript Number so you can calculate with it

Also, what is the best buienalarm integration?

It looks like buienalarm at least supports the UK as well, which is great.

I use the the following integration, and if it supports the UK it’s worth a try I guess

1 Like

Yes, I just use the influxdb integration parrel posted and I didn’t have to do anything special in home assistant outside of this thread

It’s been almost 2 years since I created this sensor, and it’s still going strong on the original battery :muscle:t2:

5 Likes

We’ve had some snow here and I was thinking about adding a heat pad underneath one day :slight_smile:

Cool! Any idea how you would do that? Maybe with a solar panel?

Mine has been covered in frozen cobwebs for days now. Need to add a spider counter :rofl:

1 Like

Nice 3D printed mount!

I have a rain gauge sensor in my weather station I am reading via a SDR dongle. Unhelpfully it resets itself from time to time. I want to use the Utility Meter helper to set up a day / week / month sensor. Any suggestions about how to cope with the readings being reset? There is a delta option in the Utility Meter helper, is this a setting that will assist.

Any thoughts?

I think you can use the utility meter without the delta option for that.

It should work like this:

your sensor - the utility meter
1mm - 1mm
2mm - 2mm
3mm - 3mm
reset
1mm - 4mm

Do you mind sharing the 3d file? I could use something like this as well :slight_smile:

Rain gauge mount by ARHARH - Thingiverse There you go. Can’t remember the size of bolt through the middle, And it is fixed down with no 8 screws.

1 Like

Perfect, thank you.

@parrel Nice work. I´m using your configuration in the initial Post.

Two things I changed:

  1. At Restart of Home Asistant History Stats are recored

As other users mentioned a restart affects the history utility stats. To avoid this you have to invert the rain sensor gauge as a new binary sensor and use that instead.

  1. Variable Names

I like to have all variables in a namespace. “rainfall”, so I changed that.

  1. Unique IDs

all Entities have now Unique IDs, so I can change their Names / Icons etc. in the user frontend.

@parrel Could you please adapt my configuration in your initial Post.

The complete configuration (of my configuration.yaml):


binary_sensor:
  - platform: trend
    sensors:
      rainfall_trend:
        entity_id: sensor.rainfall_today
        max_samples: 2

  
template:
  - binary_sensor:
      - name: rain_gauge_invert
        unique_id: rain_gauge_invert
        state: >-
          {{ is_state('binary_sensor.rain_gauge', 'off') }}
        device_class: door  
  - sensor:
      - name: Rainfall today
        unit_of_measurement: mm
        state_class: total_increasing
        unique_id: rainfall_today
        state: >-
          {% set count = states('sensor.rainsensor_flips') | int(0) %}
          {% set mm = count * 0.30303 %}
          {% if count >= 0 %}
            {{ mm|round(1, 'floor') }}
          {% endif %}
        # If you have issues with the history sensor doubling after restarting HA, add the line below (@BigG)
        availability: "{{ (states('sensor.rainsensor_flips') not in ('unknown', 'unavailable')) }}"
      - name: "Rain intensity"
        unit_of_measurement: 'mm/h'
        state_class: measurement
        unique_id: rainfall_per_hour
        state: >-
          {% set rainfall_hour = ((state_attr('binary_sensor.rainfall_trend', 'gradient') | float(0)) * 3600) | round(1, 'floor') %}
          {% if rainfall_hour >= 0 %}
            {{ rainfall_hour }}
          {% else %}
            {{ 0 }}
          {% endif %}

sensor:
# Rainsensor
  - platform: history_stats
    name: Rainsensor Flips
    entity_id: binary_sensor.rain_gauge_invert #The aqara sensor
    state: 'on'
    type: count
    start: '{{ now().replace(hour=0, minute=0, second=0) }}'
    end: '{{ now() }}'

utility_meter:
  rainfall_week:
    source: sensor.rainfall_today 
    unique_id: rainfall_week
    cycle: weekly
  rainfall_month:
    source: sensor.rainfall_today 
    unique_id: rainfall_month
    cycle: monthly
  rainfall_year:
    source: sensor.rainfall_today 
    unique_id: rainfall_year
    cycle: yearly




                                          
2 Likes

In response to your question to adapt the original post.
For the most part I want to keep it as simple as possible. Not everyone has the restart issue, and if they do, they can find several fixes in this thread to solve it, so I won’t add the inverted sensor to my OP.

I will also keep the naming the same, as a lot of pieces of code in this thread have been based on these names. And if a user wants other naming, they are free to change it themselves.

I do like the suggestion for the unique id’s, and I will add them to the utility_meter as they were not yet present there.

Thanks for your contribution :slight_smile: