Hey everyone, I wanted to share my experience setting up a rain gauge using a Zigbee door contact sensor. It’s been a great project, but I did run into a few hiccups along the way. Let me walk you through it!
The Setup
I built a simple rain gauge using a Zigbee door contact sensor. The idea is that for each amount of rain, the sensor sends a pulse. I used Home Assistant’s history_stats platform to count these pulses and convert them into millimeters of rain. Here’s a quick breakdown of my configuration:
yaml
sensor:
-
platform: history_stats
name: Rainmeter Pulses
entity_id: binary_sensor.rainmeter
state: ‘off’
type: count
start: ‘{{ now().replace(hour=0, minute=0, second=0) }}’
end: ‘{{ now() }}’ -
platform: template
sensors:
rain_value_in_mm:
friendly_name: Rain Value in mm
unit_of_measurement: ‘mm’
icon_template: ‘mdi:weather-pouring’
value_template: >
{{ (states(‘sensor.rainmeter_puls’) | float * 0.254) | round(1) }}
The Utility Meter Integration
To keep track of the rain over different intervals, I set up utility meters for quarterly, daily, and monthly measurements. Here’s how that looks:
yaml
utility_meter:
Rain meter
rain_per_quarter:
source: sensor.rain_value_in_mm
cycle: quarter-hourly
rain_per_day:
source: sensor.rain_value_in_mm
cycle: daily
rain_per_month:
source: sensor.rain_value_in_mm
cycle: monthly
The Issue
Everything worked smoothly until I restarted Home Assistant. After the restart, the values were correct for a few seconds but then doubled. It was a bit confusing, but I managed to figure out the cause. The utility meter was counting the pulses twice because of a configuration overlap. I adjusted the source entity and the cycles to ensure each interval was independent, and the issue was resolved!
Tips for Others
- Test Configurations Incrementally: Start with a single interval and ensure it works before adding more. This helps isolate issues.
- Check Entity Sources: Make sure each utility meter is sourcing data from the correct sensor and that there’s no overlap causing double counting.
- Monitor Logs: Use Home Assistant’s log monitoring to catch any errors or warnings that might indicate configuration issues.
- Restart Safely: After making changes, restart Home Assistant and observe the behavior. If issues arise, revert changes and troubleshoot step by step.
Final Thoughts
Setting up a rain gauge was a fun and educational project. It taught me a lot about sensors, data processing, and the importance of careful configuration. I’m now enjoying accurate rain measurements, which helps me manage my garden irrigation more efficiently. If anyone has questions or needs help with similar projects, feel free to reach out!
Happy tinkering! ![]()