☔ DIY Zigbee rain gauge

Hello Elyobelyob
I have the same problem when I restart home assistant it adds an tips.
I think you have to reverse the state because it is permanently open (on) and off to count tips.
i use Zigbee2mqtt but the problem comes from home assistant
How did you solve the problem?

I’m using an Aqara door sensor and ZHA. My default state is Open. I’m pretty sure it was working fine in the short period I had it working before my first message above. Recently I was getting the fake tip at midnight and fake tips at reboot. I presume this is something to do with the default state … this is the first proper day, and it all seems to work now I reversed the default state.

ok thanks you

I don’t get it… When I restart HA the state is on, which is correct. Every time it tips, it goes to off for a second, which is also right. because off translates to ‘closed’ and on translates to open, when using the sensor as a door sensor. So state: 'off' should be correct…right?

By the way, it does not add tips when I restart HA.

What is the default state of the binary sensor of you guys? (in dev->state) @April @elyobelyob

My default state is on (open). The state I want to track should have been ‘off’, but I was getting issues as mentioned.

Now I’ve swapped to ‘on’ I get no issues. At the end of the day, whichever works lol.

I am running the latest 2021.3.3 … as I say, I don’t think I had this issue before (“off”), but wasn’t running for very long to monitor it.

1 Like

Well, no surprise I’m getting confused … here are the last 360 hours and last 36 hours … I’ve not had a lot of rain.

Very confusing. Here is my graph.

The only things that I can think of causing it are:

  1. It misses the open state after closing (range/interference/low battery?)
  2. On HA reboot the state is set to closed instead of open

I also use an Aqara doorsensor. My default state is open. Make sure that the scale is in this state in both rest positions. Only if the scale is in balance it should have the state closed. The placement of the reed relay is quite important.

This is my graph.

My device had 21 flips from midnight till now (11:15).

1 Like

/nips outside and does a manual tip/ … now it’s open.

/fetches WD40/

1 Like

Screenshot 2021-03-11 at 10.47.53

Although, having swapped back to “off”, I am back to getting the drop outs on reboot. Popped it back to “on” and will watch the differences. Not a lot of rain forecast though …

Is there any reason I can’t use a z-wave door/window sensor instead of your listed Zigbee? Is there anything I should look for in selecting one? I have many z-wave devices but no zigbee and the mounting location for my sensor will be too far from my RaspberryPi for reliable communication.

I am a complete noob at anything custom in HA and this will be my very first venture into it. Thanks.

No, there is none.

If you pick a sensor I would google the name with ‘hack’ behind it, like ‘fibaro door sensor hack’. That way you can see if there is a way to solder the wires on the board.

Another thing to keep in mind is that most sensors are bigger than the aqara sensor I use, so it might not fit in the rain gauge. But you could mount it under the gauge.

Or you could dive in the world of Zigbee. Devices are pretty cheap, and there’s a lot of them. https://zigbee.blakadder.com/zha.html

it it possible to connect this to a lorawan/sigfox network?

i want to monitor rainfall at a garden few kilometers away

what do i need for board or getaway?

Theoretically, Yes. You would have to test with specific equipment to make sure you are in range.

Here, google is your best friend. There are many DIY and pre-built options available. Do some research, test out some equipment and find what works best for you.

Yes it would be possible but I suggest to calculate the rainfall on a microcontroller and send it to HA periodically. Instead of sending every raingauge tip to HA. You would need some external powersource or battery probably.

something like this should work with this rain gauge?

Yes that should be possible with this rain gauge as long as you can count the pulses in the software.

Hello,

I’ve built the same rain gauge a few days ago using an Aqara Door contact module connected to Zigbee2MQTT.
However I have the same problem than others : at each HA restart my door contact binary_sensor changes to ‘off’ for a few seconds and then back to ‘on’ which is the default value. And that increases the tip count :confused:

I have tried to set the ‘retain’ flag for this device in Zigbee2MQTT or not. I have tried to change the tip count method to track ‘on’ or ‘off’ state. But that does not change anything.

I might find a workaround using some NodeRed automation to count tips instead of history_stats, but that seems a little bit overpowered for such a simple task…
Did anybody find a cleaner solution using an Aqara Door contact module and Zigbee2MQTT ?

Thanks,
David

I don’t have a problem after a restart of HA. I’m using also a Aqara door contact. I don’t use Z2M but deCONZ (Conbee II).

I use a binary_sensor straight out deCONZ: binary_sensor.backyard_rainmeter

and these two sensors in HA:

---
platform: history_stats
name: Regensensor flips
entity_id: binary_sensor.backyard_rainmeter
state: 'off'
type: count
start: '{{ now().replace(hour=0, minute=0, second=0) }}'
end: '{{ now() }}'
---
platform: template
sensors:
  regenval_vandaag:
    unique_id: sensor_regenval_vandaag
    friendly_name: Regenval vandaag
    icon_template: mdi:weather-pouring
    unit_of_measurement: mm
    value_template: >-
      {% set count = states('sensor.regensensor_flips') | int %}
      {% set mm_per_pulse = 0.36 %}
      {% set mm = count * mm_per_pulse %}
      {{ mm|round(1, 'floor') }}

I’ve rebooted HA twice and this is my Lovelace card in HA.