2024-05-10 10:37:19 +00:00
|
|
|
esphome:
|
|
|
|
name: chlorine-pump
|
|
|
|
project:
|
|
|
|
name: nbsgamesat.chlorine-pump
|
2024-05-24 14:00:34 +00:00
|
|
|
version: "0.7"
|
2024-05-12 21:02:52 +00:00
|
|
|
on_boot:
|
|
|
|
priority: 600
|
|
|
|
then:
|
2024-05-27 12:43:10 +00:00
|
|
|
- output.turn_on: wifi_status_led
|
|
|
|
- chlorine_pump.set_target:
|
|
|
|
target: !lambda return id(chlorine_target).state;
|
|
|
|
|
2024-05-10 10:37:19 +00:00
|
|
|
|
|
|
|
esp8266:
|
|
|
|
board: nodemcuv2
|
|
|
|
|
|
|
|
# Enable logging
|
|
|
|
logger:
|
|
|
|
|
|
|
|
ota:
|
|
|
|
password: !secret cp_password
|
|
|
|
|
|
|
|
external_components:
|
|
|
|
- source:
|
|
|
|
type: local
|
|
|
|
path: external_components/
|
2024-05-25 18:01:05 +00:00
|
|
|
components: [ chlorine_pump, ezo_orp_i2c]
|
2024-05-12 21:02:52 +00:00
|
|
|
|
|
|
|
globals:
|
|
|
|
- id: last_pump_state
|
|
|
|
type: bool
|
|
|
|
restore_value: no
|
|
|
|
initial_value: "false"
|
|
|
|
- id: last_cycle_info
|
|
|
|
type: std::string
|
2024-05-10 10:37:19 +00:00
|
|
|
|
|
|
|
api:
|
|
|
|
encryption:
|
|
|
|
key: !secret cp_key
|
|
|
|
|
|
|
|
wifi:
|
|
|
|
ssid: !secret wifi_ssid
|
|
|
|
password: !secret wifi_password
|
|
|
|
fast_connect: true
|
2024-05-12 21:02:52 +00:00
|
|
|
on_connect:
|
2024-05-24 14:00:34 +00:00
|
|
|
output.turn_off: wifi_status_led
|
|
|
|
on_disconnect:
|
|
|
|
output.turn_on: wifi_status_led
|
2024-05-10 10:37:19 +00:00
|
|
|
|
|
|
|
output:
|
|
|
|
- platform: gpio
|
2024-05-12 21:02:52 +00:00
|
|
|
pin: D6
|
2024-05-10 10:37:19 +00:00
|
|
|
id: pump_switch
|
2024-05-12 21:02:52 +00:00
|
|
|
- platform: gpio
|
|
|
|
pin:
|
|
|
|
number: D0
|
|
|
|
inverted: true
|
2024-05-24 14:00:34 +00:00
|
|
|
id: wifi_status_led
|
2024-05-10 10:37:19 +00:00
|
|
|
|
|
|
|
binary_sensor:
|
|
|
|
- platform: gpio
|
|
|
|
id: pool_pump
|
2024-05-12 21:02:52 +00:00
|
|
|
pin:
|
2024-05-25 18:01:05 +00:00
|
|
|
number: D5
|
2024-05-12 21:02:52 +00:00
|
|
|
inverted: true
|
|
|
|
mode:
|
|
|
|
input: true
|
|
|
|
pullup: true
|
|
|
|
on_state:
|
|
|
|
- script.execute:
|
|
|
|
id: manage_power
|
|
|
|
switch_state: !lambda return id(power).state;
|
2024-05-25 18:01:05 +00:00
|
|
|
- platform: gpio
|
|
|
|
id: calibrater
|
|
|
|
pin:
|
|
|
|
number: GPIO0
|
|
|
|
inverted: true
|
|
|
|
on_press:
|
|
|
|
- sensor.ezo_orp_i2c.print_device_info:
|
|
|
|
id: chlorine_sensor
|
|
|
|
on_click:
|
|
|
|
min_length: 5s
|
|
|
|
max_length: 10s
|
|
|
|
then:
|
|
|
|
- sensor.ezo_orp_i2c.calibrate:
|
|
|
|
id: chlorine_sensor
|
|
|
|
calibrate_target: 475
|
|
|
|
- output.turn_on: wifi_status_led
|
|
|
|
- delay: 2s
|
|
|
|
- output.turn_off: wifi_status_led
|
2024-05-12 21:02:52 +00:00
|
|
|
- platform: template
|
|
|
|
id: pump_state
|
|
|
|
name: Pump State
|
|
|
|
lambda: !lambda return id(last_pump_state);
|
|
|
|
|
|
|
|
script:
|
|
|
|
- id: manage_power
|
|
|
|
parameters:
|
|
|
|
switch_state: bool
|
|
|
|
then:
|
|
|
|
- if:
|
|
|
|
condition:
|
|
|
|
lambda: |-
|
|
|
|
return switch_state && id(pool_pump).state;
|
|
|
|
then:
|
|
|
|
- chlorine_pump.start: {}
|
|
|
|
- text_sensor.template.publish:
|
|
|
|
id: cycle_text_info
|
|
|
|
state: !lambda 'return "ON... ";'
|
|
|
|
else:
|
|
|
|
- chlorine_pump.stop: {}
|
|
|
|
- text_sensor.template.publish:
|
|
|
|
id: cycle_text_info
|
|
|
|
state: !lambda 'return "PUMP: OFF";'
|
|
|
|
|
|
|
|
switch:
|
|
|
|
- platform: template
|
|
|
|
name: Chlorine Pump Power
|
|
|
|
id: power
|
|
|
|
optimistic: true
|
|
|
|
inverted: off
|
|
|
|
restore_mode: RESTORE_DEFAULT_ON
|
|
|
|
turn_on_action:
|
|
|
|
- script.execute:
|
|
|
|
id: manage_power
|
|
|
|
switch_state: true
|
|
|
|
turn_off_action:
|
|
|
|
- script.execute:
|
|
|
|
id: manage_power
|
|
|
|
switch_state: false
|
|
|
|
|
|
|
|
button:
|
|
|
|
- platform: template
|
|
|
|
name: Prime
|
|
|
|
id: prime
|
|
|
|
on_press:
|
|
|
|
- chlorine_pump.prime: {}
|
|
|
|
- text_sensor.template.publish:
|
|
|
|
id: cycle_text_info
|
|
|
|
state: !lambda 'return "PRIMING??";'
|
|
|
|
|
|
|
|
number:
|
|
|
|
- platform: template
|
|
|
|
name: Chlorine Target
|
|
|
|
id: chlorine_target
|
|
|
|
initial_value: 700
|
|
|
|
restore_value: true
|
|
|
|
min_value: 300
|
|
|
|
max_value: 1400
|
|
|
|
optimistic: true
|
|
|
|
step: 1.0
|
|
|
|
set_action:
|
|
|
|
then:
|
|
|
|
- chlorine_pump.set_target:
|
|
|
|
target: !lambda return x;
|
|
|
|
|
|
|
|
text_sensor:
|
|
|
|
- platform: template
|
|
|
|
name: Cycle Info
|
|
|
|
id: cycle_text_info
|
2024-05-10 10:37:19 +00:00
|
|
|
|
2024-05-25 18:01:05 +00:00
|
|
|
i2c:
|
|
|
|
|
2024-05-10 10:37:19 +00:00
|
|
|
sensor:
|
2024-05-25 18:01:05 +00:00
|
|
|
- platform: ezo_orp_i2c
|
2024-05-10 10:37:19 +00:00
|
|
|
id: chlorine_sensor
|
2024-05-25 18:01:05 +00:00
|
|
|
name: Chlorine
|
|
|
|
update_interval: 5s
|
2024-05-12 21:02:52 +00:00
|
|
|
- platform: hx711
|
|
|
|
name: "Chlorine Canister Levels"
|
2024-05-25 18:01:05 +00:00
|
|
|
dout_pin: D7
|
|
|
|
clk_pin: D8
|
2024-05-12 21:02:52 +00:00
|
|
|
gain: 128
|
|
|
|
update_interval: 20s
|
|
|
|
accuracy_decimals: 1
|
|
|
|
filters:
|
|
|
|
- calibrate_linear:
|
|
|
|
- 47608 -> 0
|
|
|
|
- 590566 -> 100
|
|
|
|
unit_of_measurement: "%"
|
|
|
|
|
|
|
|
chlorine_pump:
|
|
|
|
pump: pump_switch
|
|
|
|
sensor: chlorine_sensor
|
|
|
|
id: chlorine_pump_component
|
2024-05-24 14:00:34 +00:00
|
|
|
disable_clock: false
|
2024-05-27 12:43:10 +00:00
|
|
|
proportional_band: 200
|
2024-05-27 15:06:53 +00:00
|
|
|
target: 700
|
2024-05-27 12:43:10 +00:00
|
|
|
# get_target: !lambda return id(chlorine_target).state;
|
2024-05-12 21:02:52 +00:00
|
|
|
on_pump_value:
|
|
|
|
- lambda: |-
|
|
|
|
if(pState != id(last_pump_state)){
|
|
|
|
id(last_pump_state) = pState;
|
|
|
|
}
|
|
|
|
on_cycle_start:
|
|
|
|
- lambda: |-
|
|
|
|
id(cycle_text_info).publish_state("tOn: " + std::to_string(tOn) + "s\n tOff: " + std::to_string(tOff) + "s");
|
2024-05-10 10:37:19 +00:00
|
|
|
|
|
|
|
# Here is space for any display implementation that could possibliy be. Have fun OK
|