Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 102 additions & 23 deletions Integrations/ESPHome/Core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ globals:
initial_value: "true"
- id: testCycleCount
type: int
- id: debounce_restart
type: bool
restore_value: no
initial_value: 'false'

captive_portal:

Expand Down Expand Up @@ -183,29 +187,39 @@ switch:
then:
- if:
condition:
or:
# Normal mode: input has water
- and:
- switch.is_off: tank_refill_mode
- binary_sensor.is_on: fluid_input_sensor
# Inverted mode: input is dry (destination is low, needs filling)
- and:
- switch.is_on: tank_refill_mode
- binary_sensor.is_off: fluid_input_sensor
# Bypass: dry protection not enabled
- switch.is_off: stop_pump_when_dry
- lambda: 'return id(debounce_restart);'
then:
- logger.log: "Pump turning on - conditions met"
- text_sensor.template.publish:
id: last_pump_action
state: "Pump Started"
- lambda: |-
id(pump_start_time) = millis();
id(debounce_restart) = false;
id(safety_alert_active) = false;
- logger.log: "Pump restarting after debounce verification"
- script.execute: pump_safety_check
else:
- logger.log: "Pump blocked - water conditions not met"
- switch.turn_off: pump_control
- if:
condition:
or:
# Normal mode: input has water
- and:
- switch.is_off: tank_refill_mode
- binary_sensor.is_on: fluid_input_sensor
# Inverted mode: input is dry (destination is low, needs filling)
- and:
- switch.is_on: tank_refill_mode
- binary_sensor.is_off: fluid_input_sensor
# Bypass: dry protection not enabled
- switch.is_off: stop_pump_when_dry
then:
- logger.log: "Pump turning on - conditions met"
- text_sensor.template.publish:
id: last_pump_action
state: "Pump Started"
- lambda: |-
id(pump_start_time) = millis();
id(safety_alert_active) = false;
- script.execute: pump_safety_check
else:
- logger.log: "Pump blocked - water conditions not met"
- switch.turn_off: pump_control
on_turn_off:
then:
- if:
Expand Down Expand Up @@ -270,9 +284,11 @@ binary_sensor:
inverted: true
on_release:
then:
- delay: !lambda 'return (int)id(sensor_debounce_seconds).state * 1000;'
- if:
condition:
and:
- binary_sensor.is_off: fluid_input_sensor
- switch.is_on: auto_refill
- switch.is_on: tank_refill_mode
- switch.is_off: pump_control
Expand All @@ -285,7 +301,7 @@ binary_sensor:

- platform: gpio
name: Fluid Output
id: fulid_output_sensor
id: fluid_output_sensor
icon: mdi:water
device_class: moisture
pin:
Expand Down Expand Up @@ -321,6 +337,20 @@ number:
unit_of_measurement: "s"
restore_value: true
mode: box
- platform: template
name: "Sensor Debounce Seconds"
id: sensor_debounce_seconds
icon: mdi:timer-sand
entity_category: config
disabled_by_default: true
optimistic: true
min_value: 0
max_value: 30
step: 1
initial_value: 0
unit_of_measurement: "s"
restore_value: true
mode: box

sensor:
- platform: internal_temperature
Expand Down Expand Up @@ -438,14 +468,31 @@ script:
condition:
- switch.is_on: pump_control
then:
# Stop when full (output wet) - stop first, verify after
- if:
condition:
- and:
- switch.is_on: stop_pump_when_full
- binary_sensor.is_on: fulid_output_sensor
- binary_sensor.is_on: fluid_output_sensor
then:
- logger.log: "Pump stopping - tank full"
- switch.turn_off: pump_control
- if:
condition:
- lambda: 'return id(sensor_debounce_seconds).state > 0;'
then:
- delay: !lambda 'return (int)id(sensor_debounce_seconds).state * 1000;'
- if:
condition:
- binary_sensor.is_off: fluid_output_sensor
then:
- logger.log: "Debounce: tank full was false alarm, restarting pump"
- lambda: 'id(debounce_restart) = true;'
- switch.turn_on: pump_control
else:
- logger.log: "Pump stopped - tank full (confirmed)"
else:
- logger.log: "Pump stopping - tank full"
# Safety timeout (unchanged)
- if:
condition:
- lambda: |-
Expand All @@ -455,24 +502,56 @@ script:
then:
- logger.log: "Pump stopping - safety"
- switch.turn_off: pump_control
# Destination full in inverted mode (input wet)
- if:
condition:
- and:
- switch.is_on: tank_refill_mode
- switch.is_off: stop_pump_when_full
- binary_sensor.is_on: fluid_input_sensor
then:
- logger.log: "Pump stopping - destination full (inverted mode)"
- switch.turn_off: pump_control
- if:
condition:
- lambda: 'return id(sensor_debounce_seconds).state > 0;'
then:
- delay: !lambda 'return (int)id(sensor_debounce_seconds).state * 1000;'
- if:
condition:
- binary_sensor.is_off: fluid_input_sensor
then:
- logger.log: "Debounce: destination full was false alarm, restarting pump"
- lambda: 'id(debounce_restart) = true;'
- switch.turn_on: pump_control
else:
- logger.log: "Pump stopped - destination full (confirmed)"
else:
- logger.log: "Pump stopping - destination full (inverted mode)"
# Stop when dry (input dry)
- if:
condition:
- and:
- switch.is_on: stop_pump_when_dry
- switch.is_off: tank_refill_mode
- binary_sensor.is_off: fluid_input_sensor
then:
- logger.log: "Pump stopping - input dry"
- switch.turn_off: pump_control
- if:
condition:
- lambda: 'return id(sensor_debounce_seconds).state > 0;'
then:
- delay: !lambda 'return (int)id(sensor_debounce_seconds).state * 1000;'
- if:
condition:
- binary_sensor.is_on: fluid_input_sensor
then:
- logger.log: "Debounce: input dry was false alarm, restarting pump"
- lambda: 'id(debounce_restart) = true;'
- switch.turn_on: pump_control
else:
- logger.log: "Pump stopped - input dry (confirmed)"
else:
- logger.log: "Pump stopping - input dry"
- delay: 1s
- id: testScript
then:
Expand Down
Loading