---
esphome:
  name: $devicename
  platform: ESP32
  board: nodemcu-32s
  build_path: build/test2

globals:
  - id: my_global_string
    type: std::string
    restore_value: yes
    max_restore_data_length: 70
    initial_value: '"DefaultValue"'

substitutions:
  devicename: test2

ethernet:
  type: LAN8720
  mdc_pin:
    allow_other_uses: true
    number: GPIO23
  mdio_pin:
    allow_other_uses: true
    number: GPIO25
  clk_mode: GPIO0_IN
  phy_addr: 0
  power_pin:
    allow_other_uses: true
    number: GPIO25
  manual_ip:
    static_ip: 192.168.178.56
    gateway: 192.168.178.1
    subnet: 255.255.255.0
  domain: .local

network:
  enable_ipv6: true

mdns:
  disabled: true

api:

i2c:
  sda:
    allow_other_uses: true
    number: 21
  scl:
    allow_other_uses: true
    number: 22
  scan: false

spi:
  clk_pin:
    allow_other_uses: true
    number: GPIO21
  mosi_pin:
    allow_other_uses: true
    number: GPIO22
  miso_pin:
    allow_other_uses: true
    number: GPIO23

uart:
  tx_pin:
    allow_other_uses: true
    number: GPIO22
  rx_pin:
    allow_other_uses: true
    number: GPIO23
  baud_rate: 115200
  # Specifically added for testing debug with no after: definition.
  debug:
    dummy_receiver: false
    direction: rx
    sequence:
      - lambda: UARTDebug::log_hex(direction, bytes, ':');

ota:
  safe_mode: true
  port: 3286
  num_attempts: 15

logger:
  level: DEBUG

debug:

deep_sleep:
  run_duration:
    default: 20s
    gpio_wakeup_reason: 10s
    touch_wakeup_reason: 15s
  sleep_duration: 50s
  wakeup_pin:
    allow_other_uses: true
    number: GPIO2
  wakeup_pin_mode: INVERT_WAKEUP

as3935_i2c:
  irq_pin:
    allow_other_uses: true
    number: GPIO12

mcp3008:
  - id: mcp3008_hub
    cs_pin:
      allow_other_uses: true
      number: GPIO12

output:
  - platform: ac_dimmer
    id: dimmer1
    gate_pin: GPIO5
    zero_cross_pin:
      allow_other_uses: true
      number: GPIO12

