substitutions: name: sthome-ut7 friendly_name: "sthome-ut7" esphome: name: "${name}" friendly_name: "${friendly_name}" #esphome: # name: sthome-ut7 # friendly_name: sthome-ut7 esp8266: board: esp01_1m # Enable logging logger: # Enable Home Assistant API api: encryption: key: "0H1KvuIcSV11klUG1MB8wyalPSNhlk40jkfEzBK95WU=" ota: - platform: esphome password: "be731abfa319b072b199a257af6e9527" wifi: #ssid: !secret wifi_ssid #password: !secret wifi_password # we will use local dns server for local dns resolution domain: ".sthome.org" networks: - ssid: !secret wifi_ssid1 password: !secret wifi_password1 - ssid: !secret wifi_ssid2 password: !secret wifi_password2 - ssid: !secret wifi_ssid3 password: !secret wifi_password3 - ssid: !secret wifi_ssid4 password: !secret wifi_password4 - ssid: !secret wifi_ssid5 password: !secret wifi_password5 manual_ip: # For faster connection startup, set a static IP address # Set this to the IP of the ESP static_ip: 10.0.2.7 gateway: 10.0.0.2 subnet: 255.255.240.0 dns1: 10.0.0.1 dns2: 10.0.0.2 # Enable fallback hotspot (captive portal) in case wifi connection fails ap: ssid: "${friendly_name} Fallback Hotspot" password: "0JNEPN1Q7GZ4" captive_portal: ##################################################################################### # Minimal flash writes, once per hour preferences: flash_write_interval: 60min sun: id: sun_sensor latitude: !secret latitude longitude: !secret longitude # Sync time with Home Assistant time: - platform: homeassistant id: homeassistant_time switch: # Switch to restart the ESP - platform: restart name: ${friendly_name} Restart - platform: gpio pin: GPIO0 name: "Relay1" inverted: false id: relay1 restore_mode: RESTORE_DEFAULT_OFF on_turn_on: - delay: 2500ms - switch.turn_off: relay1 - platform: gpio pin: GPIO1 name: "Relay2" inverted: true id: relay2 restore_mode: RESTORE_DEFAULT_OFF on_turn_on: - delay: 1000ms - switch.turn_off: relay2 - platform: gpio pin: GPIO2 name: "Relay3" inverted: true id: relay3 restore_mode: RESTORE_DEFAULT_OFF on_turn_on: - delay: 1000ms - switch.turn_off: relay3 binary_sensor: - platform: status # Status platform provides a connectivity sensor name: "${friendly_name} - Status" device_class: connectivity - platform: gpio pin: number: GPIO3 inverted: false id: gpio3_sensor name: GPIO3 Sensor device_class: problem sensor: # Report wifi signal strength every 5 min if changed - platform: wifi_signal name: ${friendly_name} WiFi Signal update_interval: 300s filters: - delta: 10% # human readable uptime sensor output to the text sensor above - platform: uptime name: ${friendly_name} Uptime in Days id: uptime_sensor_days update_interval: 60s on_raw_value: then: - text_sensor.template.publish: id: uptime_human state: !lambda |- int seconds = round(id(uptime_sensor_days).raw_state); int days = seconds / (24 * 3600); seconds = seconds % (24 * 3600); int hours = seconds / 3600; seconds = seconds % 3600; int minutes = seconds / 60; seconds = seconds % 60; return ( (days ? String(days) + "d " : "") + (hours ? String(hours) + "h " : "") + (minutes ? String(minutes) + "m " : "") + (String(seconds) + "s") ).c_str(); text_sensor: # Expose WiFi information as sensors - platform: wifi_info ip_address: name: ${friendly_name} IP mac_address: name: ${friendly_name} Mac Address # human readable update text sensor from sensor:uptime - platform: template name: Uptime id: uptime_human icon: mdi:clock-start # Pin assignments for ESP-01 # https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/ # 3v3 | | RX/GPIO3 - high at boot # RST | | GPIO0 - pulled up, flash if low on boot # EN | | GPIO2 - pulled up, blue led on if pulled down, must be high at boot # TX | | GND # ^ TX/GPIO1 - high at boot