Files
fresh-home/esphome/backup/water-softener-multisensor.yaml
T
2026-05-24 12:33:06 -04:00

112 lines
2.7 KiB
YAML

# 3v3 en svp sun 34 35 32 33 25 26 27 14 12 gnd 13 sd2 sd3 gnd 5v
substitutions:
devicename: water-softener-multisensor
entity_name: water_softener_multisensor
friendly_name: Water Softener MultiSensor
comment: Clever Water Softener MultiSensor
platform: ESP32
board: wemos_d1_mini32
static_ip: !secret water-softener-multisensor-ip
door_pin: GPIO18
# For the ultrasonic sensor
trigger_pin: GPIO16
echo_pin: GPIO17
packages:
# network: !include common/ethernet.yaml
network: !include common/wifi.yaml
device_base: !include common/device_base.yaml
ble_proxy: !include common/ble_proxy.yaml
esphome:
name: ${devicename}
friendly_name: ${friendly_name}
name_add_mac_suffix: false
esp32:
board: ${board}
framework:
type: esp-idf
# Enable logging
logger:
api: # Using settings from common/device_base.yaml
ota: # Using settings from common/device_base.yaml
esp32_ble_tracker:
sensor:
- platform: ultrasonic
trigger_pin: ${trigger_pin}
echo_pin: ${echo_pin}
id: ultrasonic_source
update_interval: 1s
internal: True
filters:
- sliding_window_moving_average:
window_size: 5
send_every: 5
send_first_at: 1
on_value:
then:
- sensor.template.publish:
id: distance_from_bottom
state: !lambda 'return id(ultrasonic_source).state;'
- sensor.template.publish:
id: distance_from_top
state: !lambda 'return id(ultrasonic_source).state;'
- platform: template
unit_of_measurement: "cm"
state_class: measurement
id: distance_from_bottom
name: "Salt Level in CM"
icon: mdi:arrow-collapse-up
disabled_by_default: true
#update_interval: 5s
filters:
- lambda: 'return (0.94 - (id(ultrasonic_source).state)) * 100;'
on_value:
then:
- sensor.template.publish:
id: level_in_bags
state: !lambda 'return id(distance_from_bottom).state;'
- platform: template
unit_of_measurement: "cm"
state_class: measurement
id: distance_from_top
name: "Salt Level From Top in CM"
icon: mdi:arrow-collapse-down
disabled_by_default: true
#update_interval: 5s
filters:
- lambda: 'return (id(ultrasonic_source).state) * 100;'
- platform: template
unit_of_measurement: "bags"
state_class: measurement
id: level_in_bags
name: "Salt Level in Bags"
icon: mdi:counter
disabled_by_default: true
#update_interval: 5s
filters:
- lambda: 'return (id(distance_from_bottom).state) / 17.5;'
binary_sensor:
- platform: gpio
name: "Door"
device_class: door
pin:
number: ${door_pin}
mode: INPUT_PULLUP
# filters:
# - invert: