Does anyone has a very simple working YAML code to start with Lilygo T-display.
I received my unit and I would like to load, using Esphome, a very basic code to start learning.
For example a code that would display a Home Assistant entity and that I can turn ON/Off using the button on the device.
there are a bunch of different versionā¦ T-Display S3, T-Display-s3-OLED. For the plain T-Display, here is mine to get you started:
esphome:
name: "19-case-1"
friendly_name: 1.9 case 1
esp32:
board: esp32dev
framework:
type: arduino
deep_sleep:
# run_duration: 5min
id: deepsleep
esp32_ext1_wakeup:
mode: ALL_LOW
pins:
- number: 0
allow_other_uses: true
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "****"
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esphome-Web-3D6B80"
password: "GD2UrQDWBaz4"
# Include custom fonts
font:
- file: "gfonts://Roboto"
id: roboto
size: 42
sensor:
- platform: adc
name: "19-case-1 Battery Raw"
pin: 34
attenuation: 11db
id: "VCC"
update_interval: 10s
internal: false
entity_category: diagnostic
- platform: template
name: "19-case-1 Battery"
id: "vccp"
unit_of_measurement: '%'
update_interval: 10s
entity_category: diagnostic
lambda: |-
return ((id(VCC).state / 2.47) * 100);
binary_sensor:
- platform: homeassistant
id: kitchenfp2
entity_id: binary_sensor.kitchen_fp2_presence_sensor_2
- platform: homeassistant
id: kitchenhue
entity_id: binary_sensor.kitchen_hue_motion_sensor_motion
- platform: homeassistant
id: motiongroup
entity_id: binary_sensor.kitchen_motions
- platform: homeassistant
id: lrfp2
entity_id: binary_sensor.living_room_fp2_presence_sensor_3
- platform: gpio
pin:
number: GPIO0
inverted: true
allow_other_uses: true
mode:
input: true
pullup: true
name: "19-case-1 Button 1"
id: tdisplay_button_input_1
on_click:
then:
# - light.turn_on: back_light
- platform: gpio
pin:
number: GPIO35
inverted: true
name: "19-case-1 Button 2"
id: tdisplay_button_input_2
on_click:
then:
- deep_sleep.enter
# - light.turn_off: back_light
output:
- platform: ledc
pin: 4
id: gpio_04_backlight_pwm
light:
- platform: monochromatic
output: gpio_04_backlight_pwm
name: "Display Backlight"
id: back_light
restore_mode: ALWAYS_ON
# Define colors
color:
- id: color_text
red: 100%
green: 0%
blue: 0%
white: 0%
# Pins for Board
spi:
clk_pin: GPIO18
mosi_pin: GPIO19
# render on the screen.
display:
- platform: st7789v
id: shottimer_display
cs_pin: GPIO5
dc_pin: GPIO16
reset_pin: GPIO23
backlight_pin: no
model: TTGO TDisplay 135x240
update_interval: 1s
rotation: 90Ā°
lambda: |-
if (id(kitchenfp2).state) {
it.print(0, 0, id(roboto), color_text,TextAlign::TOP_LEFT, "K FP2");
} else {
it.print(0, 0, id(roboto), color_text,TextAlign::TOP_LEFT, "");
}
if (id(kitchenhue).state) {
it.print(it.get_width(), 0, id(roboto), color_text,TextAlign::TOP_RIGHT, "K M");
} else {
it.print(it.get_width(), 0, id(roboto), color_text,TextAlign::TOP_RIGHT,"");
}
if (id(motiongroup).state) {
it.print(0, 135, id(roboto), color_text,TextAlign::BOTTOM_LEFT,"K G");
} else {
it.print(0, 135, id(roboto), color_text,TextAlign::BOTTOM_LEFT,"");
}
if (id(lrfp2).state) {
it.print(it.get_width(), 135, id(roboto), color_text,TextAlign::BOTTOM_RIGHT, "LR FP2");
} else {
it.print(it.get_width(), 135, id(roboto), color_text,TextAlign::BOTTOM_RIGHT, "");
}
it.printf(it.get_width()/2, it.get_height()/2, id(roboto), color_text,TextAlign::CENTER, "%.1f", id(VCC).state / 2.47 * 100);
captive_portal:
```
Thank you very much, this look very good to get me started
Iāve been trying to figure out how to load above code into my ESP32 to get started with ESPhome and Home assistant but searching has not helped as to how to go about it.
Iām successfully running Home Assistant in Docker. ESPHome has been installed and ESP32 connects and Iām able to able to āPREPARE DEVICE FOR FIRST USEā in web interface then successfully āConfigure Wi-Fiā. After this, Home Assistant notifies me of new device which then I configure and everything seems to work fine. But after this I have no clue as to where to go from here for custom code like the one above. Can someone please point me in the right direction. I been at this for days and just canāt figure it out.
It should be visible in the ESP-Home addon of Home Assistant.
Do you have that installed?
I gave up running HA in Docker. This was causing me all sorts of issues due to software limitations. Iām running it in a virtual machine now and ESPHome works as it should.