Detect sliding gate state

Hi all, I’m trying to report the status of a sliding gate to home assistant.
The gate controller report it’s status on a “signal lamp” that is off when the gate is closed, on when the gate is open or opening and flashing with a frequency of about 1 flash/sec when closing.

It seems easy to detect on/off but how can I detect the flashing ? I’ve thought to use an esp8266 GPIO (in a sonoff basic) with esphome and maybe the Pulse Width Sensor, but it seems more suited to much higher frequency than 1Hz or simply on/off static status, do you believe this is possible with esphome ?

Thanks in advance

Use an analogue input to measure the voltage (via appropriate voltage divider resistors) at the lamp.

Low-pass filter the input voltage heavily.

On = V
Moving = V/2 (assuming the flash duty cycle is 50%).
Off = 0

This will slow down the responsiveness a bit though.

but that would need me to reach the analog input on the sonoff basic I’m using,and if I remember correctly the ADC pin is not broken out on that board. Or is somehow possible to reconfigure a GPIO to be an analogue input ?

Ah you tricked me with the ESPHome category. I assumed a NodeMCU type board (I did not read close enough). Disregard the suggestion.

The pulse width sensor should work.

How are you preventing the gate binary sensor from going open/closed/…/open/closed when the the gate is closing?

A delay_off of a bit over a second should do it.

Thank you again, where is that delay_off documented ? I’ve looked at https://esphome.io/components/sensor/pulse_width.html and https://esphome.io/components/sensor/index.html#config-sensor but it is not mentioned :frowning:

I’m pretty new to ESPHome so maybe I’m missing something really obvious

Assuming however that the pulse width is the right path, I’d better show off what the problem is.
It seems that this sensor just outputs a number of seconds each time that the configured GPIO pin toggle on/off.
But how can I use that number to determine Open/close/closing (1Hz flashing) ?
Is there also a way to report the pin status ?

image

Binary sensor filters for delay_off: https://esphome.io/components/binary_sensor/index.html#binary-sensor-filters

Though if you’re using that binary sensor to feed your pulse width sensor, it will prevent it from working. The sensor will no longer detect flashing if you set delay off to > 1 sec.

I’m thinking the lamp may not be the way to go. Can you access other places to sense?

Limit switches or motor relay for example?

Oh ok I see, thanks for the link.
Motor works at 220v but the driving relay works at 24v, pretty easy to hook up but of course it can’t give anything about gate status.

There are two magnetic limit switches, the magnet is fixed on the sliding gate and the sensors are are directly soldered in the gate control board, and I’d rather not mess up with them, since are really tiny and it’s easy to let some drop of solder near them.

However I believe I can add two other magnetic sensor and near those two and use them: if both contact are open then the gate is opening or closing otherwise is either open or closed.

If you believe that the lamp is not the way to go I can try this path, adding two magnetic sensors

This would be much easier.

Just not too close. You don’t want the magnets interfering. You can actually convert an NC reed switch to an NO read switch by using two magnets :slight_smile:

Ok, thanks for your input! I just have to carefully check the space inside for the two reed but that seems way easier. :slightly_smiling_face:
Thanks!

Thanks for the insightful thread. I’m surprised there is not a more elegant way to address this and to do it directly from the gate status led/output that presents itself on most gate control boards. Most gates I know work on a similar principal - normally off when closed, on when open and flashing when opening or closing. Some also have a short, long interval flash when closed, to indicate that the power is good. Fitting sensors to an existing gate setup is not a simple job, especially for swing gates.

Stumbled across this thread hoping there might be some alternate solutions to mine for a double swing gate.

I have 2 swing gates with a crescent type driveway with each having infrared sensors to avoid collision, installed by previous owner.

The control boards have the courtesy/flashing light option which I thought I might use aswell, but ended up installing an actual courtesy light as I have multiple devices with gate control an wanted to alert anyone that the gate is moving. Each gate can be viewed on its own camera.

Settled on using the electric lock option that outputs 0v or 24v after a close cycle has finished.

Using a handy 24v relay as i had nothing else on hand I was able use the output to switch the relay on/off to get myself an input signal.

Very makeshift but works as intended

Using a 24V to 3.3V Optocoupler Isolator would be the option

Hope this helps someone