Skip to content

Instantly share code, notes, and snippets.

@ad3m3r5
Last active December 23, 2024 02:43
Show Gist options
  • Save ad3m3r5/ed74cecb14d2994d36b2550c12a93389 to your computer and use it in GitHub Desktop.
Save ad3m3r5/ed74cecb14d2994d36b2550c12a93389 to your computer and use it in GitHub Desktop.
# final config from @ad3m3r5, most of the original yaml is from:
# - https://digiblur.com/2024/03/14/emporia-vue-gen3-esp32-esphome-home-assistant/
# - https://github.com/emporia-vue-local/esphome?tab=readme-ov-file#writing-configuration
# home assistant, esphome, esp32, emporia vue 3, config
# Ensure "API_KEY" and "PASSWORD" are replaced with real values
esphome:
name: esp32-emporia-vue-3
friendly_name: esp32-emporia-vue-3
external_components:
# UPDATES FOR Vue 3
- source: github://emporia-vue-local/esphome@vue3
components:
- emporia_vue
esp32:
board: esp32dev
framework:
type: esp-idf
version: recommended
preferences:
# the default of 1min is far too short--flash chip is rated
# for approx 100k writes.
flash_write_interval: "48h"
# Enable logging
logger:
logs:
# by default, every reading will be printed to the UART, which is very slow
# This will disable printing the readings but keep other helpful messages
sensor: INFO
# Enable Home Assistant API
api:
encryption:
key: "API_KEY"
safe_mode:
disabled: false
ota:
- platform: esphome
password: "PASSWORD"
#wifi:
# ssid: !secret wifi_ssid
# password: !secret wifi_password
# Enable fallback hotspot in case wifi connection fails
# ap:
# ssid: "esp32-emporia-vue-3"
# password: !secret fallback_password
ethernet:
type: RTL8201
mdc_pin: GPIO32
mdio_pin: GPIO33
clk_mode: GPIO0_IN
# Optional manual IP
# manual_ip:
# static_ip: x.x.x.x
# gateway: x.x.x.x
# subnet: 255.255.255.0
# Configure the two status LEDs on the Emporia Vue v3 case
# https://github.com/emporia-vue-local/esphome/discussions/264#discussioncomment-9788390
light:
- platform: status_led
#name: "D3_LED"
id: wifi_led
#pin: 2
pin:
number: 2
ignore_strapping_warning: true
#restore_mode: ALWAYS_ON
restore_mode: RESTORE_DEFAULT_ON
#entity_category: config
- platform: status_led
#name: "D31_LED"
id: ethernet_led
pin: 4
#restore_mode: ALWAYS_ON
restore_mode: RESTORE_DEFAULT_ON
#entity_category: config
switch:
- platform: restart
name: Restart
i2c:
sda: 5
scl: 18
scan: false
# recommended range is 50-200kHz
frequency: 200kHz
id: i2c_a
time:
- platform: sntp
id: sntp_time
# these are called references in YAML. They allow you to reuse
# this configuration in each sensor, while only defining it once
.defaultfilters:
# throttle_avg - emporia-vue-local
- &throttle_avg
# average all raw readings together over a 5 second span before publishing
throttle_average: 5s
- &throttle_time
# only send the most recent measurement every 60 seconds
throttle: 60s
# moving_avg - digitalblur
- &moving_avg
# we capture a new sample every 0.24 seconds, so the time can
# be calculated from the number of samples as n * 0.24.
sliding_window_moving_average:
# we average over the past 2.88 seconds
window_size: 24
# we push a new value every 1.44 seconds
send_every: 12
- &invert
# invert and filter out any values below 0.
lambda: 'return max(-x, 0.0f);'
- &pos
# filter out any values below 0.
lambda: 'return max(x, 0.0f);'
- &abs
# take the absolute value of the value
lambda: 'return abs(x);'
sensor:
- platform: emporia_vue
i2c_id: i2c_a
phases:
# Verify that this specific phase/leg is connected to correct input wire color on device listed below
- id: phase_a
# Vue device wire color
input: BLACK
# 0.022 is used as the default as starting point but may need adjusted to ensure accuracy
calibration: 0.0194
# To calculate new calibration value use the formula <in-use calibration value> * <accurate voltage> / <reporting voltage>
voltage:
name: "Phase A Voltage"
filters: [*pos, *pos]
frequency:
name: "Phase A Frequency"
filters: [*throttle_avg, *pos]
# Verify that this specific phase/leg is connected to correct input wire color on device listed below
- id: phase_b
# Vue device wire color
input: RED
# 0.022 is used as the default as starting point but may need adjusted to ensure accuracy
calibration: 0.0194
# To calculate new calibration value use the formula <in-use calibration value> * <accurate voltage> / <reporting voltage>
voltage:
name: "Phase B Voltage"
filters: [*moving_avg, *pos]
phase_angle:
name: "Phase B Phase Angle"
filters: [*throttle_avg, *pos]
ct_clamps:
- phase_id: phase_a
# Verify the CT going to this device input also matches the phase/leg
input: "A"
# NECESSARY IF USING DEFAULT VUE 2 SETTINGS
# https://github.com/emporia-vue-local/esphome/discussions/264#discussioncomment-8899111
#input: "C"
power:
name: "Phase A Power"
id: phase_a_power
device_class: power
#filters: [*moving_avg, *pos]
# https://github.com/emporia-vue-local/esphome/discussions/264#discussioncomment-9170097
filters: [*moving_avg, *invert]
# TESTING 0.0 W Values - https://github.com/emporia-vue-local/esphome?tab=readme-ov-file#im-seeing-zeros-on-certain-current-clamps
#filters: []
# TESTING BASED OFF OF https://github.com/emporia-vue-local/esphome/discussions/264#discussioncomment-8899111
#filters: [*abs]
- phase_id: phase_b
# Verify the CT going to this device input also matches the phase/leg
input: "B"
power:
name: "Phase B Power"
id: phase_b_power
device_class: power
# https://github.com/emporia-vue-local/esphome/discussions/264#discussioncomment-9170097
filters: [*moving_avg, *invert]
#filters: [*moving_avg, *pos]
# TESTING 0.0 W Values - https://github.com/emporia-vue-local/esphome?tab=readme-ov-file#im-seeing-zeros-on-certain-current-clamps
#filters: []
# TESTING BASED OFF OF https://github.com/emporia-vue-local/esphome/discussions/264#discussioncomment-8899111
#filters: [*abs]
# Pay close attention to set the phase_id for each breaker by matching it to the phase/leg it connects to in the panel
# LEFT SIDE
- { phase_id: phase_a, input: "1", power: { name: "Breaker 1/3 - XYZ", id: circuit_1, filters: [ *moving_avg, *invert, multiply: 2 ] } }
- { phase_id: phase_a, input: "2", power: { name: "Breaker 5 - XYZ", id: circuit_2, filters: [ *moving_avg, *invert ] } }
### REMOVED MOST, JUST REPEAT FROM ABOVE
# RIGHT SIDE
- { phase_id: phase_a, input: "9", power: { name: "Breaker 2/4 - XYZ", id: circuit_9, filters: [ *moving_avg, *invert, multiply: 2 ] } }
- { phase_id: phase_b, input: "10", power: { name: "Breaker 8 - XYZ", id: circuit_10, filters: [ *moving_avg, *invert ] } }
### REMOVED MOST, JUST REPEAT FROM ABOVE
- platform: template
name: "Total Power"
lambda: return id(phase_a_power).state + id(phase_b_power).state;
update_interval: 10s
id: total_power
unit_of_measurement: "W"
- platform: total_daily_energy
name: "Total Daily Energy"
power_id: total_power
accuracy_decimals: 0
# LEFT SIDE
- { power_id: circuit_1, platform: total_daily_energy, accuracy_decimals: 0, name: "Breaker 1/3 - Daily Energy" }
- { power_id: circuit_2, platform: total_daily_energy, accuracy_decimals: 0, name: "Breaker 5 - Daily Energy" }
### REMOVED MOST, JUST REPEAT FROM ABOVE
# RIGHT SIDE
- { power_id: circuit_9, platform: total_daily_energy, accuracy_decimals: 0, name: "Breaker 2/4 - Daily Energy" }
- { power_id: circuit_10, platform: total_daily_energy, accuracy_decimals: 0, name: "Breaker 8 - Daily Energy" }
### REMOVED MOST, JUST REPEAT FROM ABOVE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment