Files
esphome-configs/mcu-mains-power.yaml
T
randy bb76912023 Set framework.advanced.flash_chip on ESP32 devices to save IRAM
Values come from ESPHome's own hint in the log of each online device
("Set flash_chip: ... to save IRAM"). Devices that were off got the value of
an identical board (ESP32-PICO-D4 ATOM/Stamp Pico: gd, JC3248W535: generic,
POW Elite: gd), marked as not read from the device.
2026-09-30 11:57:30 +02:00

242 lines
5.7 KiB
YAML

---
# Hardware: M5Stack ATOM Lite
# Pinout:
# GPIO1 UART0 TX
# GPIO3 UART0 RX
# GPIO12 IR
# GPIO19 NC
# GPIO21 I2C1 SCL
# GPIO22 1-WIRE
# GPIO23 UART1 RX
# GPIO25 I2C1 SDA
# GPIO26 I2C0 SDA -> uart_modbus (uart rx_pin)
# GPIO27 NEO -> atom_led (status LED, common/status_led_atom.yaml)
# GPIO32 I2C0 SCL -> uart_modbus (uart tx_pin)
# GPIO33 UART1 TX
# GPIO39 BUTTON
substitutions:
device: mains-power
name: Mains Power
area: Room
comment: Mains Power Monitoring
esphome:
name: mcu-${device}
friendly_name: ${name}
area: ${area}
comment: ${comment}
areas:
- id: local_area
name: ${area}
devices:
- id: mains
name: Mains
area_id: local_area
esp32:
variant: esp32
toolchain: esp-idf
framework:
advanced:
flash_chip: gd
type: esp-idf
packages:
common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
status_led: !include common/status_led_atom.yaml
modbus:
uart_id: uart_modbus
uart:
- id: uart_modbus
rx_pin: 26
tx_pin: 32
baud_rate: 9600
stop_bits: 2
# debug:
sensor:
# - platform: template
# name: Total Daily Energy
# id: mains_daily_energy
# lambda: |-
# return (id(mains_l1_total_daily_energy).state + id(mains_l3_total_daily_energy).state + id(mains_l3_total_daily_energy).state);
# update_interval: 60s
# L1
- platform: pzemac
address: 10
id: pzemac_l1
current:
name: L1 Current
device_id: mains
voltage:
name: L1 Voltage
device_id: mains
energy:
name: L1 Energy
id: mains_l1_energy
device_id: mains
power:
name: L1 Power
id: mains_l1_power
device_id: mains
frequency:
name: L1 Frequency
device_id: mains
power_factor:
name: L1 Power Factor
device_id: mains
update_interval: 20s
# - platform: total_daily_energy
# name: L1 Total Daily Energy
# power_id: mains_l1_power
# id: mains_l1_total_daily_energy
# filters:
# - multiply: 0.001
# unit_of_measurement: kWh
# icon: mdi:counter
# - platform: integration
# name: L1 Energy Meter
# sensor: mains_l1_power
# time_unit: h
# filters:
# - lambda: return x * (0.001) + 2282;
# unit_of_measurement: kWh
# icon: mdi:counter
# L2
- platform: pzemac
address: 11
id: pzemac_l2
current:
name: L2 Current
device_id: mains
voltage:
name: L2 Voltage
device_id: mains
energy:
name: L2 Energy
id: mains_l2_energy
device_id: mains
power:
name: L2 Power
id: mains_l2_power
device_id: mains
frequency:
name: L2 Frequency
device_id: mains
power_factor:
name: L2 Power Factor
device_id: mains
update_interval: 20s
# - platform: total_daily_energy
# name: L2 Total Daily Energy
# id: mains_l2_total_daily_energy
# power_id: mains_l2_power
# filters:
# - multiply: 0.001
# unit_of_measurement: kWh
# icon: mdi:counter
# - platform: integration
# name: L2 Energy Meter
# sensor: mains_l2_power
# time_unit: h
# filters:
# - lambda: return x * (0.001) + 2282;
# unit_of_measurement: kWh
# icon: mdi:counter
# L3
- platform: pzemac
address: 12
id: pzemac_l3
current:
name: L3 Current
device_id: mains
voltage:
name: L3 Voltage
device_id: mains
energy:
name: L3 Energy
id: mains_l3_energy
device_id: mains
power:
name: L3 Power
id: mains_l3_power
device_id: mains
frequency:
name: L3 Frequency
device_id: mains
power_factor:
name: L3 Power Factor
device_id: mains
update_interval: 20s
# - platform: total_daily_energy
# name: L3 Total Daily Energy
# power_id: mains_l3_power
# id: mains_l3_total_daily_energy
# filters:
# - multiply: 0.001
# unit_of_measurement: kWh
# icon: mdi:counter
# - platform: integration
# name: L3 Energy Meter"
# sensor: mains_l3_power
# time_unit: h
# filters:
# - lambda: return x * (0.001) + 2282;
# unit_of_measurement: kWh
# icon: mdi:counter
# TOTAL: L1+L2+L3
- platform: template
name: Power
id: total_mains_power
device_id: mains
device_class: power
state_class: measurement
unit_of_measurement: W
accuracy_decimals: 1
lambda: |-
return id(mains_l1_power).state + id(mains_l2_power).state + id(mains_l3_power).state ;
# - platform: template
# name: Total Daily Energy
# id: mains_total_daily_energy
# icon: mdi:counter
# device_class: energy
# # state_class: measurement
# state_class: total_increasing
# unit_of_measurement: kWh
# accuracy_decimals: 1
# lambda: |-
# return id(mains_l1_total_daily_energy).state + id(mains_l2_total_daily_energy).state + id(mains_l3_total_daily_energy).state ;
- platform: template
name: Energy
device_id: mains
icon: mdi:counter
device_class: energy
state_class: total_increasing
unit_of_measurement: kWh
accuracy_decimals: 1
filters:
- multiply: 0.001
lambda: |-
return id(mains_l1_energy).state + id(mains_l2_energy).state + id(mains_l3_energy).state;
button:
- platform: template
name: Energy Zero
device_id: mains
on_press:
- pzemac.reset_energy: pzemac_l1
- pzemac.reset_energy: pzemac_l2
- pzemac.reset_energy: pzemac_l3
time:
- id: !extend ha_time
on_time:
- cron: '0 0 0 * * *'
then:
- pzemac.reset_energy: pzemac_l1
- pzemac.reset_energy: pzemac_l2
- pzemac.reset_energy: pzemac_l3