Help with ESPHome alarm system

I have built my own alarm system using an esp32 and connecting all my wired sensors to it. It worked perfectly for the past two years, but for the past few months I am getting a very weird behavior happening.

About 20 of my 50 sensors connected to it start continuously triggering on its own, but only happens between around about 7PM and 7AM. During the day, they all work as designed. Herein a screenshot of the trigger history on one of my panic buttons that is only supposed to trigger when the button is pressed.

Also, not all the same sensors that trigger, they are random and there is not set pattern.

Do I have a ghost?

Any help in figuring this out would be appreciated.

Obviously as a first step you carefully observed devices esphome log and found out what?

No

Likely it’s doing what you set it to do and you just don’t realize it.

Checked connection?
Any associated automation?

Here is a sample of the log:

[19:12:51][D][binary_sensor:036]: 'Scullery Motion': Sending state ON
[19:12:52][D][binary_sensor:036]: 'Scullery Motion': Sending state OFF
[19:12:53][D][binary_sensor:036]: 'Scullery Motion': Sending state ON
[19:12:54][D][binary_sensor:036]: 'Scullery Motion': Sending state OFF
[19:12:56][D][binary_sensor:036]: 'Scullery Motion': Sending state ON
[19:12:57][D][binary_sensor:036]: 'Main Bathroom Door': Sending state ON
[19:12:57][D][binary_sensor:036]: 'Main Bathroom Door': Sending state OFF
[19:12:58][D][binary_sensor:036]: 'Scullery Motion': Sending state OFF
[19:13:00][D][binary_sensor:036]: 'Taksheel's Room Right Window': Sending state ON
[19:13:00][D][binary_sensor:036]: 'Taksheel's Room Right Window': Sending state OFF
[19:13:02][D][binary_sensor:036]: 'Scullery Motion': Sending state ON
[19:13:03][D][binary_sensor:036]: 'Scullery Motion': Sending state OFF
[19:13:04][D][binary_sensor:036]: 'Scullery Motion': Sending state ON
[19:13:04][D][binary_sensor:036]: 'Kitchen Motion': Sending state ON
[19:13:05][D][binary_sensor:036]: 'Scullery Motion': Sending state OFF
[19:13:07][D][binary_sensor:036]: 'Kitchen Motion': Sending state OFF
[19:13:08][D][binary_sensor:036]: 'TV Room Right Window': Sending state ON
[19:13:08][D][binary_sensor:036]: 'TV Room Right Window': Sending state OFF
[19:13:11][D][binary_sensor:036]: 'Kitchen Motion': Sending state ON
[19:13:12][D][binary_sensor:036]: 'Kitchen Windows': Sending state ON
[19:13:12][D][binary_sensor:036]: 'Kitchen Windows': Sending state OFF
[19:13:12][D][binary_sensor:036]: 'Scullery Motion': Sending state ON
[19:13:13][D][binary_sensor:036]: 'Scullery Motion': Sending state OFF
[19:13:14][D][binary_sensor:036]: 'Front Door Lock': Sending state ON
[19:13:14][D][binary_sensor:036]: 'Front Door Lock': Sending state OFF
[19:13:14][D][binary_sensor:036]: 'Kitchen Motion': Sending state OFF
[19:13:28][D][binary_sensor:036]: 'Taksheel's Room Right Window': Sending state ON
[19:13:28][D][binary_sensor:036]: 'Taksheel's Room Right Window': Sending state OFF
[19:13:30][D][binary_sensor:036]: 'Kitchen Motion': Sending state ON
[19:13:31][D][binary_sensor:036]: 'Scullery Motion': Sending state ON
[19:13:32][D][binary_sensor:036]: 'Scullery Motion': Sending state OFF
[19:13:32][D][binary_sensor:036]: 'Scullery Motion': Sending state ON
[19:13:33][D][binary_sensor:036]: 'Kitchen Motion': Sending state OFF
[19:13:33][D][binary_sensor:036]: 'Scullery Motion': Sending state OFF
[19:13:51][D][binary_sensor:036]: 'Main Bathroom Door': Sending state ON
[19:13:52][D][binary_sensor:036]: 'Main Bathroom Door': Sending state OFF
[19:14:00][D][binary_sensor:036]: 'Kitchen Windows': Sending state ON
[19:14:00][D][binary_sensor:036]: 'Kitchen Windows': Sending state OFF
[19:14:07][D][binary_sensor:036]: 'Main Bathroom Door': Sending state ON
[19:14:08][D][binary_sensor:036]: 'Main Bathroom Door': Sending state OFF