sensor:
  - platform: homeassistant
    entity_id: sensor.hello_world
    id: ha_hello_world
  - platform: homeassistant
    entity_id: climate.living_room
    attribute: temperature
    id: ha_hello_world_temperature
  - platform: ble_rssi
    mac_address: AC:37:43:77:5F:4C
    name: BLE Google Home Mini RSSI value
  - platform: ble_rssi
    service_uuid: 11aa
    name: BLE Test Service 16
  - platform: ble_rssi
    service_uuid: "11223344"
    name: BLE Test Service 32
  - platform: ble_rssi
    service_uuid: 11223344-5566-7788-99aa-bbccddeeff00
    name: BLE Test Service 128
  - platform: ble_rssi
    service_uuid: 11223344-5566-7788-99aa-bbccddeeff00
    name: BLE Test iBeacon UUID
  - platform: b_parasite
    mac_address: F0:CA:F0:CA:01:01
    humidity:
      name: b-parasite Air Humidity
    temperature:
      name: b-parasite Air Temperature
    moisture:
      name: b-parasite Soil Moisture
    battery_voltage:
      name: b-parasite Battery Voltage
    illuminance:
      name: b-parasite Illuminance
  - platform: senseair
    id: senseair0
    co2:
      name: SenseAir CO2 Value
      on_value:
        then:
          - senseair.background_calibration: senseair0
          - senseair.background_calibration_result: senseair0
          - senseair.abc_get_period: senseair0
          - senseair.abc_enable: senseair0
          - senseair.abc_disable: senseair0
    update_interval: 15s
  - platform: ruuvitag
    mac_address: FF:56:D3:2F:7D:E8
    humidity:
      name: RuuviTag Humidity
    temperature:
      name: RuuviTag Temperature
    pressure:
      name: RuuviTag Pressure
    acceleration_x:
      name: RuuviTag Acceleration X
    acceleration_y:
      name: RuuviTag Acceleration Y
    acceleration_z:
      name: RuuviTag Acceleration Z
    battery_voltage:
      name: RuuviTag Battery Voltage
    tx_power:
      name: RuuviTag TX Power
    movement_counter:
      name: RuuviTag Movement Counter
    measurement_sequence_number:
      name: RuuviTag Measurement Sequence Number
  - platform: as3935
    lightning_energy:
      name: Lightning Energy
    distance:
      name: Distance Storm
  - platform: xiaomi_hhccjcy01
    mac_address: 94:2B:FF:5C:91:61
    temperature:
      name: Xiaomi HHCCJCY01 Temperature
    moisture:
      name: Xiaomi HHCCJCY01 Moisture
    illuminance:
      name: Xiaomi HHCCJCY01 Illuminance
    conductivity:
      name: Xiaomi HHCCJCY01 Soil Conductivity
    battery_level:
      name: Xiaomi HHCCJCY01 Battery Level
  - platform: xiaomi_lywsdcgq
    mac_address: 7A:80:8E:19:36:BA
    temperature:
      name: Xiaomi LYWSDCGQ Temperature
    humidity:
      name: Xiaomi LYWSDCGQ Humidity
    battery_level:
      name: Xiaomi LYWSDCGQ Battery Level
  - platform: xiaomi_lywsd02
    mac_address: 3F:5B:7D:82:58:4E
    temperature:
      name: Xiaomi LYWSD02 Temperature
    humidity:
      name: Xiaomi LYWSD02 Humidity
    battery_level:
      name: Xiaomi LYWSD02 Battery Level
  - platform: xiaomi_cgg1
    mac_address: 7A:80:8E:19:36:BA
    temperature:
      name: Xiaomi CGG1 Temperature
    humidity:
      name: Xiaomi CGG1 Humidity
    battery_level:
      name: Xiaomi CGG1 Battery Level
  - platform: xiaomi_gcls002
    mac_address: 94:2B:FF:5C:91:61
    temperature:
      name: GCLS02 Temperature
    moisture:
      name: GCLS02 Moisture
    conductivity:
      name: GCLS02 Soil Conductivity
    illuminance:
      name: GCLS02 Illuminance
  - platform: xiaomi_hhccpot002
    mac_address: 94:2B:FF:5C:91:61
    moisture:
      name: HHCCPOT002 Moisture
    conductivity:
      name: HHCCPOT002 Soil Conductivity
  - platform: xiaomi_lywsd03mmc
    mac_address: A4:C1:38:4E:16:78
    bindkey: e9efaa6873f9f9c87a5e75a5f814801c
    temperature:
      name: Xiaomi LYWSD03MMC Temperature
    humidity:
      name: Xiaomi LYWSD03MMC Humidity
    battery_level:
      name: Xiaomi LYWSD03MMC Battery Level
  - platform: xiaomi_cgd1
    mac_address: A4:C1:38:D1:61:7D
    bindkey: c99d2313182473b38001086febf781bd
    temperature:
      name: Xiaomi CGD1 Temperature
    humidity:
      name: Xiaomi CGD1 Humidity
    battery_level:
      name: Xiaomi CGD1 Battery Level
  - platform: xiaomi_jqjcy01ym
    mac_address: 7A:80:8E:19:36:BA
    temperature:
      name: JQJCY01YM Temperature
    humidity:
      name: JQJCY01YM Humidity
    formaldehyde:
      name: JQJCY01YM Formaldehyde
    battery_level:
      name: JQJCY01YM Battery Level
  - platform: xiaomi_mhoc303
    mac_address: E7:50:59:32:A0:1C
    temperature:
      name: MHO-C303 Temperature
    humidity:
      name: MHO-C303 Humidity
    battery_level:
      name: MHO-C303 Battery Level
  - platform: atc_mithermometer
    mac_address: A4:C1:38:4E:16:78
    temperature:
      name: ATC Temperature
    humidity:
      name: ATC Humidity
    battery_level:
      name: ATC Battery-Level
    battery_voltage:
      name: ATC Battery-Voltage
  - platform: pvvx_mithermometer
    mac_address: A4:C1:38:4E:16:78
    temperature:
      name: PVVX Temperature
    humidity:
      name: PVVX Humidity
    battery_level:
      name: PVVX Battery-Level
    battery_voltage:
      name: PVVX Battery-Voltage
  - platform: inkbird_ibsth1_mini
    mac_address: 38:81:D7:0A:9C:11
    temperature:
      name: Inkbird IBS-TH1 Temperature
    humidity:
      name: Inkbird IBS-TH1 Humidity
    battery_level:
      name: Inkbird IBS-TH1 Battery Level
  - platform: xiaomi_rtcgq02lm
    id: motion_rtcgq02lm
    battery_level:
      name: Mi Motion Sensor 2 Battery level
  - platform: ltr390
    uv:
      name: LTR390 UV
    uv_index:
      name: LTR390 UVI
    light:
      name: LTR390 Light
    ambient_light:
      name: LTR390 ALS
    gain: X3
    resolution: 18
    window_correction_factor: 1.0
    address: 0x53
    update_interval: 60s
  - platform: sgp4x
    voc:
      name: VOC Index
      id: sgp40_voc_index
      algorithm_tuning:
        index_offset: 100
        learning_time_offset_hours: 12
        learning_time_gain_hours: 12
        gating_max_duration_minutes: 180
        std_initial: 50
        gain_factor: 230
    nox:
      name: NOx
      algorithm_tuning:
        index_offset: 100
        learning_time_offset_hours: 12
        learning_time_gain_hours: 12
        gating_max_duration_minutes: 180
        std_initial: 50
        gain_factor: 230
    update_interval: 5s
  - platform: mcp3008
    update_interval: 5s
    mcp3008_id: mcp3008_hub
    id: freezer_temp_source
    reference_voltage: 3.19
    number: 0
  - id: airthingswp
    platform: airthings_wave_plus
    ble_client_id: airthings01
    update_interval: 5min
    battery_update_interval: 12h
    temperature:
      name: Wave Plus Temperature
    radon:
      name: Wave Plus Radon
    radon_long_term:
      name: Wave Plus Radon Long Term
    pressure:
      name: Wave Plus Pressure
    humidity:
      name: Wave Plus Humidity
    co2:
      name: Wave Plus CO2
    tvoc:
      name: Wave Plus VOC
    battery_voltage:
      name: Wave Plus Battery Voltage
  - id: airthingswm
    platform: airthings_wave_mini
    ble_client_id: airthingsmini01
    update_interval: 5min
    battery_update_interval: 12h
    temperature:
      name: Wave Mini Temperature
    humidity:
      name: Wave Mini Humidity
    pressure:
      name: Wave Mini Pressure
    tvoc:
      name: Wave Mini VOC
    battery_voltage:
      name: Wave Mini Battery Voltage
  - platform: ina260
    address: 0x40
    current:
      name: INA260 Current
    power:
      name: INA260 Power
    bus_voltage:
      name: INA260 Voltage
    update_interval: 60s
  - platform: radon_eye_rd200
    ble_client_id: radon_eye_ble_id
    update_interval: 10min
    radon:
      name: RD200 Radon
    radon_long_term:
      name: RD200 Radon Long Term
  - platform: mopeka_pro_check
    mac_address: D3:75:F2:DC:16:91
    tank_type: CUSTOM
    custom_distance_full: 40cm
    custom_distance_empty: 10mm
    temperature:
      name: Propane test temp
    level:
      name: Propane test level
    distance:
      name: Propane test distance
    battery_level:
      name: Propane test battery level
  - platform: ufire_ec
    id: ufire_ec_board
    ec:
      name: Ufire EC
    temperature_sensor: ha_hello_world_temperature
    temperature_compensation: 20.0
    temperature_coefficient: 0.019
  - platform: ufire_ise
    id: ufire_ise_board
    temperature_sensor: ha_hello_world_temperature
    ph:
      name: Ufire pH
  - platform: mics_4514
    update_interval: 60s
    nitrogen_dioxide:
      name: MICS-4514 NO2
    carbon_monoxide:
      name: MICS-4514 CO
    methane:
      name: MICS-4514 CH4
    hydrogen:
      name: MICS-4514 H2
    ethanol:
      name: MICS-4514 C2H5OH
    ammonia:
      name: MICS-4514 NH3
  - platform: mopeka_std_check
    mac_address: D3:75:F2:DC:16:91
    tank_type: CUSTOM
    custom_distance_full: 40cm
    custom_distance_empty: 10mm
    temperature:
      name: Propane test temp
    level:
      name: Propane test level
    distance:
      name: Propane test distance
    battery_level:
      name: Propane test battery level
  - platform: duty_time
    id: duty_time1
    name: Test Duty Time
    restore: true
    last_time:
      name: Test Last Duty Time Sensor
    sensor: ha_hello_world_binary
  - platform: duty_time
    id: duty_time2
    name: Test Duty Time 2
    restore: false
    lambda: "return true;"

