esphome:
name: xx-789a6b
friendly_name: xx_789a6b
esp8266:
board: d1_mini
# Enable logging
logger:
level: info
# Enable Home Assistant API
api:
encryption:
key: "hash"
reboot_timeout: 0s
services:
- service: beep_code
variables:
repeat_count: int
delay_ms: int
then:
- script.execute:
id: beep_code
repeat_count: !lambda return repeat_count;
delay_ms: !lambda return delay_ms;
on_client_disconnected:
then:
- script.execute: failsafe_mode
ota:
password: "hash"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "xx-789A6B Fallback Hotspot"
password: "hash"
reboot_timeout: 0s
use_address: static
captive_portal:
sensor:
- platform: uptime
name: "uptime"
output:
- platform: gpio
pin: D7
id: buzzer
switch:
- platform: restart
name: "restart"
- platform: gpio
pin: D5
icon: mdi:engine
id: relay1
name: "motor_pump"
binary_sensor:
- platform: gpio
pin:
number: D1
inverted: true
mode:
input: true
pullup: true
filters:
- delayed_on_off: 1s
id: switch1
name: "motor_pump_switch"
on_press:
then:
- switch.turn_on: relay1
on_release:
then:
- switch.turn_off: relay1
on_state:
then:
- script.execute:
id: beep_code
repeat_count: 1
delay_ms: 150
script:
- id: beep_code
parameters:
repeat_count: int
delay_ms: int
then:
- repeat:
count: !lambda return repeat_count;
then:
- output.turn_on: buzzer
- delay: !lambda return delay_ms;
- output.turn_off: buzzer
- delay: !lambda return delay_ms;
- id: failsafe_mode
then:
- if:
condition:
and:
- switch.is_on: relay1
- binary_sensor.is_off: switch1
then:
- switch.turn_off: relay1
- script.execute:
id: beep_code
repeat_count: 3
delay_ms: 150
commit
critical heavy appliance (ex. motor pump, submersible) need to control with safety measure.
feature
1.manual control (work without any connectivity)
2.failsafe mode (device turn off in case of connection lost)
schematic
- binary gpio connected to standard ac switch (switch_pin0 ~ gnd, switch_pin1 ~ binary gpio)
- relay gpio connected to ssr or mechanical relay (preffer ssr for stability)
- buzzer gpio connected to 5v buzzer (active buzzer)