mediaNen
(Bo )
March 7, 2023, 5:15pm
389
Thank you again for this great project. I have a little issue with the Rain Intensity sensor. I can’t make it work.
Configuration.yaml
sensor:
###### Rain sensor flips count ######
- platform: history_stats
name: Rainsensor flips
entity_id: binary_sensor.aqara_rain_sensor_contact #The aqara sensor
state: "off"
type: count
start: "{{ now().replace(hour=0, minute=0, second=0) }}"
end: "{{ now() }}"
binary_sensor:
- platform: trend
sensors:
rainfall_trend:
entity_id: sensor.rainfall_today
max_samples: 2
template.yaml:
#Rain sensors
- sensor:
- name: Rain today
unit_of_measurement: mm
state_class: total_increasing
unique_id: rainfall_today
state: >-
{% set count = states('sensor.rainsensor_flips') | int(0) %}
{% set mm = count * 0.30303 %}
{% if count >= 0 %}
{{ mm|round(1, 'floor') }}
{% endif %}
availability: "{{ (states('sensor.rainsensor_flips') not in ('unknown', 'unavailable')) }}"
- sensor:
- name: "Rain intensity hour"
unit_of_measurement: "mm/h"
state_class: measurement
unique_id: rainfall_per_hour
state: >-
{% set rain_hour = ((state_attr('binary_sensor.rainfall_trend', 'gradient') | float(0)) * 3600) | round(1, 'floor') %}
{% if rain_hour >= 0 %}
{{ rain_hour }}
{% else %}
{{ 0 }}
{% endif %}
The sensor showing 0.0 all the time.
Any idea what could be the issue?
parrel
(Parrel)
March 7, 2023, 5:41pm
390
Does your binary sensor have a gradient attribute? If yes, does it have a value other then 0?
You can also paste the jinja2 code in the developer tools template thing to see the values of the variables.
mediaNen
(Bo )
March 7, 2023, 9:35pm
391
I am not sure that I fully understand. Do I need to set the gradient value somewhere? I have just copied the code from your post. Tips and daily rain works just fine, it is only this intensity sensor that is not working.
If I copy the Intensity sensor into the developer tools template thing, it returns 0.0
parrel
(Parrel)
March 21, 2023, 5:12pm
392
To debug why it’s showing 0 you need to debug how it’s coming to this value.
{{ state_attr('binary_sensor.rainfall_trend', 'gradient') }}
What does this return when you add it to the developer tools template?
Any errors in the logs?
mediaNen
(Bo )
March 29, 2023, 6:01am
393
No errors in the logs that I can see. I have entered the above line and it simply returns “null”
parrel
(Parrel)
March 29, 2023, 6:22am
394
And the entity id for reading the daily rain is correct? sensor.rainfall_today
mediaNen
(Bo )
March 29, 2023, 6:49am
395
Yes, you can see my sensors a few comments up. It is an exact copy of your sensors from your post. Everything else is working just fine.
mediaNen
(Bo )
March 29, 2023, 11:13am
396
I removed everything from my configuration.yaml and templates.yaml. Restarted HA, added sensors again and now it works. Very strange, but at least I get data now
Thank you very much for your help and time.
1 Like
Wasfwesd
(Abdul Ghani )
March 29, 2023, 9:34pm
398
I need this ZigBee rain gauge sensor please help me
parrel
(Parrel)
March 30, 2023, 4:05pm
399
You can create it yourself, the parts are in the first post.
bergasha
(Bergasha)
April 3, 2023, 7:16am
400
Is anyone running the latest Beta? tips keep setting itself to 1 and won’t reset to 0 at midnight so daily rain is constantly 0.3mm. Is anyone else getting the same?
parrel
(Parrel)
April 3, 2023, 6:57pm
401
I once had this problem, and the state of the rain sensor was ‘closed’ instead of ‘open’.
I had to pour some water in the sensor to make it tip, so that the state was ‘open’ again.
Is this not your case?
bergasha
(Bergasha)
April 3, 2023, 7:27pm
402
Unfortunately not, still states it’s open and from what I can tell is still working correctly other than resetting itself to one instead of zero.
parrel
(Parrel)
April 3, 2023, 8:33pm
403
Try to create another history stats sensor on another binary sensor and see if it also does not reset this midnight
bergasha
(Bergasha)
April 3, 2023, 8:52pm
404
Good idea, I’ll try that this evening and report back. Cheers
1 Like
bergasha
(Bergasha)
April 4, 2023, 7:39pm
406
No it did not, I however deleted my db and everything seems to be resetting again.
Not ideal but it’s a fix if anyone else runs into this.
parrel
(Parrel)
April 4, 2023, 8:40pm
407
There goes all the rain data history
bergasha
(Bergasha)
April 4, 2023, 9:32pm
408
It actually kept all the utility meter data so no issues there.
1 Like