esphome:
name: afstand-sensor1
platform: ESP8266
board: d1_mini
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "tralala"
ota:
password: "efc506805f5deb7f21136fdb4cb46159"
# Enable Web server.
web_server:
port: 80
# Sync time with Home Assistant.
time:
- platform: homeassistant
id: homeassistant_time
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Afstand-Sensor1 Fallback Hotspot"
password: "whatsthepassword"
captive_portal:
button:
- platform: restart
name: "Restart - Afstandsensor1"
sensor:
# Wifi signal sensor.
- platform: wifi_signal
name: afstand_sensor1_wifi_signal
update_interval: 600s
unit_of_measurement: '%'
filters:
- lambda: |-
if (x <= -100) {
return 0;
} else {
if (x >= -50) {
return 100;
} else {
return 2 * (x + 100);
}
}
# The actual distance sensor
- platform: ultrasonic
trigger_pin: D1
echo_pin: D2
name: afstand_sensor1_distance
update_interval: 30s
# trigger pin active for: (default 10us)
pulse_time: 20us
# distance in meter to timeout
timeout: 3m
filters:
- filter_out: nan
- median:
window_size: 3
# send_every: 1
send_first_at: 1
# - calibrate_linear:
# - 0.23 -> 1.86
# - 2.41 -> 0.0
- platform: uptime
name: "Afstand Sensor1 Uptime Sensor"