time:
  - platform: homeassistant
    on_time:
      - at: "16:00:00"
        then:
          - logger.log: It's 16:00
          - if:
              condition:
                - sensor.duty_time.is_running: duty_time2
              then:
                - sensor.duty_time.start: duty_time1
          - if:
              condition:
                - sensor.duty_time.is_not_running: duty_time1
              then:
                - sensor.duty_time.stop: duty_time2
          - sensor.duty_time.reset: duty_time1

esp32_touch:
  setup_mode: true

binary_sensor:
  - platform: homeassistant
    entity_id: binary_sensor.hello_world
    id: ha_hello_world_binary
  - platform: homeassistant
    entity_id: binary_sensor.hello
    attribute: world
    id: ha_hello_world_binary_attribute
  - platform: ble_presence
    mac_address: AC:37:43:77:5F:4C
    name: ESP32 BLE Tracker Google Home Mini
  - platform: ble_presence
    service_uuid: 11aa
    name: BLE Test Service 16 Presence
  - platform: ble_presence
    service_uuid: "11223344"
    name: BLE Test Service 32 Presence
  - platform: ble_presence
    service_uuid: 11223344-5566-7788-99aa-bbccddeeff00
    name: BLE Test Service 128 Presence
  - platform: ble_presence
    ibeacon_uuid: 11223344-5566-7788-99aa-bbccddeeff00
    ibeacon_major: 100
    ibeacon_minor: 1
    name: BLE Test iBeacon Presence
  - platform: esp32_touch
    name: ESP32 Touch Pad GPIO27
    pin: GPIO27
    threshold: 1000
  - platform: as3935
    name: Storm Alert
  - platform: xiaomi_mue4094rt
    name: MUE4094RT Motion
    mac_address: 7A:80:8E:19:36:BA
    timeout: 5s
  - platform: xiaomi_mjyd02yla
    name: MJYD02YL-A Motion
    mac_address: 50:EC:50:CD:32:02
    bindkey: 48403ebe2d385db8d0c187f81e62cb64
    idle_time:
      name: MJYD02YL-A Idle Time
    light:
      name: MJYD02YL-A Light Status
    battery_level:
      name: MJYD02YL-A Battery Level
  - platform: xiaomi_wx08zm
    name: WX08ZM Activation State
    mac_address: 74:a3:4a:b5:07:34
    tablet:
      name: WX08ZM Tablet Resource
    battery_level:
      name: WX08ZM Battery Level
  - platform: xiaomi_cgpr1
    name: CGPR1 Motion
    mac_address: "12:34:56:12:34:56"
    bindkey: 48403ebe2d385db8d0c187f81e62cb64
    battery_level:
      name: CGPR1 battery Level
    idle_time:
      name: CGPR1 Idle Time
    illuminance:
      name: CGPR1 Illuminance
  - platform: xiaomi_rtcgq02lm
    id: motion_rtcgq02lm
    motion:
      name: Mi Motion Sensor 2
    light:
      name: Mi Motion Sensor 2 Light
    button:
      name: Mi Motion Sensor 2 Button
  - platform: gpio
    id: gpio_set_retry_test
    pin:
      allow_other_uses: true
      number: GPIO9
    on_press:
      then:
        - lambda: |-
            App.scheduler.set_retry(id(gpio_set_retry_test), "set_retry_test", 100, 3, [](const uint8_t remaining) {
              return remaining ? RetryResult::RETRY : RetryResult::DONE; // just to reference both symbols
            }, 5.0f);

