substitutions:
  local_update_interval: 30s

##########################################################################################
# GENERAL COMMON SENSORS
# https://esphome.io/components/sensor/
##########################################################################################

# Debug helpers (loop time / heap / reset info)
debug:
  update_interval: 5min

sensor:
  # Free heap via debug (replaces template-based ESP.getFreeHeap if you prefer)
  - platform: debug
    free:
      name: "Free Heap"
      entity_category: "diagnostic"
      disabled_by_default: true
      filters:
        - delta: 1024       # only if heap changes by ≥1 KB
        - heartbeat: 5min   # but still publish every 5 min


  # Loop time via debug (replaces broken template loop time)
  - platform: debug
    loop_time:
      name: "Loop Time"
      disabled_by_default: true
      entity_category: "diagnostic"
      filters:
        - delta: 2          # only if loop time changes by ≥2 ms
        - heartbeat: 5min


  ## If you’d rather keep the legacy heap sensor, uncomment below and
  ## delete the debug "free" block above to avoid duplicates:
  # - platform: template
  #   name: "${friendly_name} Free Heap"
  #   unit_of_measurement: "B"
  #   update_interval: 30s
  #   entity_category: "diagnostic"
  #   lambda: |-
  #     return (float) ESP.getFreeHeap();

  ##  # Only works with esp8266
  #- platform: adc
  #  pin: VCC
  #  name: "VCC Voltage"
  #  id: vcc_voltage_sensor
  #  entity_category: diagnostic

