Hi guys.
First Thanks to @parrel for sharing this excellent project and for the perfectly working yaml.
I used the exact same rain sensor, but instead of the Zigbee door switch, I used an esp8266 board (main powered), because my Zigbee network is quite busy (over 100 devices) and would certainly miss some pulses.
I flashed it with EspHome, connecting the pin 2 and 3 (from the RJ11 original wire) to GPIO12 and GND.
As it was working perfectly on the breadboard, when manually moving the sensor with my fingers, I soldered a quick PCB with a RJ11 female connector, and moved it outside…
BUT Making further tests by pouring the sensor with water, … did not worked !!! ![]()
While the esphome correctly logged each flip , they were NEVER received by HA. ![]()
After hours (days) of trying to figure what the problem was, I finnally found the reason and thus the cure. ![]()
The sensor is making a very short pulse (On state) before reverting to off state. And it seems that in this case, Esphome never send the ON state (while it correctly see it) when it is quickly followed by the Off state (certainly to not overload the network)
So for anyone wanting to use an EspHome device, here is the final configuration that works:
binary_sensor:
- platform: gpio
name: "Pulse"
id: pulse
icon: mdi:water-outline
pin:
number: GPIO12
inverted: true
mode:
input: true
pullup: true
filters:
- delayed_off: 120ms # if too short, on state is logged but NOT sent to HA
# the following optionnal part is used to blink the onboard led ###
on_press:
then:
- logger.log: "--- Flip ------"
- switch.turn_on: board_led
on_release:
then:
- switch.turn_off: board_led
This part is the cure (it delays sending the off state by 120ms, after an On state) :
filters:
- delayed_off: 120ms
BTW in this case we are tracking the “on” state in the “rain flip” sensor:
- platform: history_stats
name: Rain Flips
entity_id: binary_sensor.rain_pulse
state: 'on' # <-------- instead of 'off'
type: count
start: '{{ now().replace(hour=0, minute=0, second=0) }}'
end: '{{ now() }}'
An thus we dont have any fake increments when HA restarts
HTH ![]()



