☔ DIY Zigbee rain gauge

remove the two comments, or fix the indentation like in the original post. I suspect they cause an error

#If you have issues with the history sensor doubling after restarting HA, add the line below (@BigG)
#availability: "{{ (states('sensor.rain_sensor_flips') not in ('unknown', 'unavailable')) }}"

1 Like

Yes, I removed the two comments and now Rainfall Today is 0.4 in.
I suspect at this point, the weekly, monthly and annual all should read the same value.
They are reading Unknown. That’s an assignment for me to figure out.

Thank you for helping.

1 Like

@ekainz Unfortunately, I have to write again. Everything works except for the rain intensity. It always only shows me 0.00mm/h. But I can’t find the error. When I put it in the developer tools, it tells me ‘trigger’ is undefined.

Is this just a formatting issue? I just can’t get to the error and hope someone can help me :frowning:

    - name: "Regen Intensitaet"
      unique_id: regen_intensitaet
      state: >
          {% set lastTip = as_timestamp(now()) - as_timestamp(states.binary_sensor.diy_zigbee_regenmesser_contact.last_changed) %}
          {% set betweenTips = states('sensor.regen_sensor_zeit_zwischen_tropfen') | as_timedelta %}
          {% set max_time = max(lastTip, betweenTips.total_seconds()) %}
            {{ (0,30303 / (max_time / 3600)) | round(1, default=0) }}
      state_class: measurement
      device_class: precipitation_intensity
      unit_of_measurement: "mm/h"
  - trigger:
      - platform: state
        entity_id: binary_sensor.diy_zigbee_regenmesser_contact
    sensor:
      - name: Regensensor Zeit zwischen Tropfen
        unique_id: regen_sensor_zeit_zwischen_tropfen
        state: >
          {{ (now() - trigger.from_state.last_changed).total_seconds() }}
        state_class: measurement
        unit_of_measurement: "s"

It’s been a while since I’ve asked so I will again…

Has anyone created a fully 3D printed case yet? Not a modified version of the commercial ones people are using?

while not exactly the same but works just as well and designed for the Aqara door sensors. This is what I’m using.

https://smartsolutions4home.com/ss4h-zrg-zigbee-rain-gauge/

2 Likes

That’s seems to be exactly what I’m looking for! Thank you! :+1:

Any reason this wouldn’t work to measure sprinklers?

Ordered the parts and have tested the code with a door sensor I have here. Looking forward to getting this setup!

As long as you can get a representative sample of water to go into the measurement catch funnel I don’t see why it shouldn’t work.

But depending on the type of sprinklers you have that might not be possible.

Hello, with the help of a friend, I was able to make the rain gauge soldering to work. Now this is working in HA.
However I noticed, an issue. When rain is very weak, let say 1 mm drop in 30 minutes, the rain gauge does not count anything. I noticed the drops remain on the device and don’t fall into the hole. Have you also noticed it ? And did you find a workaround ?

Good to hear you got it working.

I have not noticed that, but someone else had the same issue, and I think they used a bit of wax to stimulate the raindrops to slide to the hole.

If they do not pass the hole, you could try to make it wider with a drill.

1 Like

Another option: use rain-x to make the water flow easier.

I have an issue with my intensity counter: it always shows 0.3 mm/h, even when there is no rain. It never goes to zero. What could be the problem?

Do you use z2m or zha? Do you use the approach in the original post or another approach?

I use a Sonoff DW2 door sensor via the Sonoff custom integration instead Zigbee Aqara sensors didn’t work reliable and were unavailable often. Should work as well, right? Actually it does, only the rain density seems to behave strange though.

What is the state of the door sensor when this happens? On or off?

Currently it is ‘closed’ - and it doesn’t happen this afternoon. Yesterday it happened. Don’t know the state at that time however. Will keep a eye on it!

If I’m correct, closed is equal to ‘off’ and if you take a look at the history_stats sensor, it counts the ‘off’ states, meaning that every reset at 00:00, it counts a tip because its ‘off’ at that moment.

If you followed the original post method (on->off->on) then your sensor didn’t sent the last ‘on’ signal. If you use another method where one side is ‘on’ and one side is ‘off’ then you need to solve it in another way, described somewhere in this thread.

You can check the history of the sensor to see what the state was, right?

My sensor is indeed a ON-OFF sensor. Each time it tips, the state changes. You are right, I had to change the code for it to work. Got help from a nice user in this forum/thread to achieve it. I need to find it again in the thread.
See the states of the sensors (I have two rain gauges just for fun, about 2m apart from each other at a different height above ground). One called ‘Regensensor 2’ and one ‘Regensensor 3’. If I understand my code in configuration.yaml correct, the intensity is calculated by ‘Regensensor 2’. (I have to admit that after a period of 6-8 months after ‘constructing’ my code, I do not fully understand it. HA code is a bit difficult to master. I have a book 540pages book of Udo Brandes ‘Home Assistant’ - but still struggle a lot to understand the concept of Helpers, Template sensors etc.)

Here is my setup using a Sonoff DW2 window sensor. I’ve 3D printed a Box to keep it dry inside the rain gauge and glued a small ø5mm magnet to the flip mechanism, resulting in ON or OFF (Closed / Open for the door I believe). I placed it on top of my pergola.




Furthermore I painted the gauge in brown colors RAL 8019 as the Pergola

3 Likes

Just thinking out loud, you might be able to modify the code in the original post, by adding two history_stat sensors, one counts ‘on’ and one counts ‘off’. In the template sensor, you count both sensors together, and then decrease that value by 1 (because of a false tip each night). The number that you end up with, needs to be multiplied with the rain per tip (default 0.30303) and then you have quite a simple solution.

Not tested though :slight_smile:

PS: Blends in really well painted like that!