Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- esphome:
- name: sonoff-basic-05
- platform: ESP8266
- board: sonoff_basic
- on_loop:
- then:
- - if:
- condition:
- not:
- script.is_running: cycle_pump
- then:
- - script.execute: cycle_pump
- # Enable logging
- logger:
- globals:
- - id: pump_enabled
- type: bool
- restore_value: no
- initial_value: 'false'
- - id: pump_interval
- type: int
- restore_value: yes
- initial_value: '12'
- - id: pump_on_time
- type: int
- restore_value: yes
- initial_value: '6'
- # Enable Home Assistant API
- api:
- web_server:
- port: 80
- ota:
- password: "c0f858446b950758eb0d433b50ae73e4"
- wifi:
- ssid: !secret iot_ssid
- password: !secret iot_pass
- # Enable fallback hotspot (captive portal) in case wifi connection fails
- ap:
- ssid: "Sonoff-Basic-05 Fallback Hotspot"
- password: !secret iot_pass
- captive_portal:
- binary_sensor:
- - platform: gpio
- pin:
- number: GPIO0
- mode:
- input: true
- pullup: true
- inverted: true
- name: "Sonoff Basic Button"
- on_press:
- - switch.toggle: pump_relay
- - platform: homeassistant
- name: "Hydro Pump Enable"
- internal: false
- entity_id: input_boolean.hydro_pump_enable
- on_state:
- then:
- - lambda: |-
- id(pump_enabled) = x;
- switch:
- - platform: gpio
- name: "Pump Relay"
- id: pump_relay
- pin: GPIO12
- - platform: restart
- name: Restart
- - platform: template
- name: "Template Switch"
- optimistic: true
- id: template_swi
- #lambda: 'return id(pump_enabled);'
- status_led:
- pin:
- number: GPIO13
- inverted: yes
- number:
- - platform: template
- name: "hydro_pump_interval_set"
- optimistic: true
- initial_value: 9
- min_value: 0
- max_value: 60
- step: 1
- on_value:
- then:
- - globals.set:
- id: pump_interval
- value: !lambda 'return x;'
- - platform: template
- name: "hydro_pump_on_time_set"
- optimistic: true
- min_value: 0
- max_value: 25
- step: 0.25
- on_value:
- then:
- - globals.set:
- id: pump_on_time
- value: !lambda 'return x;'
- sensor:
- - platform: homeassistant
- name: Hydro Pump Interval
- entity_id: input_number.hydro_pump_interval
- internal: false
- on_value:
- then:
- - lambda: |-
- id(pump_interval) = x;
- - platform: homeassistant
- name: Hydro Pump On Time
- internal: false
- entity_id: input_number.hydro_pump_on_time
- on_value:
- then:
- - lambda: |-
- id(pump_on_time) = x;
- script:
- - id: cycle_pump
- then:
- - if:
- condition:
- #lambda: |-
- # return id(pump_enabled) = true;
- switch.is_on: template_swi
- then:
- - logger.log: "Started First (Interval-run time) Delay"
- - delay: !lambda |-
- return (id(pump_interval) - id(pump_on_time)) * 1000;
- - switch.turn_on: pump_relay
- - logger.log: "Started second (run time) Delay"
- - delay: !lambda |-
- return id(pump_on_time) * 1000;
- - switch.turn_off: pump_relay
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement