esphome:
  name: itlabs1

esp32:
  board: adafruit_feather_esp32s2_tft
  framework:
    type: esp-idf

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: ""

ota:
  - platform: esphome
    password: ""

switch:
  - platform: gpio
    name: "water alert"
    pin: GPIO5

sensor:
  - platform: adc
    pin: A5
    id: plant_0_soil_moisture
    name: "plant_0_soil_moisture"
    attenuation: 11db
    unit_of_measurement: '%'
    filters:
      - lambda: return x *75;

spi:
  clk_pin: GPIO36
  mosi_pin: GPIO35
  miso_pin: GPIO37

display:
  - platform: ili9xxx
    id: my_display
    model: st7789v
    cs_pin: GPIO7
    dc_pin: GPIO39
    reset_pin: GPIO40
    invert_colors: true
    dimensions:
      width: 135
      height: 240
      offset_width: 52
      offset_height: 40
    rotation: 90
    pages:
    - id: page1
      lambda: |-
        it.image(0, 0, id(flowerpot));
        it.image(160, 75, id(itlab25));
        it.printf(3, 3, id(hurmit_regular), "Water level:");
        it.printf(50, 35, id(hurmit_regular), "%.1f %%", id(plant_0_soil_moisture).state);

interval:
  - interval: 5s
    then:
      - display.page.show_next: my_display
      - component.update: my_display

image:
  - file: "flowerpot.png"
    type: rgb
    transparency: alpha_channel
    id: flowerpot
    resize: 135x135
  - file: "itlab25.png"
    type: rgb
    transparency: alpha_channel
    id: itlab25
    resize: 80x80


font:   
  - file: "HurmitNerdFont-Regular.otf"
    id: hurmit_regular
    size: 28
    #glyphs: [
    #  "\u2698", #flower pot
    #]

output:
  - platform: ledc
    pin: GPIO45
    id: screen_led

  - platform: gpio
    pin: GPIO21
    inverted: true
    id: tft_power


light:
  - platform: monochromatic
    output: screen_led
    id: backlight
    name: Backlight
    restore_mode: ALWAYS_ON


wifi:
  #ssid: "Zyxel"
  #password: "12345678"
  ssid: "ITL@bs"
  password: "StStefan202!"
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Itlabs1 Fallback Hotspot"
    password: "qsri9vnu7Y9n"

captive_portal:
    