ESPHome GPIO Touch Sensor as Capacitive Input for Waterlevel

Calibrate linear or polynomial filter should work to map reading to level percent. This would let calibration be adjustable via yaml config. Otherwise you could write a function to map reading to the percent and pass that to publish_state()

publish_state(-0.0022*reading*reading*reading + 0.2778*reading*reading - 11.889*reading + 193.33);

Below sample uses a lambda call that will get the raw value from the esp32 touch binary sensor and returns it in a template sensor (as an alternative to your custom component).

esphome:
  name: capacitive-level-test

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable Home Assistant API
api:

logger:
  baud_rate: 115200

ota:
  password: !secret esp_home_ota_pw

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  
# Sync time with Home Assistant.
time:
  - platform: homeassistant
    id: homeassistant_time

esp32_touch:
  setup_mode: false

binary_sensor:
  - platform: esp32_touch
    #name: "ESP32 Touch Pad GPIO27"
    pin: GPIO27
    threshold: 1000
    id: capacitive_level_hack

sensor:
  - platform: template
    name: "Water Level"
    icon: mdi:car-coolant-level
    update_interval: 1s
    lambda: |-
      return (float) id(capacitive_level_hack).get_value();
    filters:
      - calibrate_linear:
        - 20.0 -> 100.0
        - 2080.0 -> 0.1