Hi all,
I am looking for a way to determine the length of a pulse using ESPHome, which will determine the state of a device. The device is a gate motor. It offers an output on/off circuit that does the following:
- No pulse: The gate motor is either completely off OR gate is closed and running on battery backup
- Short pulse: A short pulse, less than 500ms roughly about every 1 to 2 seconds, means the gate power is good and the gate is closed
- Longer pulse: More than 500ms, roughly every second, means the gate is either opening or closing
- On: The circuit is on, means the gate is open
I want to derive only three states from the gate; No or short pulse -> Gate Closed. Longer pulse -> Gate opening/closing, On -> Gate is open.
Seems an obvious problem to solve, but I have no idea how to do this in ESPHome. At the moment I’ve defined a binary input with an input filter of 500ms. So I get an open/close/open/close for the opening and closing cycle, or I get an open if the gate is open. It works, but its not ideal, because I would prefer to have a state that specifically represent 1) closed, 2) opening/closing and 3) open.