How to: Daily rain sensor from cumulative sensor using MQTT and template_sensor

Hi @Naesstrom, I see I have the same rain sensor as you. I eventually get to see a sensor in HA but it does not seem to work reliable. Is it working reliable in your case? My concerns are:

  1. I find it hard to link with my HA
  2. It does not seem to keep a steady heart beat with HA if no rain is falling
  3. It sometimes rains but the sensor does not notice

btw, I have 3 additional 433 devices and they work just fine with my setup that’s why I’m pointing towards this device.

thanks!!

Hi, the chinese sensor send data via

sensor.rain_total

?

Thanks

Here is how I did it:

Create a statistics sensor, which only looks back 24 hours (max_age) on the rain total sensor.
Then create a template sensor to extract the “change” attribute from the new statistics sensor. (Not technically needed, as you could extract the change attribute directly into any automation as needed, but I like to have it)

I’m getting my rain sensor from a 433mhz weather station, received via Home-Assistant-RFLink-Gateway-ESP8266 and imported to Home Assistant using the RF-Link Sensors

Here is my configuration: genestealer / Home-Assistant-Configuration


sensor:
- platform: statistics
    name: Local Rain 24 Hours Statistics
    entity_id: sensor.rain_total
    sampling_size: 4320 # Enough for 3 readings a minute
    max_age:
      hours: 24

  - platform: template
    sensors:
      template_rain_last_24_hours:
        friendly_name: "Local Rain 24 Hours"
        unit_of_measurement: 'mm'
        value_template: "{{ state_attr('sensor.local_rain_24_hours_statistics', 'change') }}"

image

image

1 Like

hello Realthk
is this automation still working in your home assistant. For some reason my values are not updated anymore after the latest home assistant update. Thanks.

I don’t use it any more, but would not do like this now, rather use simple utility meters (with cycles hourly, daily, weekly, monthly) which is a simple 2 lines config and takes care of any value reset.

(when this topic was started, there was no utility meter in HA, that only came somewhere in 2019)