esp32_ble_tracker:
  on_ble_advertise:
    - mac_address:
        - AA:BB:CC:DD:EE:FF
        - FF:EE:DD:CC:BB:AA
      then:
        # yamllint disable rule:line-length
        - lambda: !lambda |-
            ESP_LOGD("main", "The device address (%s) exists in list", x.address_str().c_str());
        # yamllint enable rule:line-length
    - mac_address: AC:37:43:77:5F:4C
      then:
        # yamllint disable rule:line-length
        - lambda: !lambda |-
            ESP_LOGD("main", "The device address is %s", x.address_str().c_str());
        # yamllint enable rule:line-length
    - then:
        # yamllint disable rule:line-length
        - lambda: !lambda |-
            ESP_LOGD("main", "The device address is %s", x.address_str().c_str());
        # yamllint enable rule:line-length
  on_ble_service_data_advertise:
    - service_uuid: ABCD
      then:
        - lambda: !lambda |-
            ESP_LOGD("main", "Length of service data is %i", x.size());
  on_ble_manufacturer_data_advertise:
    - manufacturer_id: ABCD
      then:
        - lambda: !lambda |-
            ESP_LOGD("main", "Length of manufacturer data is %i", x.size());

ble_client:
  - mac_address: 01:02:03:04:05:06
    id: airthings01
  - mac_address: 01:02:03:04:05:06
    id: airthingsmini01
  - mac_address: 01:02:03:04:05:06
    id: radon_eye_ble_id

