Last active
August 13, 2020 20:04
-
-
Save Saiboogu/672dc4cfb97b1b7382d3cf8c808c54c9 to your computer and use it in GitHub Desktop.
Example of an esphome configuration file - my bathroom sensor with temp, humidity, one switch and one relay (light) output.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
esphome: | |
name: bathroom | |
platform: ESP8266 | |
board: nodemcuv2 | |
wifi: | |
ssid: "ssid" | |
password: "123" | |
fast_connect: true | |
# Enable fallback hotspot (captive portal) in case wifi connection fails | |
ap: | |
ssid: "Bathroom Fallback Hotspot" | |
password: "123" | |
captive_portal: | |
# Enable logging | |
logger: | |
# Enable Home Assistant API - This talks back to the datastorage and UI server | |
api: | |
password: "123" | |
ota: | |
password: "123" | |
sensor: | |
# just sends the uptime seconds so we can see unexpected reboots | |
- platform: uptime | |
name: "Bathroom Uptime Sensor" | |
update_interval: 300s | |
- platform: dht | |
pin: D4 | |
temperature: | |
name: "Bathroom Temperature" | |
icon: mdi:shower | |
filters: | |
- calibrate_polynomial: | |
degree: 2 | |
datapoints: | |
# Sensor is in a heated metal box, these values | |
# calibrate it closer to the air temp | |
- 27 -> 23 | |
- 31 -> 24 | |
- 34 -> 27.2 | |
- 35 -> 28.3 | |
- 36 -> 28.9 | |
- 37 -> 29.4 | |
# sometimes the sensor reading fails and it sends "NaN" | |
# this blocks those messages | |
- filter_out: nan | |
# the sensor only outputs when it changes | |
# this resends the last value as a heartbeat signal | |
- heartbeat: 15s | |
# the sensor sometimes spikes or dips wildly during startup or from random events | |
# this averages a few readings before outputing anything | |
- sliding_window_moving_average: | |
window_size: 2 | |
send_every: 2 | |
send_first_at: 1 | |
# the sensor reads in C, this sends F | |
- lambda: return x * (9.0/5.0) + 32.0; | |
# this just sets the name of the units, we had to do the math above | |
unit_of_measurement: "°F" | |
humidity: | |
name: "Bathroom Humidity" | |
icon: mdi:shower | |
filters: | |
- calibrate_polynomial: | |
degree: 1 | |
datapoints: | |
# This humidity calibration is rougher, need more data | |
- 16 -> 46 | |
- 15 -> 45 | |
- filter_out: nan | |
- heartbeat: 15s | |
- sliding_window_moving_average: | |
window_size: 2 | |
send_every: 2 | |
send_first_at: 1 | |
accuracy_decimals: 1 # humidity gets 0 decimals by default | |
model: DHT11 | |
# reports signal strength as a diagnostic value | |
- platform: wifi_signal | |
name: "Bathroom WiFi Signal Strength" | |
update_interval: 300s | |
binary_sensor: | |
# this pin connects to the old rocker switch on the wall | |
- platform: gpio | |
name: "Bathroom Switch #1" | |
# PULLUP enables resistors on the microcontroller that help clear any | |
# floating voltage to enable instant readings of switch change | |
# floating voltage can keep the pin high for several minutes after | |
# turning off the switch. I actually wired in my own resitors to get | |
# the same result, then discovered this one line fix. | |
# Inverted to match pin state to switch status | |
# because that's the way it is | |
pin: | |
number: D5 | |
mode: INPUT_PULLUP | |
inverted: true | |
# delay shutoff because the switch makes and breaks multiple times as it turns off | |
filters: | |
- delayed_off: 60ms | |
# this tells the system there's an output (relay) connected to this pin | |
output: | |
- platform: gpio | |
id: bathroom_ceiling_gpio | |
pin: GPIO5 | |
# this tells the system that the output we made operates a light | |
light: | |
- platform: binary | |
id: bathroom_ceiling | |
name: "Bathroom Ceiling" | |
output: bathroom_ceiling_gpio | |
text_sensor: | |
- platform: version | |
name: "Bathroom ESPHome Version" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment