Code for Main Control - It's long but worth it!
substitutions:
device_description: "Embedded ESP Relay Module - IP Address: 192.168.1.35"
esphome:
name: main-control-embedded
friendly_name: Main-Control (embedded)
comment: ${device_description}
esp8266:
board: esp01_1m
logger:
api:
encryption:
key: "HIDDEN FOR MY SANITY"
ota:
platform: esphome
password: "HIDDEN FOR MY SANITY"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.1.35
gateway: 192.168.1.1
subnet: 255.255.255.0
ap:
ssid: "Main-Control-Embedded"
password: "HIDDEN FOR MY SANITY"
captive_portal:
web_server:
port: 80
# Notes for this code.bin file.
# Main system control. ESP embedded
# 8 relays 5 to 36 volt input
# 3 spare inputs (rx, tx, gpio0 (boot control))
switch:
# 'Water Pumps'
- platform: gpio
pin: 16
name: "Relay 1"
id: relay1
- platform: template
name: Pump Timer 15 Min
lambda: |-
if (id(relay1).state) {
return true;
} else {
return false;
}
turn_on_action:
then:
- switch.turn_on: relay1
- delay: 15min
- switch.turn_off: relay1
# 'Shower Pump'
- platform: gpio
pin: 14
name: "Relay 2"
id: relay2
- platform: template
name: Pump Timer 1 Min
lambda: |-
if (id(relay1).state) {
return true;
} else {
return false;
}
turn_on_action:
then:
- switch.turn_on: relay1
- delay: 1min
- switch.turn_off: relay1
# 'Water Heater - Electric (400W)'
- platform: gpio
pin: 12
name: "Relay 3"
id: relay3
# 'Radio/Sub woofer'
- platform: gpio
pin: 13
name: "Relay 4"
id: relay4
# 'Garage Spot Lights (white or yellow)'
- platform: gpio
pin: 15
name: "Relay 5"
id: relay5
# 'DC to DC Charger'
- platform: gpio
pin: 0
name: "Relay 6"
id: relay6
# 'Inverter'
- platform: gpio
pin: 4
name: "Relay 7"
id: relay7
# 'Garage Light'
- platform: gpio
pin: 5
name: "Relay 8"
id: relay8
button:
- platform: template
name: Pump Timer 15 Min
on_press:
then:
- switch.turn_on: relay1
- delay: 15min
- switch.turn_off: relay1
- platform: template
name: Pump Timer 1 Min
on_press:
then:
- switch.turn_on: relay1
- delay: 1min
- switch.turn_off: relay1
- platform: template
name: Inverter Timer 1 Hour
on_press:
then:
- switch.turn_on: relay7
- delay: 60min
- switch.turn_off: relay7
- platform: template
name: Inverter Timer 3 Hours
on_press:
then:
- switch.turn_on: relay7
- delay: 180min
- switch.turn_off: relay7