airthings_ble:

radon_eye_ble:

ruuvi_ble:

xiaomi_ble:

mopeka_ble:

bluetooth_proxy:
  active: true

xiaomi_rtcgq02lm:
  - id: motion_rtcgq02lm
    mac_address: 01:02:03:04:05:06
    bindkey: "48403ebe2d385db8d0c187f81e62cb64"

status_led:
  pin:
    allow_other_uses: true
    number: GPIO2

text_sensor:
  - platform: version
    name: ESPHome Version
    icon: mdi:icon
    id: version_sensor
    on_value:
      - if:
          condition:
            - api.connected:
          then:
            # yamllint disable rule:line-length
            - lambda: !lambda |-
                ESP_LOGD("main", "The state is %s=%s", x.c_str(), id(version_sensor).state.c_str());
            # yamllint enable rule:line-length
      - script.execute: my_script
      - script.execute:
          id: my_script_with_params
          prefix: Running my_script_with_params
          param2: 100
          param3: true
      - script.execute:
          id: my_script_with_params
          prefix: Running my_script_with_params using lambda parameters
          param2: !lambda return 200;
          param3: !lambda return true;
      - homeassistant.service:
          service: notify.html5
          data:
            title: New Humidity
          data_template:
            message: The humidity is {{ my_variable }}%.
          variables:
            my_variable: |-
              return id(version_sensor).state;
            my_variable_str: |-
              return "Hello World";
      - homeassistant.service:
          service: light.turn_on
          data:
            entity_id: light.my_light
      - homeassistant.tag_scanned:
          tag: 1234-abcd
      - homeassistant.tag_scanned: 1234-abcd
      - deep_sleep.enter:
          sleep_duration: 30min
      - deep_sleep.enter:
          sleep_duration: !lambda "return 30 * 60 * 1000;"
  - platform: template
    name: Template Text Sensor
    lambda: |-
      return {"Hello World"};
    filters:
      - to_upper:
      - to_lower:
      - append: xyz
      - prepend: abcd
      - substitute:
          - Hello -> Goodbye
      - map:
          - red -> green
      - lambda: 'return {"1234"};'
  - platform: homeassistant
    entity_id: sensor.hello_world2
    id: ha_hello_world2
  - platform: homeassistant
    entity_id: sensor.hello_world3
    id: ha_hello_world3
    attribute: some_attribute
  - platform: ble_scanner
    name: Scanner

