Skip to content

Instantly share code, notes, and snippets.

@adonno
Last active February 13, 2024 05:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save adonno/940d0865c4d4e2043566744393ecd67e to your computer and use it in GitHub Desktop.
Save adonno/940d0865c4d4e2043566744393ecd67e to your computer and use it in GitHub Desktop.
---
esphome:
name: salt_level_sensor
platform: ESP8266
board: d1_mini
# WiFi connection, replace these with values for your WiFi.
wifi:
ssid: !secret Wifi_SSID
password: !secret Wifi_PWD
# Enable logging
logger:
# Enable Home Assistant API
api:
# Enable over-the-air updates.
ota:
# Enable Web server.
web_server:
port: 80
# Sync time with Home Assistant.
time:
- platform: homeassistant
id: homeassistant_time
# Text sensors with general information.
text_sensor:
# Expose ESPHome version as sensor.
- platform: version
name: salt_level_sensor ESPHome Version
# Expose WiFi information as sensors.
- platform: wifi_info
ip_address:
name: salt_level_sensor IP
ssid:
name: salt_level_sensor SSID
bssid:
name: salt_level_sensor BSSID
# Exposed switches.
# Switch to restart the salt_level_sensor.
switch:
- platform: restart
name: "salt_level_sensor Restart"
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: D1
echo_pin: D2
name: "Saltlevel in percent"
update_interval: 12h
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);
unit_of_measurement: "%"
- platform: ultrasonic
trigger_pin: D1
echo_pin: D2
name: "Saltlevel in cm"
update_interval: 12h
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;
unit_of_measurement: "cm"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment