scripts/cardputer

206 lines
4.7 KiB
Plaintext

esphome:
name: m5cardputer
friendly_name: M5Cardputer
esp32:
board: esp32-s3-devkitc-1
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
- platform: esphome
password: "wifipassword"
esp32_ble_tracker:
scan_parameters:
active: true
wifi:
ssid: "DNTD"
password: "wifipassword"
fast_connect: True
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "M5Cardputer Fallback Hotspot"
password: "wifipassword"
captive_portal:
text_sensor:
# Current weather condition from Home Assistant
- platform: homeassistant
id: mom_state
entity_id: person.mom # The entity_id for weather condition
internal: true
binary_sensor:
- platform: gpio
pin:
number: GPIO00
inverted: true
name: Button
id: btn
on_press:
then:
- logger.log: "Button Pressed"
- delay: 500ms
- if:
condition:
# Check if the button is still pressed after 500ms (for double-tap detection)
binary_sensor.is_on: btn
then:
- logger.log: "Double Tap Detected"
- homeassistant.service:
service: logbook.log
data:
name: "M5Cardputer"
message: "Double Tap Detected"
entity_id: binary_sensor.btn
else:
- logger.log: "Single Tap Detected"
- homeassistant.service:
service: logbook.log
data:
name: "M5Cardputer"
message: "Single Tap Detected"
entity_id: binary_sensor.btn
i2s_audio:
i2s_lrclk_pin: GPIO43
i2s_bclk_pin: GPIO41
color:
- id: color_white
red: 100%
green: 100%
blue: 100%
microphone:
- platform: i2s_audio
id: external_mic
adc_type: external
i2s_din_pin: GPIO46
pdm: true
media_player:
- platform: i2s_audio
id: media_out
name: ESPHome I2S Media Player
dac_type: external
i2s_dout_pin: GPIO42
mode: mono
output:
- platform: ledc
pin: GPIO38 # Same pin as backlight
id: backlight_output
frequency: 50 Hz
inverted: false
light:
- platform: monochromatic
name: "Backlight"
output: backlight_output # Link to the correct output component
id: backlight
restore_mode: RESTORE_AND_ON
gamma_correct: 2.8
default_transition_length: 1s
flash_transition_length: 0s
disabled_by_default: False
- platform: neopixelbus
type: GRB
variant: sk6812
restore_mode: RESTORE_AND_ON
pin: GPIO21
num_leds: 1
name: "Cardputer LED"
effects:
- pulse:
- pulse:
name: "Fast Pulse"
transition_length: 0.5s
update_interval: 0.5s
min_brightness: 0%
max_brightness: 100%
- pulse:
name: "Slow Pulse"
transition_length: 500ms
update_interval: 2s
- pulse:
name: "Asymmetrical Pulse"
transition_length:
on_length: 1s
off_length: 500ms
update_interval: 1.5s
- random:
name: Random Effect With Custom Values
transition_length: 5s
update_interval: 7s
- strobe:
name: Strobe Effect With Custom Values
colors:
- state: true
brightness: 100%
red: 100%
green: 90%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- flicker:
name: Flicker Effect With Custom Values
alpha: 95%
intensity: 3.3%
spi:
clk_pin: GPIO36
mosi_pin: GPIO35
miso_pin: GPIO39
display:
platform: ili9xxx
model: st7789v
cs_pin: GPIO37
dc_pin: GPIO34
reset_pin: GPIO33
rotation: 90
invert_colors: true
lambda: |-
// Set background color to black for better contrast
Color text_color = id(color_white); // Set text color to white
// Display the current time
it.strftime(49, 70, id(roboto_20), text_color, TextAlign::BASELINE_LEFT, "%l:%M", id(sntp_time).now());
// Print "NO U" at the top of the screen
it.print(49, 80, id(roboto_20), text_color, "Your slut is at:");
it.print(49, 110, id(roboto_20), text_color, id(mom_state).state.c_str());
font:
- file: "gfonts://Roboto"
id: roboto_20
size: 16
#keypress
# Define the time component
time:
- platform: sntp
id: sntp_time
timezone: "America/Chicago" # Change to your timezone