esphome:
  name: esptank32
  platformio_options:
    board_build.flash_mode: dio

esp32:
  board: esp32-c3-devkitm-1
   
logger:

api:
  password: !secret api_secret

ota:
  platform: esphome
  password: !secret ota_key

wifi:
  ssid:     !secret wireless_ssid
  password: !secret wireless_key
  domain:   !secret wireless_domain

  ap:
    ssid: "ESPtank_Fallback"
    password: !secret ap_secret

captive_portal:

web_server:
  port: 80

time:
  - platform: sntp
    id: sntp_time
    servers: 
      - 193.190.198.10
#    timezone: "Europe/Brussels"
    on_time_sync:
      then:
        - logger.log: "NTP : Synchronized sntp clock"
        
mqtt:
  broker: domotic.home.cabestan.be
  username: espsalon
  password: !secret mqtt_espsalon

i2c: 
  sda: 1
  scl: 0
  scan: true
  frequency: 300kHz
  id: bus_a

ads1115:
  - address: 0x48

sensor:
  - platform: ads1115
    multiplexer: 'A0_GND'
    gain: 6.144
    name: "ADS1115 Channel A0"
    id: ads0
    update_interval: 5s
    on_value:
      then:
        - component.update: waterlevel
        - component.update: waterpercent
        - component.update: watervolume
    filters:
        - sliding_window_moving_average:
            window_size: 30
            send_every: 10
    # 0.74 volts à vide.
    # 2.8 volts plein.
    # linéaire
    
  - platform: template
    name: water level
    id: waterlevel
    lambda: return  ( id(ads0).state - 0.74 ) * 0.9;
    icon: "mdi:arrow-expand-vertical"
    unit_of_measurement: "m"
    accuracy_decimals: 2

  - platform: template
    name: water percent
    id: waterpercent
    unit_of_measurement: "%"
    icon: "mdi:water-percent"
    accuracy_decimals: 0
    lambda: return ( id(ads0).state - 0.74 ) * 0.9 / 2.0 * 100;

  - platform: template
    name: water volume
    id: watervolume
    unit_of_measurement: "l"
    icon: "mdi:gauge"
    lambda: return ( id(ads0).state - 0.74 ) * 0.9 / 2.0 * 5000.0;
    accuracy_decimals: 0



