Created
April 20, 2023 18:06
-
-
Save ev0rtex/0e3ac2a1719271c5848e7cab9ee2b53e to your computer and use it in GitHub Desktop.
ESPHome salt level sensor config
This file contains hidden or 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: salt-level-sensor | |
esp8266: | |
board: d1_mini | |
# Enable logging | |
logger: | |
# Enable Home Assistant API | |
api: | |
encryption: | |
key: "<HA API KEY>" | |
ota: | |
password: "<OTA PASSWORD>" | |
wifi: | |
ssid: !secret wifi_ssid | |
password: !secret wifi_password | |
domain: <DOMAIN> | |
# Enable fallback hotspot (captive portal) in case wifi connection fails | |
ap: | |
ssid: "Salt-Level-Sensor" | |
password: "<AP PASSWORD>" | |
captive_portal: | |
sensor: | |
# Uptime sensor. | |
- platform: uptime | |
name: salt-level-sensor Uptime | |
# WiFi Signal sensor. | |
- platform: wifi_signal | |
name: salt-level-sensor WiFi Signal | |
update_interval: 60s | |
- platform: ultrasonic | |
trigger_pin: D2 | |
echo_pin: D1 | |
name: "Salt Level (percentage)" | |
icon: "mdi:cup-water" | |
update_interval: 5sec | |
filters: | |
# Calculates in % | |
# Replace 0.42 by the height of your container. From the sensor to the bottom. | |
# I used this website to know how I should multiply my values :https://www.skillsyouneed.com/num/percent-change.html | |
- lambda: return (0.42-x)*(100/0.42); | |
- filter_out: nan | |
unit_of_measurement: "%" | |
- platform: ultrasonic | |
trigger_pin: D2 | |
echo_pin: D1 | |
name: "Salt Level (cm)" | |
icon: "mdi:cup-water" | |
update_interval: 5sec | |
filters: | |
# Replace the 0.42 by the height of your container. From the sensor to the bottom. | |
# I multiplied by 100 in order to get CM since the sensor works in meters | |
- lambda: return (0.42-x)*100; | |
- filter_out: nan | |
unit_of_measurement: "cm" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment