Files
esphome-configs/mcu-well.yaml
T
randy 7517c301ac Status LED on every ATOM device (except the vehicle beacons)
common/status_led_atom.yaml puts common/status_led.yaml on the ATOM Lite's
own RGB LED (G27, 64 RMT symbols to leave room for IR/RF). echo-1 uses its
existing LED light.
2026-09-30 08:58:16 +02:00

374 lines
10 KiB
YAML

---
# Hardware: M5Stack ATOM Lite + ATOM Hub Switch
# Pinout:
# GPIO21 -> i2c (i2c scl)
# GPIO23 -> modbus_uart (uart tx_pin)
# GPIO25 -> i2c (i2c sda)
# GPIO26 Grove SDA
# GPIO27 NEO (ATOM RGB LED) -> atom_led (status LED, common/status_led_atom.yaml)
# GPIO32 Grove SCL
# GPIO33 -> modbus_uart (uart rx_pin)
# I2C:
# 0x27 relay_module (pca9554)
substitutions:
device: well
name: Well
area: Outside
comment: Well | Irrigation A
esphome:
name: mcu-${device}
friendly_name: ${name}
area: ${area}
comment: ${comment}
# friendly_name: mcu-well
# on_boot:
# priority: -10
# then:
# - switch.turn_off: irrigation_relay_1
# - delay: 2s
# - switch.turn_off: irrigation_relay_2
# - delay: 2s
# - switch.turn_off: irrigation_relay_3
# - delay: 2s
# - switch.turn_off: irrigation_relay_4
# - delay: 2s
# - switch.turn_off: irrigation_relay_5
esp32:
variant: esp32
toolchain: esp-idf
framework:
type: esp-idf
advanced:
sram1_as_iram: true
packages:
common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
status_led: !include common/status_led_atom.yaml
api:
actions:
- action: irrigation_morning
then:
- lambda: |-
id(relay_module).setup();
- switch.turn_on: irrigation_relay_1
- delay: 4minutes
- switch.turn_off: irrigation_relay_1
- delay: 2minutes
- lambda: |-
id(relay_module).setup();
- switch.turn_on: irrigation_relay_1
- delay: 4minutes
- switch.turn_off: irrigation_relay_1
- delay: 2minutes
- lambda: |-
id(relay_module).setup();
- switch.turn_on: irrigation_relay_2
- delay: 4minutes
- switch.turn_off: irrigation_relay_2
- delay: 2minutes
- lambda: |-
id(relay_module).setup();
- switch.turn_on: irrigation_relay_2
- delay: 4minutes
- switch.turn_off: irrigation_relay_2
- delay: 2minutes
- lambda: |-
id(relay_module).setup();
- switch.turn_on: irrigation_relay_3
- delay: 4minutes
- switch.turn_off: irrigation_relay_3
# - switch.turn_on: irrigation_relay_4
# - delay: 40minutes
# - switch.turn_off: irrigation_relay_4
- action: irrigation_grass
then:
- lambda: |-
id(relay_module).setup();
- switch.turn_on: irrigation_relay_1
- delay: 5minutes
- switch.turn_off: irrigation_relay_1
- delay: 2minutes
- lambda: |-
id(relay_module).setup();
- switch.turn_on: irrigation_relay_2
- delay: 5minutes
- switch.turn_off: irrigation_relay_2
- delay: 2minutes
- lambda: |-
id(relay_module).setup();
- switch.turn_on: irrigation_relay_3
- delay: 2minutes
- switch.turn_off: irrigation_relay_3
- action: irrigation_patio
then:
- lambda: |-
id(relay_module).setup();
- switch.turn_on: irrigation_relay_5
- delay: 30sec
- switch.turn_off: irrigation_relay_5
script:
- id: modbus_turn_on_ch1
mode: single
then:
- lambda: |-
ESP_LOGD("modbus", "Sending Channel 0 ON command as byte array");
// Channel 0 open command: [0x01, 0x05, 0x00, 0x00, 0xFF, 0x00, 0x8C, 0x3A]
uint8_t data[8] = {0x01, 0x06, 0x00, 0x01, 0x01, 0x00, 0xD9, 0x9A};
id(modbus_uart).write_array(data, 8);
- id: modbus_turn_off_ch1
mode: single
then:
- lambda: |-
ESP_LOGD("modbus", "Sending Channel 0 OFF command as byte array");
// Channel 0 close command: [0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0xCD, 0xCA]
uint8_t data[8] = {0x01, 0x06, 0x00, 0x01, 0x02, 0x00, 0xD9, 0x6A};
id(modbus_uart).write_array(data, 8);
i2c:
sda: 25
scl: 21
scan: true
pca9554:
- id: relay_module
address: 0x27
uart:
id: modbus_uart
tx_pin: 23
rx_pin: 33
baud_rate: 9600
data_bits: 8
parity: NONE
stop_bits: 1
rx_buffer_size: 256
modbus:
id: modbus_hub
uart_id: modbus_uart
modbus_controller:
- id: n4dig08
address: 0x01
modbus_id: modbus_hub
setup_priority: -10
logger:
level: DEBUG # Alebo VERY_VERBOSE, ak chceš vidieť úplne všetko
logs:
modbus: DEBUG
modbus_controller: DEBUG
sprinkler:
- id: lawn_sprinkler_ctrlr
main_switch: "Irrigation A"
auto_advance_switch: "Irrigation A Auto Advance"
# reverse_switch: "Lawn Sprinklers Reverse"
multiplier_number: "Irrigation A Multiplier"
repeat_number: "Irrigation A Repeat"
valve_open_delay: 2min
valves:
- valve_switch: "Irrigation A1"
enable_switch: "Irrigation A1 Enable"
run_duration_number: "Irrigation A1 Run Duration"
valve_switch_id: irrigation_relay_1
- valve_switch: "Irrigation A2"
enable_switch: "Irrigation A2 Enable"
run_duration_number: "Irrigation A2 Run Duration"
valve_switch_id: irrigation_relay_2
- valve_switch: "Irrigation A3"
enable_switch: "Irrigation A3 Enable"
run_duration_number: "Irrigation A3 Run Duration"
valve_switch_id: irrigation_relay_3
- valve_switch: "Irrigation A4"
enable_switch: "Irrigation A4 Enable"
run_duration_number: "Irrigation A4 Run Duration"
valve_switch_id: irrigation_relay_4
- valve_switch: "Irrigation A5"
enable_switch: "Irrigation A5 Enable"
run_duration_number: "Irrigation A5 Run Duration"
valve_switch_id: irrigation_relay_5
switch:
- platform: gpio
name: "Irrigation Valve A1"
id: irrigation_relay_1
interlock: &interlock_group [irrigation_relay_1, irrigation_relay_2, irrigation_relay_3, irrigation_relay_4, irrigation_relay_5, irrigation_relay_6, irrigation_relay_7, irrigation_relay_8]
pin:
pca9554: relay_module
number: 0
mode: OUTPUT
- platform: gpio
name: "Irrigation Valve A2"
id: irrigation_relay_2
interlock: *interlock_group
pin:
pca9554: relay_module
number: 1
mode: OUTPUT
- platform: gpio
name: "Irrigation Valve A3"
id: irrigation_relay_3
interlock: *interlock_group
pin:
pca9554: relay_module
number: 2
mode: OUTPUT
- platform: gpio
name: "Irrigation Valve A4"
id: irrigation_relay_4
interlock: *interlock_group
pin:
pca9554: relay_module
number: 3
mode: OUTPUT
- platform: gpio
name: "Irrigation Valve A5"
id: irrigation_relay_5
interlock: *interlock_group
pin:
pca9554: relay_module
number: 4
mode: OUTPUT
- platform: gpio
name: "Irrigation Valve A6"
id: irrigation_relay_6
interlock: *interlock_group
pin:
pca9554: relay_module
number: 5
mode: OUTPUT
- platform: gpio
name: "Irrigation Valve A7"
id: irrigation_relay_7
interlock: *interlock_group
pin:
pca9554: relay_module
number: 6
mode: OUTPUT
- platform: gpio
name: "Irrigation Valve A8"
id: irrigation_relay_8
interlock: *interlock_group
pin:
pca9554: relay_module
number: 7
mode: OUTPUT
# - platform: gpio
# name: "${name} Relay 1"
# id: relay_1
# pin:
# number: 22
# mode: OUTPUT
# - platform: gpio
# name: "${name} Relay 2"
# id: relay_2
# interlock: *interlock_group
# pin:
# number: 19
# mode: OUTPUT
valve:
- platform: template
name: "Irrigation Valve A1"
lambda: |-
if (id(irrigation_relay_1).state) {
return VALVE_OPEN;
} else {
return VALVE_CLOSED;
}
open_action:
- switch.turn_on: irrigation_relay_1
close_action:
- switch.turn_off: irrigation_relay_1
- platform: template
name: "Irrigation Valve A2"
lambda: |-
if (id(irrigation_relay_2).state) {
return VALVE_OPEN;
} else {
return VALVE_CLOSED;
}
open_action:
- switch.turn_on: irrigation_relay_2
close_action:
- switch.turn_off: irrigation_relay_2
- platform: template
name: "Irrigation Valve A3"
lambda: |-
if (id(irrigation_relay_3).state) {
return VALVE_OPEN;
} else {
return VALVE_CLOSED;
}
open_action:
- switch.turn_on: irrigation_relay_3
close_action:
- switch.turn_off: irrigation_relay_3
- platform: template
name: "Irrigation Valve A4"
lambda: |-
if (id(irrigation_relay_4).state) {
return VALVE_OPEN;
} else {
return VALVE_CLOSED;
}
open_action:
- switch.turn_on: irrigation_relay_4
close_action:
- switch.turn_off: irrigation_relay_4
- platform: template
name: "Irrigation Valve A5"
lambda: |-
if (id(irrigation_relay_5).state) {
return VALVE_OPEN;
} else {
return VALVE_CLOSED;
}
open_action:
- switch.turn_on: irrigation_relay_5
close_action:
- switch.turn_off: irrigation_relay_5
- platform: template
name: "Irrigation Valve A6"
lambda: |-
if (id(irrigation_relay_6).state) {
return VALVE_OPEN;
} else {
return VALVE_CLOSED;
}
open_action:
- switch.turn_on: irrigation_relay_6
close_action:
- switch.turn_off: irrigation_relay_6
- platform: template
name: "Irrigation Valve A7"
lambda: |-
if (id(irrigation_relay_7).state) {
return VALVE_OPEN;
} else {
return VALVE_CLOSED;
}
open_action:
- switch.turn_on: irrigation_relay_7
close_action:
- switch.turn_off: irrigation_relay_7
- platform: template
name: "Irrigation Valve A8"
lambda: |-
if (id(irrigation_relay_8).state) {
return VALVE_OPEN;
} else {
return VALVE_CLOSED;
}
open_action:
- switch.turn_on: irrigation_relay_8
close_action:
- switch.turn_off: irrigation_relay_8