espHome-NBS-files/chlorPump.yaml

182 lines
3.8 KiB
YAML

esphome:
name: chlorine-pump
project:
name: nbsgamesat.chlorine-pump
version: "0.2"
on_boot:
priority: 600
then:
output.turn_on: whatever
esp8266:
board: nodemcuv2
# Enable logging
logger:
ota:
password: !secret cp_password
external_components:
- source:
type: local
path: external_components/
components: [ analog_orp, chlorine_pump ]
globals:
- id: last_pump_state
type: bool
restore_value: no
initial_value: "false"
- id: last_cycle_info
type: std::string
api:
encryption:
key: !secret cp_key
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
on_connect:
output.turn_off: whatever
output:
- platform: gpio
pin: D6
id: pump_switch
- platform: gpio
pin:
number: D0
inverted: true
id: whatever
binary_sensor:
- platform: gpio
id: pool_pump
pin:
number: D2
inverted: true
mode:
input: true
pullup: true
on_state:
- script.execute:
id: manage_power
switch_state: !lambda return id(power).state;
- 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
sensor:
- platform: analog_orp
name: Chlorine
id: chlorine_sensor
pin: A0
zero_point: 673
inverted: true
update_interval: 1s
# print_raw: true
average:
mesurements: 15
send_state_every: 10
# on_value_read:
# - lambda: |-
# ESP_LOGD("WHAT", "Chlorine_value, %.1f", x);
- platform: hx711
name: "Chlorine Canister Levels"
dout_pin: D5
clk_pin: D1
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
target: 700
disable_clock: true
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");
# Here is space for any display implementation that could possibliy be. Have fun OK