177 lines
3.8 KiB
YAML
177 lines
3.8 KiB
YAML
esphome:
|
|
name: a3pool
|
|
board: nodemcuv2
|
|
platform: ESP8266
|
|
|
|
ota:
|
|
password: !secret a3poolpasswd
|
|
|
|
api:
|
|
encryption:
|
|
key: !secret a3poolkey
|
|
|
|
logger:
|
|
|
|
wifi:
|
|
ssid: !secret wifi_ssid
|
|
password: !secret wifi_password
|
|
fast_connect: true
|
|
|
|
binary_sensor:
|
|
- platform: gpio
|
|
pin:
|
|
number: 12
|
|
inverted: true
|
|
mode:
|
|
input: true
|
|
pullup: true
|
|
id: pump_state
|
|
|
|
number:
|
|
- platform: template
|
|
name: "Start Hour"
|
|
id: start_h
|
|
optimistic: true
|
|
min_value: 0
|
|
max_value: 23
|
|
restore_value: true
|
|
initial_value: 8
|
|
mode: box
|
|
step: 1
|
|
- platform: template
|
|
name: "Start Minute"
|
|
id: start_m
|
|
optimistic: true
|
|
min_value: 0
|
|
max_value: 59
|
|
initial_value: 0
|
|
restore_value: true
|
|
mode: box
|
|
step: 1
|
|
- platform: template
|
|
name: "End Hour"
|
|
id: end_h
|
|
optimistic: true
|
|
min_value: 0
|
|
max_value: 23
|
|
restore_value: true
|
|
initial_value: 20
|
|
mode: box
|
|
step: 1
|
|
- platform: template
|
|
name: "End Minute"
|
|
id: end_m
|
|
optimistic: true
|
|
min_value: 0
|
|
max_value: 59
|
|
restore_value: true
|
|
initial_value: 0
|
|
mode: box
|
|
step: 1
|
|
|
|
button:
|
|
- platform: template
|
|
name: "Sync To Clock"
|
|
on_press:
|
|
then:
|
|
- lambda: |-
|
|
int startMins = (int) (id(start_h).state * 60) + id(start_m).state;
|
|
int endMins = (int) (id(end_h).state * 60) + id(end_m).state;
|
|
int nowMins = (id(a3poolTime).now().hour * 60) + id(a3poolTime).now().minute;
|
|
|
|
if(!id(control).state){
|
|
// Make sure wierd error or whatever
|
|
return;
|
|
}
|
|
|
|
if(startMins < endMins){
|
|
if(startMins < nowMins && nowMins < endMins){
|
|
id(pump).turn_on();
|
|
}
|
|
else{
|
|
id(pump).turn_off();
|
|
}
|
|
}
|
|
else if(startMins > endMins){
|
|
if(endMins < nowMins && nowMins < startMins){
|
|
id(pump).turn_off();
|
|
}
|
|
else{
|
|
id(pump).turn_on();
|
|
}
|
|
}
|
|
|
|
|
|
switch:
|
|
- platform: gpio
|
|
pin: 5
|
|
id: relay
|
|
on_turn_on:
|
|
- delay: 500ms
|
|
- switch.turn_off: relay
|
|
- platform: template
|
|
name: "Automate Control"
|
|
id: control
|
|
optimistic: true
|
|
restore_mode: RESTORE_DEFAULT_OFF
|
|
- platform: template
|
|
optimistic: false
|
|
name: pump
|
|
id: pump
|
|
lambda: |-
|
|
if (id(pump_state).state) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
turn_on_action:
|
|
- if:
|
|
condition:
|
|
lambda: 'return id(pump_state).state == false;'
|
|
then:
|
|
- switch.turn_on: relay
|
|
- delay: 500ms
|
|
- switch.turn_off: relay
|
|
turn_off_action:
|
|
- if:
|
|
condition:
|
|
lambda: 'return id(pump_state).state;'
|
|
then:
|
|
- switch.turn_on: relay
|
|
- delay: 500ms
|
|
- switch.turn_off: relay
|
|
|
|
time:
|
|
timezone: "Europe/Vienna"
|
|
id: a3poolTime
|
|
platform: sntp
|
|
on_time:
|
|
- seconds: 0
|
|
months: 4-10
|
|
then:
|
|
- if:
|
|
condition:
|
|
lambda: 'return id(a3poolTime).now().hour == (int) id(start_h).state && id(a3poolTime).now().minute == (int) id(start_m).state && id(control).state;'
|
|
then:
|
|
- switch.turn_on: pump
|
|
- seconds: 0
|
|
months: 4-10
|
|
then:
|
|
- if:
|
|
condition:
|
|
lambda: 'return id(a3poolTime).now().hour == (int) id(end_h).state && id(a3poolTime).now().minute == (int) id(end_m).state && id(control).state;'
|
|
then:
|
|
- switch.turn_off: pump
|
|
|
|
dallas:
|
|
- pin: D4
|
|
update_interval: 10s
|
|
sensor:
|
|
- platform: dallas
|
|
address: 0xd1000007494b3628
|
|
name: "Pool Temperature"
|
|
- platform: dallas
|
|
address: 0x440000073de2e728
|
|
name: "Solar Temperature"
|
|
|