captive_portal:
web_server:
port: 80
version: 3
# Grabs the IP address for the boot message
text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
id: ip_address
rtttl:
output: buzzer_pwm
id: doorbell_chime
# Add a template component alongside your GPIO pin
binary_sensor:
- platform: gpio
pin:
number: GPIO14 # D5 on NodeMCU
mode: INPUT_PULLUP
inverted: true
name: "Doorbell Physical Button"
# When physically pressed, toggle our master virtual sensor
on_press:
- binary_sensor.template.publish:
id: doorbell_master
state: ON
- delay: 500ms
- binary_sensor.template.publish:
id: doorbell_master
state: OFF
filters:
- delayed_on: 50ms
# This is the master entity Home Assistant will watch.
# It acts exactly like your old buttonPressed global flag.
- platform: template
name: "Doorbell Button"
id: doorbell_master
on_press:
then:
- logger.log: "Doorbell Triggered! Playing Chime..."
# Plays a crisp "Ding-Dong" tone
# e6 = Ding (High note), c6 = Dong (Low note)
- rtttl.play: "dingdong2:d=4,b=120:e6,2c6,p,e6,2c6"
# Exposed to Home Assistant as clickable Button entities
button:
- platform: restart
name: "Restart Doorbell"
- platform: template
name: "Test Doorbell Press"
# Clicking PRESS in the WebUI now triggers this exact same master sensor
on_press:
- logger.log: "WebUI Test Button Pressed!"
- binary_sensor.template.publish:
id: doorbell_master
state: ON
- delay: 500ms
- binary_sensor.template.publish:
id: doorbell_master
state: OFF
# Status LED Configuration (Blinks every 5 seconds to show it's alive)
output:
- platform: gpio
pin:
number: GPIO2 # LED_BUILTIN (active low)
inverted: true
id: builtin_led
- platform: esp8266_pwm
pin: GPIO12 # D6 on NodeMCU
id: buzzer_pwm
interval:
- interval: 10s
then:
- output.turn_on: builtin_led
- delay: 25ms
- output.turn_off: builtin_led