espHome-NBS-files/chlorPump.yaml

205 lines
4.4 KiB
YAML
Raw Normal View History

2024-05-10 10:37:19 +00:00
esphome:
name: chlorine-pump
project:
name: nbsgamesat.chlorine-pump
version: "0.7"
on_boot:
priority: 600
then:
- 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:
2024-11-18 13:08:12 +00:00
- platform: esphome
password: !secret cp_password
2024-05-10 10:37:19 +00:00
external_components:
- source:
type: local
path: external_components/
components: [ chlorine_pump, ezo_orp_i2c]
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
on_connect:
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
pin: D6
2024-05-10 10:37:19 +00:00
id: pump_switch
- platform: gpio
pin:
number: D0
inverted: true
id: wifi_status_led
2024-05-10 10:37:19 +00:00
binary_sensor:
- platform: gpio
id: pool_pump
pin:
number: D5
inverted: true
mode:
input: true
pullup: true
on_state:
- script.execute:
id: manage_power
switch_state: !lambda return id(power).state;
- 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
- 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
i2c:
2024-05-10 10:37:19 +00:00
sensor:
- platform: ezo_orp_i2c
2024-05-10 10:37:19 +00:00
id: chlorine_sensor
name: Chlorine
update_interval: 5s
- platform: hx711
name: "Chlorine Canister Levels"
dout_pin: D7
clk_pin: D8
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
disable_clock: false
proportional_band: 200
cycle_time: 300
2024-05-27 15:06:53 +00:00
target: 700
# get_target: !lambda return id(chlorine_target).state;
cycle_modifiers:
min_on_time: 30
max_on_time: 240
on_time_multiplier: 0.5
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