Help needed with Smoke detector to ESP home

I’ve together a very basic Home Assistant smoke alarm from an old 9v one and a D1 mini but I’m having trouble with the yaml.

I’ve simply connected a wire from the red wire on the piezo alarm through a 100k resistor to the centre pin on a 2N3904 transistor. The other 2 legs go to D5 and GND on the D1 Mini.

Everything works, and I get an alert when it goes off (with an automation in Home Assistant) but I get continuous alerts as each beep is sending another alert to home assistant. I’m sure there’s an easy way to get the ESP home to send one alert until the beeping pulses end. I just don’t know how. Can anyone please assist?

Here is my yaml.

substitutions:
  name: "smoke-alarm"
  friendly_name: Smoke Alarm

esphome:
  name: ${name}
  friendly_name: ${friendly_name}
  name_add_mac_suffix: false
  project:
    name: esphome.web
    version: '1.0'

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:

# Allow Over-The-Air updates
ota:

# Allow provisioning Wi-Fi via serial
improv_serial:

wifi:
  # Set up a wifi access point
  ap: {}

# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:

binary_sensor:
  - platform: gpio
    name: “Studio Smoke Alarm"
    id: studio_smoke_alarm
    device_class: power
    pin: 
      number: GPIO14
      inverted: true
      mode:
        input: true
        pullup: True
    filters:
      - delayed_on: 10ms
      - delayed_off: 1000ms

1 Like

You just need to increase your delayed_off time to be slightly greater then the gap between the beeps.

2 Likes

Please be careful and thoughtful about safety for your use case.

Also change your smoke detectors regularly as the detection mechanism degrades over time - specially in dusty environments (e.g. workshops) the devices hardly work the advertised 10 years…

Very nice! How do you power the setup?

1 Like

At the moment a USB fits in the back of the detector. I’m considering a 12v supply with a couple of these to power both the D1 and the alarm so as to avoid flat battery pips coming as an alert and sending me into a panic.
https://www.aliexpress.com/item/1005006100242276.html?

1 Like

I started with this, but I really wanted battery backup for the esp32. However, getting that into a junction box without risking burning the house down was rather difficult.

Instead a created a pair of toslink boxes. One for the hardwired smoke alarm junction box with a 5v ldo, a 250V/80mA fuse, and a toslink transmitter. The other box has a toslink receiver wired directly to an esp32 that I can power from a system that is already battery backed.

I then run the fiber optic toslink cable out of the junction box without worry that it will some how become live. I modified the yaml slightly to have device_class: smoke.

Wow, do you have so many smoke events you need this in HA?

I believe I have had fewer than 5 events in the many decades I have had a house. I have the Nest ones currently and will likely go back to the basic BRK ones in the next year or so, when I need to replace mine.

Wow Nice work. A toslink smoke detector is pretty wild.
I must update my device_class too.

Wow, do you have so many smoke events you need this in HA?
In my case I have a studio 150m from the house with a 1979 JH636 recording console full of tantalum capcitors that tend to ignite. If I wander off I wanna know if things are burning :slight_smile:

1 Like

The main purpose is to know if they are going off while I am not at home.