Hello, I’m looking to implement deep sleep for an ESP8266 with ESPhome to control a fan. I don’t need it to be using power all the time unless it’s reporting back temperature sensor values or when a button is pressed.
substitutions:
name: esphome-web-3070ac
friendly_name: Vent
esphome:
name: ${name}
friendly_name: ${friendly_name}
min_version: 2024.6.0
name_add_mac_suffix: false
project:
name: esphome.web
version: dev
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: WZIIl3yawMBlaiu8LdtVUqOL7gDq74lQxivRIh8vhhw=
# OTA updates with password
ota:
- platform: esphome
password: !secret ota_password
# Allow provisioning Wi-Fi via serial
improv_serial:
# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:
# To have a "next url" for improv serial
web_server:
version: 3
port: 80
auth:
username: !secret web_server_username
password: !secret web_server_password
dashboard_import:
package_import_url: github://esphome/example-configs/esphome-web/esp32.yaml@main
import_full_config: true
wifi:
# Set up a wifi access point
ap:
ssid: !secret ap_ssid
password: !secret ap_password
# Define the Neopixel light
light:
- platform: neopixelbus
name: "d9cd470a-163a-4f5f-b9fa-8abe6e945412"
icon: "mdi:wall-sconce-round-variant"
type: GRB
variant: WS2812
pin: 3
num_leds: 1
id: ws2812_indc_light
restore_mode: ALWAYS_OFF
default_transition_length: 1500ms
web_server:
sorting_weight: -1
# Define the SPI bus
spi:
miso_pin: 12
clk_pin: 15
# Define the SPI sensor
sensor:
- platform: max6675
name: "Temperature"
icon: "mdi:thermometer"
id: stove_temp
cs_pin: 13
update_interval: 60s
web_server:
sorting_weight: 5
# Define the binary sensors
binary_sensor:
- platform: gpio
pin:
number: 0
mode: INPUT_PULLUP
inverted: true
id: light_switch
name: "Light"
icon: "mdi:lightbulb"
web_server:
sorting_weight: 3
on_press:
then:
- switch.toggle: light_relay
- platform: gpio
pin:
number: 2
mode: INPUT_PULLUP
inverted: true
id: fan_switch
name: "Vent Fan"
icon: "mdi:fan"
web_server:
sorting_weight: 1
on_press:
then:
- script.execute: switch_indc_aesthetics
# Define the GPIO switches
switch:
- platform: gpio
pin: 4
id: fan_relay
name: "Vent Relay"
icon: "mdi:fan"
web_server:
sorting_weight: 2
- platform: gpio
pin: 5
id: light_relay
name: "Light Relay"
icon: "mdi:light"
web_server:
sorting_weight: 4
# Define the script for toggling the light
script:
- id: switch_indc_aesthetics
then:
- if:
condition:
switch.is_on: fan_relay
then:
- light.turn_off:
id: ws2812_indc_light
transition_length: 600ms
- delay: 700ms
- switch.toggle: fan_relay
else:
- light.turn_on:
id: ws2812_indc_light
transition_length: 400ms
brightness: 100%
red: 100%
green: 45%
blue: 100%
- delay: 700ms
- switch.toggle: fan_relay