☔ DIY Zigbee rain gauge

@ekainz Hey, sorry for the stupid question. I have now connected the Aqara sensor to the Rain Gauge and wanted to add your code to my configuartion.yaml. Will this work or do I need further configuration codes?
And how do I make the Aqara door contact work as a rain sensor? Do I have to rename the entity?
Sorry for the stupid questions :-/

The code from @ekainz is only for the ‘rain intensity’ sensor from the original post. You will still need the other configurations from the original post to create the rain sensor. And they work just as good as they did in 2020 when the post was created :slight_smile:

ok I added the part and entered my zigbee door contact.

  - platform: history_stats
    name: Regensensor flips 
    entity_id: binary_sensor.diy_zigbee_regenmesser_contact #The aqara sensor
    state: 'off'
    type: count
    start: '{{ now().replace(hour=0, minute=0, second=0) }}'
    end: '{{ now() }}'

I then adapted the configuration from ekainz a little for myself in German.

Do I then have to enter the zigbee door contact again at the point I marked with ***?

  - sensor:
    - name: "Regen Intensitaet"
      unique_id: regen_intensitaet
      state: >
          {% set letzterTropfen = (as_timestamp(now()) - as_timestamp(states.binary_sensor.regen_sensor.last_changed)) %}
          {% set zwischenTropfen = states('sensor.regen_sensor_zeit_zwischen_tropfen') | as_timedelta %}
          {% set max_zeit = max(letzterTropfen, zwischenTropfen.total_seconds()) %}
                        
          {{ (0.1 / (max_time / 3600)) | round(1, default=0) }} #replace 0.1 with your mm of rain per tip value
      state_class: measurement
      device_class: precipitation_intensity
      unit_of_measurement: "mm/h"
  - trigger:
      - platform: state
****        entity_id: binary_sensor.regen_sensor
    sensor:
      - name: Regen Sensor 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"

Yes that would be the following for you

1 Like

Thank you, I have done so. I moved the swing back and forth a few times but the status says unavailable. Do you have any idea what the problem could be?

I’m not sure, I’m not using that code from ekainz yet. But I suggest you use the developer tools in Home Assistant, and paste the templates in there too see what the values of the variables are.

1 Like

@parrel The funny thing is that it shows me a value there :-/

  - sensor:
    - name: "Regen Intensitaet"
      unique_id: regen_intensitaet
      state: >
          {% set letzterTropfen = (as_timestamp(now()) - as_timestamp(states.binary_sensor.diy_zigbee_regenmesser_contact.last_changed)) %}
          {% set zwischenTropfen = states('sensor.regen_sensor_zeit_zwischen_tropfen') | as_timedelta %}
          {% set max_zeit = max(letzterTropfen, zwischenTropfen.total_seconds()) %}
                        
          {{ (0.1 / (max_zeit / 3600)) | round(1, default=0) }} #replace 0.1 with your mm of rain per tip value
      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: Regen Sensor 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"

Hmm, maybe it needs a trigger as well, like the code below

How would I have to change the code then? sorry for the stupid question.

I think it’s best to wait for an answer of the author of the code.

In the meanwhile you can use the rain intensity code from the original post.

1 Like

Hi Jeroen,

I built the same setup, adopted your number in the configuration but I am not getting the measurements I expect.

As a test I tipped in 180ml of water ( an Ikea mug) into the funnel. Many tips later, I got a measurement of 5mm of rainfall.
When I calculate this by hand, I should be getting more like 7.8mm.

0,18l / 0,022892m2 = 7,86 . Am I making a mistake here?

If you pour the water fast it can miss tips as the water just runs past the tipper. I have done this when calibrating.

Hi Paul,

3 options

  • the water runs past the tipper if you pour too quickly
  • your ml per tip is different. You can measure the ml required for one tip
  • I made a calculation mistake

I would guess the first one

thanks both, I will retest

Hello, I tried this rain gauge solution and I was almost there, the setup in home assistant was working with the aqara door sensor triggering the flip count. But when I tried to solder the aqara sensor, I think somehow I burnt it as it is not working since.
I never soldered anything before so I watched some videos but I probably did something wrong but I don’t know what.
Reading this thread, nobody complains about it, so you all know how to solder something that is 1 or mm long on a tiny electronic card ?
I would need some advice on how to proceed because now I ma reluctant to buy a new door sensor and waste my money again.
Thanks

Hi Leco
Is the light still blinking when you press and hold the button? What have you tried to see if it’s working? Can you share a picture of the board?

Unfortunately, it is not blinking anymore.
I unsoldered it to see if it can make it work again but not.

What kind of soldering iron did you use? I find it best to use an iron on low heat with a small pointed tip. You can get a decent one that you can adjust the heat on for around $15

I used one bought in Aliexpress where you can adjust temperature from 200 to 400°c.
Would you have any reference to share ?
And at what temperature should be done ?

Thanks

I didn’t really know how to write comments in Jinja2 (I assumed it was just #comment, but its {# comment #})

I’ve updated my code, but you should be ok to just delete the #replace 0.1 with your mm of rain per tip value comment

Other note is my setup is configured so the binary sensor reads on half the time, and off half the time, the default configuration is a momentary on on each tip.
If you would like to set it up in this configuration change the trigger as follows:

    - trigger:
        - platform: state
          entity_id: binary_sensor.rain_sensor
          from: 'off'
          to: 'on'

(untested)