☔ DIY Zigbee rain gauge

Thanks for your answer.
I have the same configuration except Z2M. And my problem is that the binary_sensor value change to ‘off’ a few seconds after HA restart. :confused:
I will try to find a workaround. :frowning:

I have z2m too and the same symptom. I’d be happy to know if there’s a work around…

I ended by ading a new input_boolean that I set to ‘true’ for 2 seconds when my Aqara binary_sensor does on → off. I use Node Red to do this but this is probably very easy also with HA automotions.
This prevents to add ghost tips when I restart HA.

1 Like

For those using zigbee2mqtt who have the change of value at reboot, the “retain” option does not work in the interface. I added it directly in the zigbee2mqtt folder and device.yaml and now it works correctly, retaining the last known value at reboot.

1 Like

For hourly rainfall I found that

utility_meter:
  hourly_rain:
    source: sensor.rain
    cycle: hourly

Works well

1 Like

Does not work for me.
You just added the “retain: true” option for your contact door device in the device.yaml, restart Z2M that’s it ? Nothing else ?
When I restart HA Core, the contact door value still change to ‘off’ for 4 seconds. :confused:

Damn ! you’re right, it worked when I tested it, but just now it doesn’t anymore… What happened in between I have no idea. That’s annoying

1 Like

Hi, can you have an instruction on what should be done to read the daily, weekly, monthly, annual rainfall? Thank you greetings.

Worked well for a while (except for reboots I haven’t found a reliable solution), but just recently all previous data went haywire… Anyone have any idea how ?


In this screenshot all the bars at equal height appeared out of nowhere !

Have you set the purge_keep_days of the recorder component to at least the amount of days shown on the chart?

I’ll try that thank you !

1 Like

@czaki
Have you tried Utility Meter - Home Assistant ?

After reading this

and im having a 1/2 knee replacement i have build the knee strength up with no weight

DOC said I have ride a stationary bike

thinking on one of the bike rides " could i do the rain gauge to this.

and my the battery going flat on mine Zigbee Bed occupancy sensor

so tape it to the bike wheel and get a count bugger it worked ok

image

now the maths (im just winging it )

i walk the bike one turn which came to 2.2 mtr

base on the above maths I did

#=======================================================================
#
#=======================================================================

- platform: history_stats
  name: bike turns
  entity_id: binary_sensor.bike_contact
  state: 'off'
  type: count
  start: "{{ now().replace(hour=0, minute=0, second=0) }}"
  end: "{{ now() }}"

- platform: template
  sensors:
    bike_today:
      friendly_name: Bike  Today
      unit_of_measurement: km
      value_template: >-
        {% set count = states('sensor.bike_turns') | int %}
        {% set mm_per_pulse = 2200 %}
        {% set mm = (count * mm_per_pulse) %}
        {% set KM = mm / 1000000 %}
        {{ KM|round(2, 'floor') }}

will add lovelace screen after tomorrow bike ride

here is the lovelace look

image

after some more thinking

3 Likes

Really cool! Let us know the results haha. And good luck with recovering!

Great contribution here! Awesome raingauge.
I’ve also succesfully built it and enjoy the readings.

I’ve also seen the restart hass false flip-count issue. Tried to find a decent solution and I think I have found one. So I’m trying to give something back.

Basically, the problem resides in Hass, when the restart occurs, the binary sensor goes unavailable for a short while, somehow it seems that it is calculated in the history_stats. Not sure if this is expected behaviour or maybe a bug.
However. When you create an inverted binary sensor of your contact-sensor (I’m also using Zigbee2MQTT), then this problem no longer occurs:

- platform: template
  sensors:
    regensensor_contact_invert:
      value_template: >-
         {{ is_state('binary_sensor.regensensor_contact', 'off') }}
      friendly_name: Regensensor
      device_class: door

Edit: please be aware, above is a binary_sensor. The device_class also is important here.

(because we only mirror ‘off’ state, an unavailable state doesn’t mess anything up)
Then all you have to do is alter the history_stats sensor to use this inverted one instead, and ofcourse count state ‘on’ instead, because it’s inverted now (very important):

- platform: history_stats
  name: Regensensor flips
  entity_id: binary_sensor.regensensor_contact_invert
  state: 'on'
  type: count
  start: '{{ now().replace(hour=0, minute=0, second=0) }}'
  end: '{{ now() }}'
3 Likes

I’ve also done this but using a battery operated cheapo 433 door/window sensor.
No need for power or rewiring but you do need a 433 bridge.

I just fitted the sensor inside the casing and added another magnet to the opposite pivot point on the tipper.

I love your brilliant idea! Thanks for posting this.

1 Like

Could show us with some pic

Yes…
I meant to take a photo and post it here but I forgot.
It’s in-situ now but I promise to try and sort it out as soon as I get time.

Sorry
:blush:

sorry for the dumb question.
But where should I integrate this code?
To my config.yaml?
If I save this, there is always an error and I cannot restart my home assistant

no dump question here bro

what are you trying to add

so 1o1 then

glue is looking at the platform that I the Main pointer and that where it all starts

this is basic on my understanding of HA

1st we have

platform: history_stats

that belong with a sensor as its getting data from SOMETHING but we dont know what

that were the platform come in its a pointer

so in my config file I have

image

SHIT I LOVE YAML you can see what you are getting
(note took 2 months to get head around it LOL)

note the sensor bit its point to a sensor folder

sensor: !include_dir_merge_list sensor

so any YAML stuff (file) inside that folder is loading in as a sensor thing (my english LOL)

so base of there file names you get and idea on what im trying to do thanks @frenck for your logic

so the in the statistic.yaml i have the

my logic here i always paste make at top of file easy to find LOL

then my other bits are the the template.yaml file

this is one of the GOOD THING ABOUT HA I can do it MY WAYS as long and i play with in the rules

anymore question just ask bro

1 Like