Hi There,
I had an idea about using my currently DHT22 outside sensor as a rain sensor as well.
I have observed that when starts raining the temperature always drop at least 1 degree Celsius in a 2 minutes window.
But I have no idea how to make an automation to detect that drop in that window time.
Somebody with more experience could enlighten me ?
Thanks
If you’re getting updates every 2 minutes, just compare previous state to current state.
trigger:
platform: state
entity_id: sensor.dht22
condition:
platform: template
# Only do something if temp change greater than -1 degree C
value_template: "{{ trigger.from_state.state | float - trigger.to_state.state | float > 1 }}"
action:
# Input action here
In either case, you could just create a statistics sensor to keep track of it all for you.
sensor:
- platform: statistics
entity_id: sensor.dht22
name: "Temperature Drop"
# Only care about all readings within the last 2 minutes.
max_age:
minutes: 2
Now just use the attributes of this sensor
trigger:
platform: state
entity_id: sensor.temperature_drop
condition:
platform: template
# True if the difference in max/min temperature > 1 degree in the sample size.
value_template: >-
{% set t1 = state_attr('sensor.temperature_drop', 'max_value') | float %}
{% set t2 = state_attr('sensor.temperature_drop', 'min_value') | float %}
{{ t1 - t2 > 1 }}
action:
# Insert action here
Thank you very much Jim, I will try your suggestion.
I have also came across an integration called Trend, perhaps it will work as well.
I will give a try in both.
Thanks again.