No errors on the code and no errors on the logs.

How do you have sensors connected to esp (schematic?)? This seem like noise on work… do you have any pull-up or pull-down resistors on inputs? Did you connected any new device (possibly from china - ľike led light etc…) which is causing noise all over…?

But do you see those mentioned " 20 continuously triggering sensors" on your log triggering continuously?

The code is simple as all logic is handled in HA.

As mentioned, the system worked well for over 2 years, and the issue suddenly started. No changes have been done to the system or no new sensors added.

I do not recall adding anything new in the past few months. It however seems logical as this only happens at night when the lights are on and may be causing some disturbance on my panel.

as you can see from the logs, the same sensors keep triggering every few seconds. for example, the windows are all closed, and never trigger during the day. They are hard wired with mag switches.

Are these Gpio binary sensors or some template- or HA binary sensors?

Easy to debug. Turn the lights off. Problem gone?

If you have HA set to trigger when sensor opens and sensor opens because poor connection, noise, esp power fluctuations causing problem or other, it will be doing what you set it to do

It appears from logs the devices are open/closing

You should first verify sensor function properly
Next check connection to esp device
Then check esp device power
And so on

It would also be good to tell us how you physically connected sensor to esp

They are GPIO binary sensors, using I/O extenders.

Not really, as all lights go off when we go to bed, and it still persists, so it could be the actual smart switches. Will try and disconnect all switches on my DB board except the one feeding the alarm, and see it that helps. will have to do it later when all are in bed :grimacing:.

As long as you don’t have disturbance from street lights…
Do you have any filtering on your sensor configuration code?

If that was these issues, they it would happen during the day too. This only happens between 7PM to 7AM.

here is the code for two of the sensors:

binary_sensor:
## Hub 1 ##
  - platform: gpio
    name: "Main Bedroom Motion"
    id: main_bedroom_motion_100
    device_class: motion
    pin:
      pcf8574: pcf8575_hub_1
      number: 0
      mode: INPUT
      inverted: false
    filters:
      - delayed_off: 100ms
  - platform: gpio
    name: "Back Outdoor Motion"
    id: back_outdoor_motion_101
    device_class: motion
    pin:
      pcf8574: pcf8575_hub_1
      number: 1
      mode: INPUT
      inverted: false
    filters:
      - delayed_off: 100ms

Shouldn’t you use delayed on?

filters:
      - delayed_on_off: 100ms

Yep, delayed ON, and at least 100ms, better more( off is not needed, but it doesn’t hurt). Pro alarm panels have as much as 400ms delay. You don’t loose anything, but you can gain a lot.
Second: put some pull-down resistors from input to gnd. If you don’t have them inputs are prone to noise - around 10kohm, even less is good (tecnoalarm pro panel has 2k7). This way you will effectively eliminate noise. IO expanders have usually quite high input pull-up/down resistors (too high if wires to sensors are long).
If thing worked a copule of years i guess you were lucky so far, but not anymore… even some of your neighbours could connect some weird chinese lights which produces enough noise to trigger your inputs. And since it only happens at night this is even more likely.

Here is a picture of my home made board. I used 100k resistors on each. Will change it to delayed_on and try it.

However the issue is resolved. I have an NVR close to the alarm panel, and a few months ago, the video card in the NVR blew up (it still records and can view videos online), but decided to disconnect it completely, and what you know, the sensors no longer trigger. So the blown card on the NVR was causing the noise. :scream: Time for a new NVR! The one I had was a cheap Chinese make. Still don’t understand why it only happens at night. Maybe there is noise around, and the NVR amplified it. :thinking: .

Thank you all for your input, it definitely helped in resolving the issue.

Nice build!
As i expected…noise… (been there…). I’m glad that you found the culprit.
Delayed on will surely help, lower pull resistors would even more, but as i see from picture replacing them is not so easy…
Now that you know what’s causing it you can add delay, turn on nvr again and see if it helps…:stuck_out_tongue_winking_eye:

You are just lucky, you didn’t have problems before.
That delayed on is must on your code.