Making a distinction between two signals

For an intercom based doorbell detector that’s capable of automatic opening the central door of the building, I need to distinguish two types of signals:

  • front door of the appartment
  • central intercom of the building

I already designed the circuit (using a opto-coupler and reading the signal to the door chime) and i’m able to detect when the front door button / central door of the building is pressed.

For now, I just let esphome detect a low signal on pin d2 (active low) by using the binary sensor.

  - platform: gpio
    pin: 
      number: D2
      inverted: true
    name: "Deurbel"
    device_class: sound
    filters:
      - delayed_off: 1500ms

This is working great and without any delay.

next step: distinguish between two signals
I measured the signals of the central door of the building and front door of my appartment.

Main differences:

  • Central door signal duration is +/- 453 ms , while front door signal duration is +/- 905 ms
  • Central door signal has 480 rising pulses, while front door signal has 1000 rising pulses
  • Central door signal sometimes has a longer pulse, while frond door signal has equal pulse length everywhere.

ESP Home challenge: detect difference
Now on to my main question:

Does somebody knows a good way of letting esphome making a distinction between these two signals?
If making the code myself, I would have used an interrupt and count pulses, but i’m not sure what the best way is to do it in ESPhome.

I am thinking about some different possibilities:

Option 1: if signal on pin D2 is > 460ms , front door bell (appartment) is pressed. If signal on pin d2 <= 460ms, central door is pressed. Perhaps something with a timer and a lambda?
Option 2: using the pulsecounter, count all rising edges . Problem with this: more delay due too the way the pulsecounter works.
Option 3: using raw ir code in esphome to detect the two signals

Someone with good ideas or other good options to do make a distinction in esphome between these two signals?

Ok guys,

I found a good solution that is simple and doesn’t add too much latency.

I used option 3 from my list, with the default 1KB buffer. The 1KB buffer doesn’t get the full signal (only 999 signed integers), but that doesn’t matter for my purpose. This way latency is kept low enough for my purpose.

If anyone needs to decode signals in the future, you can use the remote_receiver component (Remote Receiver — ESPHome), and use the raw protocol.

My yaml file:

remote_receiver:
  pin: D2
  #dump: raw

binary_sensor:
  - platform: remote_receiver
    name: "Front Door"
    device_class: sound
    raw:
      code: [-504, 519, -504, 520, .... ,400, -387, 400, -387]
    filters:
      - delayed_off: 1500ms
  - platform: remote_receiver
    name: "Central Door"
    device_class: sound
    raw:
      code: [-492, 527, -502, ...... , 519, -505, 519]
    filters:
      - delayed_off: 1500ms