---
substitutions:
  devicename: d1-003
  id_name: d1-003
  Device_Location: Temperature
  update_interval: !secret d1-update_interval
  ipaddress: 10.0.0.113
  unique_id: "d1-003"
  deep_sleep_interval: !secret deep_sleep_interval

logger:
  level: WARN

esp8266:
  board: nodemcuv2

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

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

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

# Enable Home Assistant API
api:
  encryption:
    key: !secret mogwai_api_key

ota:
  platform: esphome
  password: !secret mogwai_ota_key

captive_portal:



time:

  - platform: homeassistant
    id: homeassistant_time

<<: !include common/website.yaml

switch:

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

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

  - <<: !include common/restart.yaml

interval:

  - interval: $update_interval
    then:
      - mqtt.publish:
          topic: /sensors/$devicename/temp-d1-001
          payload: "${Device_Location} Dallas Connected to GPIO03 - 0x593c01d607853f28 - 004 - prox-01"
      - mqtt.publish:
          topic: /sensors/$devicename/temp-d1-001
          payload: "${Device_Location} Dallas Connected to GPIO03 - 0x233c01d607290828 - 005 - prox-02"

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

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

sensor:

  - <<: !include common/free_space.yaml

  - platform: dallas_temp
    address: 0x593c01d607853f28
    name: "prox_01_temperature"
    id: "prox_01_temperature"
    update_interval: $update_interval
  - platform: dallas_temp
    address: 0x233c01d607290828
    name: "prox_02_temperature"
    id: "prox_02_temperature"
    update_interval: $update_interval

text_sensor:

  - <<: !include common/version.yaml

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

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