Skip to content

Instantly share code, notes, and snippets.

@tyeth
Forked from Timo614/funhouse.yaml
Created April 11, 2024 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyeth/35b7cf5ee388a6bdf6d9a05666c3b449 to your computer and use it in GitHub Desktop.
Save tyeth/35b7cf5ee388a6bdf6d9a05666c3b449 to your computer and use it in GitHub Desktop.
Adafruit funhouse esphome starter config
# Thanks to this configuration for the initial legwork https://github.com/kbx81/esphome-configs/blob/main/dev/esp-funhouse.yaml
esphome:
name: funhouse
friendly_name: Funhouse
platformio_options:
board_build.mcu: esp32s2
board_build.variant: esp32s2
esp32:
board: adafruit_funhouse_esp32s2
framework:
type: esp-idf
version: 5.0.2
platform_version: 6.3.2
# type: arduino
# version: 2.0.9
# platform_version: 5.4.0
psram:
speed: 80MHz
esp32_touch:
# setup_mode: true
measurement_duration: 100us
denoise_grade: BIT12
denoise_cap_level: L0
debounce_count: 1
filter_mode: IIR_16
noise_threshold: 0
jitter_step: 0
smooth_mode: IIR_2
# Enable logging
logger:
hardware_uart: USB_CDC
ota:
password: !secret ota_funhouse
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
time:
- platform: homeassistant
id: esptime
timezone: EST+5EDT,M3.2.0/2,M11.1.0/2
i2c:
id: i2c_bus
frequency: 400kHz
scl: 33
sda: 34
scan: false
spi:
- id: spi_lcd
clk_pin: 36
mosi_pin: 35
- id: spi_led
clk_pin: 15
mosi_pin: 14
status_led:
pin: 37
font:
- file: "fonts/Roboto-Regular.ttf"
id: roboto_large
size: 64
- file: "fonts/Roboto-Regular.ttf"
id: roboto_med
size: 28
- file: "fonts/Roboto-Regular.ttf"
id: roboto_metric
size: 22
- file: "fonts/Roboto-Regular.ttf"
id: roboto_small
size: 12
binary_sensor:
- platform: status
name: Status
id: conn_status
on_press:
then:
- display.page.show: page1
- if:
condition:
switch.is_on: auto_dotstar
then:
- light.control:
id: dotstar_light
state: on
effect: None
on_release:
then:
- display.page.show: page2
- if:
condition:
switch.is_on: auto_dotstar
then:
- light.control:
id: dotstar_light
state: on
effect: Random Twinkle
- platform: gpio
id: motion_sense
name: Motion Detection
device_class: motion
pin:
number: 16
- platform: gpio
id: button_input_0
name: Button Up
pin:
number: 5
- platform: gpio
id: button_input_1
name: Button Select
pin:
number: 4
on_press:
- display.page.show: page1
- platform: gpio
id: button_input_2
name: Button Down
pin:
number: 3
on_press:
- display.page.show: page2
- platform: gpio
id: button_input_back
name: Button 0
pin:
number: 0
inverted: true
mode:
input: true
pullup: true
on_press:
- light.toggle: dotstar_light
- platform: esp32_touch
id: touchpad_left
name: Touchpad Left
pin: 6
threshold: 50000
on_press:
- rtttl.play: "alert 1:d=8,o=5,b=160:e"
on_release:
- rtttl.play: "alert 1:d=8,o=4,b=160:a"
- platform: esp32_touch
id: touchpad_center
name: Touchpad Middle
pin: 7
threshold: 50000
on_press:
- rtttl.play: "alert 1:d=8,o=6,b=160:e"
on_release:
- rtttl.play: "alert 1:d=8,o=5,b=160:a"
- platform: esp32_touch
id: touchpad_right
name: Touchpad Right
pin: 8
threshold: 50000
on_press:
- rtttl.play: "alert 1:d=8,o=7,b=160:e"
on_release:
- rtttl.play: "alert 1:d=8,o=6,b=160:a"
- platform: esp32_touch
id: touchpad_slider_a
name: Touchpad Slider A
pin: 9
threshold: 50000
on_press:
- light.turn_on:
id: dotstar_light
brightness: 100%
- platform: esp32_touch
id: touchpad_slider_b
name: Touchpad Slider B
pin: 10
threshold: 50000
on_press:
- light.turn_on:
id: dotstar_light
brightness: 80%
- platform: esp32_touch
id: touchpad_slider_c
name: Touchpad Slider C
pin: 11
threshold: 50000
on_press:
- light.turn_on:
id: dotstar_light
brightness: 60%
- platform: esp32_touch
id: touchpad_slider_d
name: Touchpad Slider D
pin: 12
threshold: 50000
on_press:
- light.turn_on:
id: dotstar_light
brightness: 40%
- platform: esp32_touch
id: touchpad_slider_e
name: Touchpad Slider E
pin: 13
threshold: 50000
on_press:
- light.turn_on:
id: dotstar_light
brightness: 20%
color:
- id: color_heavy_blue
red: 39.2%
green: 58.4%
blue: 92.9%
- id: color_cool_purple
red: 50.2%
green: 0%
blue: 50.2%
- id: color_sea_green
red: 18.0%
green: 54.5%
blue: 34.1%
- id: color_red
red: 100%
green: 0%
blue: 0%
- id: color_yellow
red: 100%
green: 100%
blue: 0%
- id: color_green
red: 0%
green: 100%
blue: 0%
- id: color_blue
red: 0%
green: 0%
blue: 100%
- id: color_gray
red: 60%
green: 60%
blue: 60%
- id: color_white
red: 100%
green: 100%
blue: 100%
- id: elec_cost_color
red: 100%
green: 0%
blue: 100%
light:
- platform: monochromatic
id: lcd_backlight
name: Display Backlight
output: lcd_backlight_pwm
restore_mode: RESTORE_DEFAULT_ON
- platform: spi_led_strip
id: dotstar_light
spi_id: spi_led
data_rate: 40MHz
name: APA102 LEDs
restore_mode: RESTORE_DEFAULT_OFF
num_leds: 5
effects:
- addressable_flicker:
- addressable_color_wipe:
- addressable_rainbow:
- addressable_scan:
- addressable_twinkle:
- addressable_random_twinkle:
- addressable_fireworks:
output:
- platform: ledc
id: lcd_backlight_pwm
pin: 21
channel: 0
# Buzzer output
- platform: ledc
id: rtttl_out
pin: 42
channel: 2
rtttl:
output: rtttl_out
on_finished_playback:
- logger.log: 'Song ended!'
switch:
- platform: template
id: auto_dotstar
name: Auto Light Color
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
on_turn_off:
then:
- rtttl.play: "alert 1:d=16,o=5,b=120:a"
- light.turn_off: dotstar_light
on_turn_on:
then:
- rtttl.play: "alert 1:d=16,o=5,b=120:e6"
- light.turn_on: dotstar_light
- light.turn_on:
id: dotstar_light
effect: Rainbow Effect With Custom Values
number:
- platform: template
id: light_brightness
name: Auto Light Brightness
optimistic: true
min_value: 0
max_value: 1
step: 0.01
initial_value: 0.5
restore_value: true
sensor:
# Phototransistor ADC sensor...can't use with Wi-Fi :(
# - platform: adc
# id: phototransistor
# name: Phototransistor ADC
# pin: 18
# attenuation: 11db
# update_interval: 1s
- platform: aht10
temperature:
id: aht20_temperature
name: AHT20 Temperature
filters:
- offset: -2.0
humidity:
id: aht20_humidity
name: AHT20 Humidity
update_interval: 15s
- platform: dps310
temperature:
id: dps310_temperature
name: DPS310 Temperature
filters:
- offset: -2.6
pressure:
id: dps310_pressure
name: DPS310 Pressure
update_interval: 15s
graph:
- id: temperature_graph
sensor: aht20_temperature
duration: 1h
border: False
color: color_heavy_blue
width: 150
height: 50
- id: pressure_graph
sensor: dps310_pressure
duration: 1h
border: False
color: color_cool_purple
width: 150
height: 50
- id: humidity_graph
sensor: aht20_humidity
duration: 1h
border: False
color: color_sea_green
width: 150
height: 50
display:
- platform: st7789v
id: main_lcd
spi_id: spi_lcd
model: Adafruit Funhouse 240x240
rotation: 180
data_rate: 80MHz
# eightbitcolor: true
# cs_pin: 40
# dc_pin: 39
# reset_pin: 41
update_interval: 1s
pages:
- id: page1
lambda: |-
const uint8_t header_height = 20;
const uint8_t vert_spacing_offset = 45;
const uint8_t vert_center = ((it.get_height() - header_height) / 2) + header_height;
auto logo_color = id(conn_status).state ? id(color_gray) : id(color_red);
it.strftime(6, 6, id(roboto_small), id(color_gray), TextAlign::TOP_LEFT, "%Y-%m-%d", id(esptime).now());
it.strftime((it.get_width() - 6), 6, id(roboto_small), id(color_gray), TextAlign::TOP_RIGHT, "%H:%M:%S", id(esptime).now());
it.print(it.get_width() / 2, 6, id(roboto_small), logo_color, TextAlign::TOP_CENTER, "ESPHome");
it.graph(90, 40, id(temperature_graph));
it.graph(90, 100, id(humidity_graph));
it.graph(90, 160, id(pressure_graph));
it.printf(40, 70, id(roboto_metric), id(color_heavy_blue), TextAlign::CENTER, "%.1f°", id(aht20_temperature).state * 1.8 + 32);
it.printf(40, 130, id(roboto_metric), id(color_sea_green), TextAlign::CENTER, "%.1f%%", id(aht20_humidity).state);
it.printf(40, 190, id(roboto_metric), id(color_cool_purple), TextAlign::CENTER, "%.1f", id(dps310_pressure).state);
it.printf(40, 220, id(roboto_metric), id(color_cool_purple), TextAlign::CENTER, "nhPa");
- id: page2
lambda: |-
const uint8_t header_height = 20;
const uint8_t vert_spacing_offset = 45;
const uint8_t vert_center = ((it.get_height() - header_height) / 2) + header_height;
auto logo_color = id(conn_status).state ? id(color_gray) : id(color_red);
it.strftime(6, 6, id(roboto_small), id(color_gray), TextAlign::TOP_LEFT, "%Y-%m-%d", id(esptime).now());
it.strftime((it.get_width() - 6), 6, id(roboto_small), id(color_gray), TextAlign::TOP_RIGHT, "%H:%M:%S", id(esptime).now());
it.print(it.get_width() / 2, 6, id(roboto_small), logo_color, TextAlign::TOP_CENTER, "ESPHome");
it.printf(it.get_width() / 2, vert_center - vert_spacing_offset, id(roboto_med), id(color_gray), TextAlign::BOTTOM_CENTER, "%.1f hPa", id(dps310_pressure).state);
it.printf(it.get_width() / 2, vert_center, id(roboto_large), id(color_white), TextAlign::CENTER, "%.1f°", id(aht20_temperature).state * 1.8 + 32);
it.printf(it.get_width() / 2, vert_center + vert_spacing_offset, id(roboto_med), id(color_gray), TextAlign::TOP_CENTER, "%.1f%%", id(aht20_humidity).state);
api:
encryption:
key: !secret ota_funhouse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment