Bilge Pump YAML
Here is the essential Bilge Pump YAML snippet to add to your ESPHome ESP32 configuration.
For a step-by-step guide, watch the comprehensive tutorial available at the following link: Video
i2c:
sda: GPIO21
scl: GPIO22
globals:
- id: bilge_pump_cycle_count
type: int
restore_value: true
initial_value: '0'
sensor:
- platform: ina219
address: 0x40
shunt_resistance: 0.1 ohm
id: ina_sensor
bus_voltage:
name: "Bilge Pump Voltage"
id: bilge_pump_voltage
update_interval: 1s
- platform: template
name: "Bilge Pump Running"
id: bilge_pump_running
lambda: |-
return id(bilge_pump_voltage).state > 8.0 ? 1 : 0;
update_interval: 1s
unit_of_measurement: "on/off"
accuracy_decimals: 0
- platform: integration
name: "Bilge Pump Run Time"
sensor: bilge_pump_running
time_unit: s
restore: true
- platform: template
name: "Bilge Pump Cycles"
id: bilge_pump_cycles
lambda: |-
static bool last_state = false;
bool current_state = id(bilge_pump_running).state > 0;
if (current_state && !last_state) {
id(bilge_pump_cycle_count) += 1;
}
last_state = current_state;
return id(bilge_pump_cycle_count);
update_interval: 1s
unit_of_measurement: "cycles"
binary_sensor:
- platform: template
name: "Bilge Pump Status"
lambda: |-
return id(bilge_pump_running).state > 0;