initial commit
This commit is contained in:
@@ -0,0 +1,152 @@
|
||||
substitutions:
|
||||
device_name: salt-sensor
|
||||
friendly_name: "Salt Level Sensor"
|
||||
|
||||
esphome:
|
||||
name: ${device_name}
|
||||
friendly_name: ${friendly_name}
|
||||
|
||||
esp32:
|
||||
board: esp32-c3-devkitm-1
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "EaifDkFuB9N+qDKHW6B4k/n495FWLVmcp6DBODKzK10="
|
||||
|
||||
ota:
|
||||
- platform: esphome
|
||||
password: "7ce613915c51252c2810c07c889b4a5e"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_iot_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Salt-Sensor Fallback Hotspot"
|
||||
password: "ZoBRDcj54rwW"
|
||||
|
||||
# Prevents aggressive reconnection attempts
|
||||
power_save_mode: none # Use 'light' for battery devices
|
||||
|
||||
# Slower but more reliable connection
|
||||
fast_connect: true
|
||||
|
||||
# Handle connection failures gracefully
|
||||
on_connect:
|
||||
- logger.log: "Wi-Fi connected!"
|
||||
on_disconnect:
|
||||
- logger.log: "Wi-Fi disconnected!"
|
||||
|
||||
# Reduce mDNS traffic
|
||||
mdns:
|
||||
disabled: false # Set to true if you use static IPs and don't need discovery
|
||||
|
||||
# Watchdog to auto-reboot if things go wrong
|
||||
interval:
|
||||
- interval: 5min
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
and:
|
||||
- lambda: 'return millis() > 300000;' # >5 min uptime
|
||||
- not:
|
||||
wifi.connected:
|
||||
then:
|
||||
- logger.log: "Wi-Fi not connected for 5 min, rebooting..."
|
||||
- delay: 10s
|
||||
- lambda: 'App.safe_reboot();'
|
||||
|
||||
captive_portal:
|
||||
|
||||
# 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
|
||||
|
||||
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
|
||||
|
||||
# Diagnostic sensors
|
||||
- platform: wifi_signal
|
||||
name: "${device_name} WiFi Signal"
|
||||
update_interval: 60s
|
||||
|
||||
- platform: uptime
|
||||
name: "${device_name} Uptime"
|
||||
update_interval: 60s
|
||||
|
||||
# Ultrasonic sensor to measure salt level.
|
||||
# - platform: ultrasonic
|
||||
# trigger_pin: GPIO6
|
||||
# echo_pin: GPIO7
|
||||
# name: "Salt level in percent"
|
||||
# update_interval: 1h
|
||||
# unit_of_measurement: "%"
|
||||
# # pulse_time: 20us
|
||||
# # accuracy_decimals: 4
|
||||
# filters:
|
||||
# - lambda: return(0.42-x)*(100/0.42);
|
||||
# # - multiply: 100
|
||||
# - exponential_moving_average:
|
||||
# alpha: 0.001
|
||||
# send_every: 1
|
||||
# - clamp:
|
||||
# min_value: 20
|
||||
# max_value: 100
|
||||
# on_value_range:
|
||||
# above: 200
|
||||
# then:
|
||||
# - homeassistant.service:
|
||||
# service: notify.mailgun
|
||||
# data:
|
||||
# target:
|
||||
# -"joshua@cnjmail.com"
|
||||
# title: "Add Salt"
|
||||
# message: "Add Salt to the Water Softener Tank"
|
||||
# - homeassistant.service:
|
||||
# service: notify.mobile_app_joshuas_iphone_of_pain
|
||||
# data:
|
||||
# message: Water softener is low on salt, please add salt.
|
||||
|
||||
# Ultrasonic sensor to measure salt level.
|
||||
- platform: ultrasonic
|
||||
trigger_pin: GPIO6
|
||||
echo_pin: GPIO7
|
||||
name: "Salt level in cm"
|
||||
update_interval: .5h
|
||||
unit_of_measurement: "cm"
|
||||
# pulse_time: 20us
|
||||
# accuracy_decimals: 4
|
||||
filters:
|
||||
- lambda: return(0.83-x)*(100/0.83);
|
||||
Reference in New Issue
Block a user