script:
  - id: my_script
    mode: single
    then:
      - lambda: 'ESP_LOGD("main", "Hello World!");'
  - id: my_script_queued
    mode: queued
    max_runs: 2
    then:
      - lambda: 'ESP_LOGD("main", "Hello World!");'
  - id: my_script_parallel
    mode: parallel
    max_runs: 2
    then:
      - lambda: 'ESP_LOGD("main", "Hello World!");'
  - id: my_script_restart
    mode: restart
    then:
      - lambda: 'ESP_LOGD("main", "Hello World!");'
  - id: my_script_with_params
    parameters:
      prefix: string
      param2: int
      param3: bool
    then:
      - lambda: 'ESP_LOGD("main", (prefix + " Hello World!" + to_string(param2) + " " + to_string(param3)).c_str());'

stepper:
  - platform: uln2003
    id: my_stepper
    pin_a:
      allow_other_uses: true
      number: GPIO23
    pin_b: GPIO27
    pin_c:
      allow_other_uses: true
      number: GPIO25
    pin_d: GPIO26
    sleep_when_done: false
    step_mode: HALF_STEP
    max_speed: 250 steps/s

    # Optional:
    acceleration: inf
    deceleration: inf

interval:
  interval: 5s
  startup_delay: 10s
  then:
    - logger.log: Interval Run

display:
  - platform: st7789v
    model: LILYGO_T-EMBED_170X320
    spi_mode: mode0
    height: 320
    width: 170
    offset_height: 35
    offset_width: 0
    dc_pin: GPIO13
    reset_pin:
      allow_other_uses: true
      number: GPIO9

image:
  - id: binary_image
    file: pnglogo.png
    type: BINARY
    dither: FloydSteinberg
  - id: transparent_transparent_image
    file: pnglogo.png
    type: TRANSPARENT_BINARY
  - id: rgba_image
    file: pnglogo.png
    type: RGBA
    resize: 50x50
  - id: rgb24_image
    file: pnglogo.png
    type: RGB24
    use_transparency: yes
  - id: rgb565_image
    file: pnglogo.png
    type: RGB565
    use_transparency: no
  - id: web_svg_image
    file: https://raw.githubusercontent.com/esphome/esphome-docs/a62d7ab193c1a464ed791670170c7d518189109b/images/logo.svg
    resize: 256x48
    type: TRANSPARENT_BINARY
  - id: web_tiff_image
    file: https://upload.wikimedia.org/wikipedia/commons/b/b6/SIPI_Jelly_Beans_4.1.07.tiff
    type: RGB24
    resize: 48x48
  - id: web_redirect_image
    file: https://avatars.githubusercontent.com/u/3060199?s=48&v=4
    type: RGB24
    resize: 48x48

  - id: mdi_alert
    file: mdi:alert-circle-outline
    resize: 50x50
  - id: another_alert_icon
    file: mdi:alert-outline
    type: BINARY

font:
  - file: "gfonts://Roboto"
    id: roboto
    size: 20

graph:
  - id: my_graph
    sensor: ha_hello_world_temperature
    duration: 1h
    width: 100
    height: 100

cap1188:
  id: cap1188_component
  address: 0x29
  touch_threshold: 0x20
  allow_multiple_touches: true
  reset_pin: 14

switch:
  - platform: template
    name: Test BLE Write Action
    turn_on_action:
      - ble_client.ble_write:
          id: airthings01
          service_uuid: F61E3BE9-2826-A81B-970A-4D4DECFABBAE
          characteristic_uuid: 6490FAFE-0734-732C-8705-91B653A081FC
          value: [0x01, 0xab, 0xff]
      - ble_client.ble_write:
          id: airthings01
          service_uuid: F61E3BE9-2826-A81B-970A-4D4DECFABBAE
          characteristic_uuid: 6490FAFE-0734-732C-8705-91B653A081FC
          value: !lambda |-
            return {0x13, 0x37};

esp32_ble_server:
  id: ble
  manufacturer_data: [0x72, 0x4, 0x00, 0x23]

text:
  - platform: template
    name: My Text
    id: my_text
    min_length: 0
    max_length: 20
    mode: text
    pattern: "[a-z]+"
    optimistic: true
    restore_value: true
    initial_value: "Hello World"
  - platform: copy
    name: My Text Copy
    id: my_text_copy
    source_id: my_text
    mode: password
