esphome: name: chlorine-pump project: name: nbsgamesat.chlorine-pump version: "0.7" on_boot: priority: 600 then: output.turn_on: wifi_status_led esp8266: board: nodemcuv2 # Enable logging logger: ota: password: !secret cp_password external_components: - source: type: local path: external_components/ components: [ 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: wifi_status_led on_disconnect: output.turn_on: wifi_status_led output: - platform: gpio pin: D6 id: pump_switch - platform: gpio pin: number: D0 inverted: true id: wifi_status_led 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: adc name: Chlorine id: chlorine_sensor unit_of_measurement: "mV" icon: "mdi:test-tube" pin: A0 update_interval: 200ms filters: - multiply: 3.3 - offset: -1.5 - multiply: 1000.0 - median: window_size: 25 send_every: 25 send_first_at: 25 - offset: 30.0 - 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: "%" - platform: template name: debug_last_raw_value id: debug_last_raw_value accuracy_decimals: 0 unit_of_measurement: "points" chlorine_pump: pump: pump_switch sensor: chlorine_sensor id: chlorine_pump_component target: 700 disable_clock: false proportional_band: 400 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