Noise/Sound Detection

I’m trying to create noise detection system that I can leave plugged in remotely, connected over wifi to detect when noise is over a certain threshold. Just a simple yes, no, unavailable flag is all I need. I don’t care about the dB level or anything specific.

To do this at the moment I am using an old android phone with IPWebcam installed and running over IP to my homeassistant server and added as a ffmpeg_noise custom platform into the configuration. When noise is detected it sends a notification to my phone.

configuration.yaml

ffmpeg:
  
binary_sensor:
  - platform: ffmpeg_noise
    name: "Pixel5a"
    input: http://192.168.1.22:8080/audio.wav
    extra_arguments: -nostats
    peak: -40

#restarts ffmpeg if "unvailable"
- switch:
  - turn_on:
    - target:
        entity_id:
        - automation.restart_ffmpeg_noise_if_unavailable_new
      action: automation.turn_on
    - target:
        entity_id:
        - automation.restart_ffmpeg_noise_if_unavailable_new
      action: automation.trigger
    turn_off:
    - target:
        entity_id:
        - automation.restart_ffmpeg_noise_if_unavailable_new
      action: automation.turn_off
    default_entity_id: switch.ffmpeg_auto_restart
    name: FFmpeg Auto Restart
    state: '{{ is_state(''automation.restart_ffmpeg_noise_if_unavailable_new'', ''on'')
      }}'

I use it for when I’m in my office or gaming at night to ensure that I don’t miss it if one of my kids makes a noise (2.5 and 4 years old, so old enough to not need a proper baby monitor setup anymore, but young enough that I want to hear if they’re upset)

The problem with my current setup is that it is incredibly flakey and I assume by nature of using ffmpeg fairly “heavy”. It often becomes unavailable, or just disconnects without flagging, or gets stuck detected or clear. I’ve basically totally lost faith in it and just want to make a better system. I just had a play with the IPWebcam integration but it doesn’t seem to be exposing the sound sensor and seems to be a bit flakey as well with unavailable indications popping up.

From what I see online and from Gemini, it’s pushing me towards ESPHome and a microphone. Is this a workable solution, or is there something easier? Something standalone from Tuya/Aliexpress for example? Or just a better integration? ONVIF integration appears to expose a lot of sensors, will try that when I get home as well.

The simplest thing to make would be an ESPHome device triggered by a GPIO input attached to something like this:

https://www.aliexpress.com/item/32607737910.html

Adjustable threshold on the device - - although it would be nicer if you could adjust the threshold from HA. Devices with Modbus / TTL outputs are available but considerably more expensive and harder to code.

Thanks for the suggestion! Looks like exactly what im after.

In the meantime I did get my ipcamera working a bit better. The integration does expose a sound sensor when you configure the app correctly and it seems a lot more consistent and controllable than my older ffmpeg solution.

I want to do something similar with sound detection above a threshold. I have a big-ish (music) jam room and I built a WLED clock for the wall. I only want the clock on if we’re jamming so I built an automation. I have a PIR sensor in the corner of the room but it only reaches about a quarter of the way into the room. What I’d really like is to detect if there is noise above a threshold from the room – then keep the clock on.

It surprises me that we have microphone definitions in ESPHome but there is no way to create a stream to monitor and describe a binary_sensor that goes true if the microphone’s stream hits a threshold. The hardware solution suggested by Daryl is definitely a possibility but I am not a fan of using a hardware threshold (pot), I’d rather have something I can tune with software over time using collected data.

Not very familiar with sound detection, but wouldn’t this work for you? At the very least it looks like it provides enough data for you to template a binary sensor on.

YES! Thank you!!

I don’t know why I couldn’t find that… I was looking at the Microphone Components - ESPHome - Smart Home Made Simple and there’s no quick-link to the Sound Level Sensor - ESPHome - Smart Home Made Simple page.

Seems like just the solution I was looking for! I’m going to give it whirl!