Hi,
I have made a raindrop sensor with the ESPHome binary sensor
Have two questions about it.
First question.
Is this:
filters:
- delayed_on_off:
time_on: 3s
time_off: 120s
the same as:
filters:
- delayed_on: 3s
- delayed_off: 120s
Which one is the best to use? and what is the difference?
I want to give the raindrop sensor some time to dry, so it is not flapping between wet and dry. If it is dry for 2 minutes, i think it will keep it dry till the next rain drops. But i have a problem with that, see next question.
This is the sensor code, works, except for one thing, see next question:
binary_sensor:
- platform: gpio
device_class: moisture
pin:
number: GPIO5
inverted: true
name: raining
id: raining
filters:
- delayed_on: 3s
- delayed_off: 120s
The next question. I have the problem that when the ESP is restarted and the raindrop sensor is dry, the binary_sensor state is unknown after boot.
When delayed_off is < 5s (not sure if it is exactly below 5) than this problem is solved.
The sensor is dry after boot.
Sensor is only unknown on boot with a long delayed_off filter. It keeps unknown, till there is a state change.
I also experimented with on_boot
. Did not solve the problem
on_boot:
priority: 200
then:
- delay: 130s < does not work, with or without delay. always unknown after boot
- lambda: |-
if (id(raining).state) {
id(raining).publish_state(true);
} else {
id(raining).publish_state(false);
}
and also tried with publish_initial_state, did not solve the problem, still unknow after boot when delayed_off
is more than approximately 5sec