---
<<: !include common/esp8266_boot_count_01.yaml

substitutions:
  devicename: d1-002
  id_name: d1-002
  Device_Location: Prox Server Temperature
  update_interval: !secret d1-update_interval
  ipaddress: 10.0.0.112
  unique_id: "d1-002"
  deep_sleep_interval: !secret deep_sleep_interval

logger:
  level: WARN

esp8266:
  board: nodemcuv2

esphome:
  name: d1-002
  friendly_name: "d1-002 - Temperatures"

  <<: !include common/esp8266_boot_count_02.yaml

wifi:
  ssid: !secret mogwai_wifi_name
  password: !secret mogwai_wifi_password
  <<: !include common/network.yaml
  min_auth_mode: WPA2

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "$devicename Fallback Hotspot"
    password: !secret mogwai_ap_key

api:
  encryption:
    key: !secret mogwai_api_key

ota:
  platform: esphome
  password: !secret mogwai_ota_key

captive_portal:

time:
  - platform: homeassistant
    id: homeassistant_time
    on_time:
    # Cron syntax, trigger every 5 minutes
    - cron: '1 1,6,11,16,21,26,31,36,41,46,51,56 16 * * *'
      then:
        - switch.turn_on: led_onboard1
        - switch.turn_on: led_onboard2
    - cron: '1 2,7,12,17,22,27,32,37,42,47,52,57 16 * * *'
      then:
        - switch.turn_off: led_onboard1
        - switch.turn_off: led_onboard2

<<: !include common/website.yaml

<<: !include common/uptime_formatted.yaml

switch:

  - <<: !include common/d1-led-onboard1.yaml

  - <<: !include common/d1-led-onboard2.yaml

  - <<: !include common/nodemcu-led-onboard1-2-shuffle.yaml

  - <<: !include common/restart.yaml

<<: !include common/nodemcu-led-onboard-both-mqtt.yaml

interval:

  - <<: !include common/version-interval.yaml

# Dallas Temperature Sensors
one_wire:
  - platform: gpio
    pin: GPIO03

# Individual sensors
sensor:

  - <<: !include common/free_space.yaml

  - <<: !include common/esp8266_mhz.yaml

  - <<: !include common/uptime.yaml

  - <<: !include common/memory_heap_frag.yaml

  - <<: !include common/esp8266_boot_count_03.yaml

  - platform: dallas_temp
    address: 0x6d0b2281a3cc9328
    name: "prox-03_temperature"
    id: "prox_03_temperature"
    update_interval: $update_interval
  - platform: dallas_temp
    address: 0xdd3c01d607507328
    name: "prox-04_temperature"
    id: "prox_04_temperature"
    update_interval: $update_interval
  - platform: dallas_temp
    address: 0x5f0300a279238c28
    name: "prox-05_temperature"
    id: "prox_05_temperature"
    update_interval: $update_interval

text_sensor:

  - <<: !include common/version.yaml

  - <<: !include common/esp8266_reset_reason.yaml

<<: !include common/external-heapmon.yaml