---
# GPIO03 - Data Pine for DS18
# 5.5 Volts - 4.7K Resistor between +5 and Data
# Ground

substitutions:
  devicename: d1-001
  id_name: d1-001
  Device_Location: Temperatures
  update_interval: !secret d1-update_interval
  ipaddress: 10.0.0.111
  unique_id: "d1-001"
  deep_sleep_interval: !secret deep_sleep_interval

logger:
  level: WARN

esp8266:
  board: nodemcuv2

esphome:
  name: d1-001
  friendly_name: "d1-001 - Temperatures"
  <<: !include common/esp8266_boot_count_02.yaml

<<: !include common/esp8266_boot_count_01.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

<<: !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:

  - interval: $update_interval
    then:
      - mqtt.publish:
          topic: /sensors/$devicename/temp-d1-001
          payload: "${Device_Location} Dallas Connected to GPIO03 - 0xd90119383a6c3628 - 001 - Synology3 " 
      - mqtt.publish:
          topic: /sensors/$devicename/temp-d1-001
          payload: "${Device_Location} Dallas Connected to GPIO03 - 0x530117b2419dff28 - 002 - Synology2"
      - mqtt.publish:
          topic: /sensors/$devicename/temp-d1-001
          payload: "${Device_Location} Dallas Connected to GPIO03 - 0x343c01b556be6728 - 003 - Synology1"
      - mqtt.publish:
          topic: /sensors/$devicename/temp-d1-001
          payload: "${Device_Location} Dallas Connected to GPIO03 - 0xe53c01d607ebc328 - 008 - Kodi"
      - mqtt.publish:
          topic: /sensors/$devicename/temp-d1-001
          payload: "${Device_Location} Dallas Connected to GPIO03 - 0x660b228191634728 - 010 - Lucy - 2 Cable Ties"

  - <<: !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: 0xd90119383a6c3628
    name: "synology3_temperature"
    id: "synology3_temperature"
    update_interval: $update_interval
  - platform: dallas_temp
    address: 0x530117b2419dff28
    name: "synology2_temperature"
    id: "synology2_temperature"
    update_interval: $update_interval
  - platform: dallas_temp
    address: 0x343c01b556be6728
    name: "synology1_temperature"
    id: "synology1_temperature"
    update_interval: $update_interval
  - platform: dallas_temp
    address: 0xe53c01d607ebc328
    name: "kodi_temperature"
    update_interval: $update_interval
  - platform: dallas_temp
    address: 0x660b228191634728
    name: "lucy_temperature"
    update_interval: $update_interval

text_sensor:

  - <<: !include common/version.yaml

  - <<: !include common/esp8266_reset_reason.yaml

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