esphome:
  name: flower-watering
  friendly_name: Flower Watering
  comment: Single-plant manual timed watering prototype
  on_boot:
    priority: 600
    then:
      - switch.turn_off: pump
  on_shutdown:
    then:
      - switch.turn_off: pump

esp8266:
  board: d1_mini

logger:

api:
  encryption:
    key: !secret api_encryption_key

ota:
  - platform: esphome
    password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  ap:
    ssid: "Flower Watering Fallback"
    password: !secret fallback_ap_password

captive_portal:

web_server:
  port: 80
  version: 3

sensor:
  - platform: adc
    pin: A0
    id: soil_moisture_raw
    name: "Soil Moisture Raw"
    raw: true
    unit_of_measurement: "ADC counts"
    device_class: ""
    accuracy_decimals: 0
    update_interval: 10s
    entity_category: diagnostic

  - platform: wifi_signal
    name: "Wi-Fi RSSI"
    update_interval: 60s
    entity_category: diagnostic

  - platform: uptime
    name: "Uptime"
    update_interval: 60s
    entity_category: diagnostic

switch:
  - platform: gpio
    id: pump
    name: "Pump (internal)"
    internal: true
    pin:
      number: D5
      mode:
        output: true
      inverted: false
    restore_mode: ALWAYS_OFF

script:
  - id: water_for_one_second
    mode: single
    then:
      - switch.turn_on: pump
      - delay: 1s
      - switch.turn_off: pump

button:
  - platform: template
    name: "Water for 1 second"
    icon: "mdi:watering-can"
    on_press:
      - script.execute: water_for_one_second
