Empora vue 2 energy monitor

I’ve reflashed emporia according to this howto Setting up Emporia Vue 2 with ESPHome · GitHub

It disconnects with following error:

INFO energy-monitor.local: Error while reading incoming messages: Error while reading data: 0 bytes read on a total of 1 expected bytes
INFO Disconnected from ESPHome API for energy-monitor.local
WARNING Disconnected from API
INFO energy-monitor.local: Ping Failed: Error while reading data: 0 bytes read on a total of 1 expected bytes
INFO Successfully connected to energy-monitor.local

ESPHome version 2022.6.2

My configuration:

substitutions:
  devicename: "energy-monitor"
  upper_devicename: "emporiavue2"

  wifi_ssid: !secret iot_wifi_ssid
  wifi_pass: !secret iot_wifi_password
  fallback_pass: !secret fallback_wifi_password
  api_pass: !secret esp_api_password
  ota_pass: !secret esp_ota_password
  webserver_username: !secret webserver_username
  webserver_password: !secret webserver_password
  # phase a connected to main leat L1 load closet 
  name_a_power: "Grid Power"
  name_a_voltage: "Grid Voltage"
  name_total_a_power: "Total Power Grid"
  name_total_a_energy: "Total Daily Energy Grid"
  # phase b connected to main lead N direction load N
  name_b_power: "Neutral Power"
  name_b_voltage: "Neutral Voltage"
  name_total_b_power: "Total Power Neutral"
  name_total_b_energy: "Total Daily Energy Neutral"
  # phase c connected main lead to earth direction load earth
  name_c_power: "PE Power"
  name_c_voltage: "PE Voltage"
  name_total_c_power: "Total Power PE"
  name_total_c_energy: "Total Daily Energy PE"
  # individual circuits
  name_circuit01: "Circuit 1"
  name_circuit02: "Circuit 2"
  name_circuit03: "Circuit 3"
  name_circuit04: "Circuit 4"
  name_circuit05: "Circuit 5"
  name_circuit06: "Circuit 6"
  name_circuit07: "Circuit 7"
  name_circuit08: "Circuit 8"
  name_circuit09: "Circuit 9"
  name_circuit10: "Circuit 10"
  name_circuit11: "Circuit 11"
  name_circuit12: "Circuit 12"
  name_circuit13: "Circuit 13"
  name_circuit14: "Circuit 14"
  name_circuit15: "Circuit 15"
  name_circuit16: "Circuit 16"


esphome:
  name: $devicename

external_components:
  - source: github://flaviut/[email protected]
    components: [ emporia_vue ]

esp32:
  board: esp32dev
  framework:
    type: esp-idf
    version: recommended
    
# Enable Home Assistant API
api:
  password: "${api_pass}"

# Enable over the air updates
ota:
  password: "${ota_pass}"

# Enable logging
logger:

wifi:
  ssid: "${wifi_ssid}"
  password: "${wifi_pass}"

i2c:
  sda: 21
  scl: 22
  scan: false
  frequency: 200kHz  # recommended range is 50-200kHz
  id: i2c_a
  
time:
  - platform: sntp
    timezone: 'CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00'
    id: my_time
    servers: 
      - 162.159.200.123
      - 195.13.23.5
      - 195.13.1.153
    on_time_sync:
      then:
        - logger.log: "Synchronized system clock"

# these are called references in YAML. They allow you to reuse
# this configuration in each sensor, while only defining it once
.defaultfilters:
  - &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: 12
      # we push a new value every 1.44 seconds
      send_every: 6
  - &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:
      - id: phase_a  # Verify that this specific phase/leg is connected to correct input wire color on device listed below
        input: BLACK  # Vue device wire color
        calibration: 0.02260  # 0.022 is used as the default as starting point but may need adjusted to ensure accuracy
        # To calculate new calibration value use the formula <in-use calibration value> * <accurate voltage> / <reporting voltage>
        voltage:
          name: $name_a_voltage
          filters: [*moving_avg, *pos]
      - id: phase_b  # Verify that this specific phase/leg is connected to correct input wire color on device listed below
        input: RED  # Vue device wire color
        calibration: 0.02260  # 0.022 is used as the default as starting point but may need adjusted to ensure accuracy
        # To calculate new calibration value use the formula <in-use calibration value> * <accurate voltage> / <reporting voltage>
        voltage:
          name: $name_b_voltage
          filters: [*moving_avg, *pos]
      - id: phase_c  # Verify that this specific phase/leg is connected to correct input wire color on device listed below
        input: BLUE  # Vue device wire color
        calibration: 0.02260  # 0.022 is used as the default as starting point but may need adjusted to ensure accuracy
        # To calculate new calibration value use the formula <in-use calibration value> * <accurate voltage> / <reporting voltage>
        voltage:
          name: $name_c_voltage
          filters: [*moving_avg, *pos]
    ct_clamps:
      - phase_id: phase_a
        input: "A"  # Verify the CT going to this device input also matches the phase/leg
        power:
          name: $name_a_power
          id: phase_a_power
          device_class: power
          filters: [*moving_avg, *pos]
      - phase_id: phase_b
        input: "B"  # Verify the CT going to this device input also matches the phase/leg
        power:
          name: $name_b_power
          id: phase_b_power
          device_class: power
          filters: [*moving_avg, *pos]
      - phase_id: phase_c
        input: "C"  # Verify the CT going to this device input also matches the phase/leg
        power:
          name: $name_c_power
          id: phase_c_power
          device_class: power
          filters: [*moving_avg, *pos]
      # Pay close attention to set the phase_id for each breaker by matching it to the phase/leg it connects to in the panel
      - { phase_id: phase_a, input:  "1", power: { name: $name_circuit01, internal: true, id: power_cir01, device_class: power, filters: [ *moving_avg, *pos ] } }
      - { phase_id: phase_a, input:  "2", power: { name: $name_circuit02, internal: true, id: power_cir02, device_class: power, filters: [ *moving_avg, *pos ] } }
      - { phase_id: phase_a, input:  "3", power: { name: $name_circuit03, internal: true, id: power_cir03, device_class: power, filters: [ *moving_avg, *pos ] } }
      - { phase_id: phase_a, input:  "4", power: { name: $name_circuit04, internal: true, id: power_cir04, device_class: power, filters: [ *moving_avg, *pos ] } }
      - { phase_id: phase_a, input:  "5", power: { name: $name_circuit05, internal: true, id: power_cir05, device_class: power, filters: [ *moving_avg, *pos ] } }
      - { phase_id: phase_a, input:  "6", power: { name: $name_circuit06, internal: true, id: power_cir06, device_class: power, filters: [ *moving_avg, *pos ] } }
      - { phase_id: phase_a, input:  "7", power: { name: $name_circuit07, internal: true, id: power_cir07, device_class: power, filters: [ *moving_avg, *pos ] } }
      - { phase_id: phase_a, input:  "8", power: { name: $name_circuit08, internal: true, id: power_cir08, device_class: power, filters: [ *moving_avg, *pos ] } }
      - { phase_id: phase_a, input:  "9", power: { name: $name_circuit09, internal: true, id: power_cir09, device_class: power, filters: [ *moving_avg, *pos ] } }
      - { phase_id: phase_a, input: "10", power: { name: $name_circuit10, internal: true, id: power_cir10, device_class: power, filters: [ *moving_avg, *pos ] } }
      - { phase_id: phase_a, input: "11", power: { name: $name_circuit11, internal: true, id: power_cir11, device_class: power, filters: [ *moving_avg, *pos ] } }
      - { phase_id: phase_a, input: "12", power: { name: $name_circuit12, internal: true, id: power_cir12, device_class: power, filters: [ *moving_avg, *pos ] } }
      - { phase_id: phase_a, input: "13", power: { name: $name_circuit13, internal: true, id: power_cir13, device_class: power, filters: [ *moving_avg, *pos ] } }
      - { phase_id: phase_a, input: "14", power: { name: $name_circuit14, internal: true, id: power_cir14, device_class: power, filters: [ *moving_avg, *pos ] } }
      - { phase_id: phase_a, input: "15", power: { name: $name_circuit15, internal: true, id: power_cir15, device_class: power, filters: [ *moving_avg, *pos ] } }
      - { phase_id: phase_a, input: "16", power: { name: $name_circuit16, internal: true, id: power_cir16, device_class: power, filters: [ *moving_avg, *pos ] } }
      
  - platform: template
    name: "${name_circuit01} in W"
    lambda: return id(power_cir01).state;
    update_interval: 1s
    id: total_cir01
    unit_of_measurement: "W"
    icon: mdi:gauge
  - platform: template
    name: "${name_circuit02} in W"
    lambda: return id(power_cir02).state;
    update_interval: 1s
    id: total_cir02
    unit_of_measurement: "W"
    icon: mdi:gauge
  - platform: template
    name: "${name_circuit03} in W"
    lambda: return id(power_cir03).state;
    update_interval: 1s
    id: total_cir03
    unit_of_measurement: "W"
    icon: mdi:gauge
  - platform: template
    name: "${name_circuit04} in W"
    lambda: return id(power_cir04).state;
    update_interval: 1s
    id: total_cir04
    unit_of_measurement: "W"
    icon: mdi:gauge
  - platform: template
    name: "${name_circuit05} in W"
    lambda: return id(power_cir05).state;
    update_interval: 1s
    id: total_cir05
    unit_of_measurement: "W"
    icon: mdi:gauge
  - platform: template
    name: "${name_circuit06} in W"
    lambda: return id(power_cir06).state;
    update_interval: 1s
    id: total_cir06
    unit_of_measurement: "W"
    icon: mdi:gauge
  - platform: template
    name: "${name_circuit07} in W"
    lambda: return id(power_cir07).state;
    update_interval: 1s
    id: total_cir07
    unit_of_measurement: "W"
    icon: mdi:gauge
  - platform: template
    name: "${name_circuit08} in W"
    lambda: return id(power_cir08).state;
    update_interval: 1s
    id: total_cir08
    unit_of_measurement: "W"
    icon: mdi:gauge
  - platform: template
    name: "${name_circuit09} in W"
    lambda: return id(power_cir09).state;
    update_interval: 1s
    id: total_cir09
    unit_of_measurement: "W"
    icon: mdi:gauge
  - platform: template
    name: "${name_circuit10} in W"
    lambda: return id(power_cir10).state;
    update_interval: 1s
    id: total_cir10
    unit_of_measurement: "W"
    icon: mdi:gauge
  - platform: template
    name: "${name_circuit11} in W"
    lambda: return id(power_cir11).state;
    update_interval: 1s
    id: total_cir11
    unit_of_measurement: "W"
    icon: mdi:gauge
  - platform: template
    name: "${name_circuit12} in W"
    lambda: return id(power_cir12).state;
    update_interval: 1s
    id: total_cir12
    unit_of_measurement: "W"
    icon: mdi:gauge
  - platform: template
    name: "${name_circuit13} in W"
    lambda: return id(power_cir13).state;
    update_interval: 1s
    id: total_cir13
    unit_of_measurement: "W"
    icon: mdi:gauge
  - platform: template
    name: "${name_circuit14} in W"
    lambda: return id(power_cir14).state;
    update_interval: 1s
    id: total_cir14
    unit_of_measurement: "W"
    icon: mdi:gauge
  - platform: template
    name: "${name_circuit15} in W"
    lambda: return id(power_cir15).state;
    update_interval: 1s
    id: total_cir15
    unit_of_measurement: "W"
    icon: mdi:gauge
  - platform: template
    name: "${name_circuit16} in W"
    lambda: return id(power_cir16).state;
    update_interval: 1s
    id: total_cir16
    unit_of_measurement: "W"
    icon: mdi:gauge
      
  # phase A
  - platform: template
    name: $name_total_a_power
    lambda: return id(phase_a_power).state;
    update_interval: 1s
    id: total_power_a
    unit_of_measurement: "W"
    icon: mdi:gauge
  - platform: total_daily_energy
    name: $name_total_a_energy
    power_id: total_power_a
    accuracy_decimals: 0
    icon: mdi:gauge
  # phase B
  - platform: template
    name: $name_total_b_power
    lambda: return id(phase_b_power).state;
    update_interval: 1s
    id: total_power_b
    unit_of_measurement: "W"
    icon: mdi:gauge
  - platform: total_daily_energy
    name: $name_total_b_energy
    power_id: total_power_b
    accuracy_decimals: 0
    icon: mdi:gauge
  # phase C
  - platform: template
    name: $name_total_c_power
    lambda: return id(phase_c_power).state;
    update_interval: 1s
    id: total_power_c
    unit_of_measurement: "W"
    icon: mdi:gauge
  - platform: total_daily_energy
    name: $name_total_c_energy
    power_id: total_power_c
    accuracy_decimals: 0
    icon: mdi:gauge

  - { power_id: total_cir01, platform: total_daily_energy, accuracy_decimals: 1, name: "${name_circuit01} in Wh", unit_of_measurement: "Wh", icon: mdi:calendar-clock }
  - { power_id: total_cir02, platform: total_daily_energy, accuracy_decimals: 1, name: "${name_circuit02} in Wh", unit_of_measurement: "Wh", icon: mdi:calendar-clock }
  - { power_id: total_cir03, platform: total_daily_energy, accuracy_decimals: 1, name: "${name_circuit03} in Wh", unit_of_measurement: "Wh", icon: mdi:calendar-clock }
  - { power_id: total_cir04, platform: total_daily_energy, accuracy_decimals: 1, name: "${name_circuit04} in Wh", unit_of_measurement: "Wh", icon: mdi:calendar-clock }
  - { power_id: total_cir05, platform: total_daily_energy, accuracy_decimals: 1, name: "${name_circuit05} in Wh", unit_of_measurement: "Wh", icon: mdi:calendar-clock }
  - { power_id: total_cir06, platform: total_daily_energy, accuracy_decimals: 1, name: "${name_circuit06} in Wh", unit_of_measurement: "Wh", icon: mdi:calendar-clock }
  - { power_id: total_cir07, platform: total_daily_energy, accuracy_decimals: 1, name: "${name_circuit07} in Wh", unit_of_measurement: "Wh", icon: mdi:calendar-clock }
  - { power_id: total_cir08, platform: total_daily_energy, accuracy_decimals: 1, name: "${name_circuit08} in Wh", unit_of_measurement: "Wh", icon: mdi:calendar-clock }
  - { power_id: total_cir09, platform: total_daily_energy, accuracy_decimals: 1, name: "${name_circuit09} in Wh", unit_of_measurement: "Wh", icon: mdi:calendar-clock }
  - { power_id: total_cir10, platform: total_daily_energy, accuracy_decimals: 1, name: "${name_circuit10} in Wh", unit_of_measurement: "Wh", icon: mdi:calendar-clock }
  - { power_id: total_cir11, platform: total_daily_energy, accuracy_decimals: 1, name: "${name_circuit11} in Wh", unit_of_measurement: "Wh", icon: mdi:calendar-clock }
  - { power_id: total_cir12, platform: total_daily_energy, accuracy_decimals: 1, name: "${name_circuit12} in Wh", unit_of_measurement: "Wh", icon: mdi:calendar-clock }
  - { power_id: total_cir13, platform: total_daily_energy, accuracy_decimals: 1, name: "${name_circuit13} in Wh", unit_of_measurement: "Wh", icon: mdi:calendar-clock }
  - { power_id: total_cir14, platform: total_daily_energy, accuracy_decimals: 1, name: "${name_circuit14} in Wh", unit_of_measurement: "Wh", icon: mdi:calendar-clock }
  - { power_id: total_cir15, platform: total_daily_energy, accuracy_decimals: 1, name: "${name_circuit15} in Wh", unit_of_measurement: "Wh", icon: mdi:calendar-clock }
  - { power_id: total_cir16, platform: total_daily_energy, accuracy_decimals: 1, name: "${name_circuit16} in Wh", unit_of_measurement: "Wh", icon: mdi:calendar-clock }

  - { power_id: total_cir01, platform: total_daily_energy, accuracy_decimals: 3, name: "${name_circuit01} in kWh", unit_of_measurement: "kWh", filters: [multiply: 0.001], icon: mdi:calendar-clock }
  - { power_id: total_cir02, platform: total_daily_energy, accuracy_decimals: 3, name: "${name_circuit02} in kWh", unit_of_measurement: "kWh", filters: [multiply: 0.001], icon: mdi:calendar-clock }
  - { power_id: total_cir03, platform: total_daily_energy, accuracy_decimals: 3, name: "${name_circuit03} in kWh", unit_of_measurement: "kWh", filters: [multiply: 0.001], icon: mdi:calendar-clock }
  - { power_id: total_cir04, platform: total_daily_energy, accuracy_decimals: 3, name: "${name_circuit04} in kWh", unit_of_measurement: "kWh", filters: [multiply: 0.001], icon: mdi:calendar-clock }
  - { power_id: total_cir05, platform: total_daily_energy, accuracy_decimals: 3, name: "${name_circuit05} in kWh", unit_of_measurement: "kWh", filters: [multiply: 0.001], icon: mdi:calendar-clock }
  - { power_id: total_cir06, platform: total_daily_energy, accuracy_decimals: 3, name: "${name_circuit06} in kWh", unit_of_measurement: "kWh", filters: [multiply: 0.001], icon: mdi:calendar-clock }
  - { power_id: total_cir07, platform: total_daily_energy, accuracy_decimals: 3, name: "${name_circuit07} in kWh", unit_of_measurement: "kWh", filters: [multiply: 0.001], icon: mdi:calendar-clock }
  - { power_id: total_cir08, platform: total_daily_energy, accuracy_decimals: 3, name: "${name_circuit08} in kWh", unit_of_measurement: "kWh", filters: [multiply: 0.001], icon: mdi:calendar-clock }
  - { power_id: total_cir09, platform: total_daily_energy, accuracy_decimals: 3, name: "${name_circuit09} in kWh", unit_of_measurement: "kWh", filters: [multiply: 0.001], icon: mdi:calendar-clock }
  - { power_id: total_cir10, platform: total_daily_energy, accuracy_decimals: 3, name: "${name_circuit10} in kWh", unit_of_measurement: "kWh", filters: [multiply: 0.001], icon: mdi:calendar-clock }
  - { power_id: total_cir11, platform: total_daily_energy, accuracy_decimals: 3, name: "${name_circuit11} in kWh", unit_of_measurement: "kWh", filters: [multiply: 0.001], icon: mdi:calendar-clock }
  - { power_id: total_cir12, platform: total_daily_energy, accuracy_decimals: 3, name: "${name_circuit12} in kWh", unit_of_measurement: "kWh", filters: [multiply: 0.001], icon: mdi:calendar-clock }
  - { power_id: total_cir13, platform: total_daily_energy, accuracy_decimals: 3, name: "${name_circuit13} in kWh", unit_of_measurement: "kWh", filters: [multiply: 0.001], icon: mdi:calendar-clock }
  - { power_id: total_cir14, platform: total_daily_energy, accuracy_decimals: 3, name: "${name_circuit14} in kWh", unit_of_measurement: "kWh", filters: [multiply: 0.001], icon: mdi:calendar-clock }
  - { power_id: total_cir15, platform: total_daily_energy, accuracy_decimals: 3, name: "${name_circuit15} in kWh", unit_of_measurement: "kWh", filters: [multiply: 0.001], icon: mdi:calendar-clock }
  - { power_id: total_cir16, platform: total_daily_energy, accuracy_decimals: 3, name: "${name_circuit16} in kWh", unit_of_measurement: "kWh", filters: [multiply: 0.001], icon: mdi:calendar-clock }

Also connected to see if there was more information on the console but there was even less, on the console I wouldn’t be able to tell that it reconnected.

What wifi dBm does your router/AP report for the vue?

I’ve been running mine on ESPhome since late last year and it is solid if better than -70dBm. Above that and I might see disconnects on a weekly basis.

This is not a wifi thing 0% package loss when this happens ! It disconnects from the api so what I understand from that is that it disconnects from esphome port. And not the wifi.

But I’m using Unifi AC pro

I would capture it with tcpdump but that’s not included on the ova images.

I didn’t either. So what’s the dBm?

Since we are both Unifi (U6-Lite), you will be no stranger the mDNS issues.

mdns isn’t having any issues never really had any mdns issues router is handeling that part with avahi.

Pretty good, …
afbeelding


Have you tried w/o the min data rate, multi-cast enhancement and WPA2 (only)?

The UI Communities are a crazy place, but after a while the trend often appears that the fewest features possible works well for 2.4 networks. Albeit I’ve had BSS Transition enabled as well for ages successfully.

I rarely have issues w/ 12+ ESPHome devices and twice as many Tasmota’s with everything else off (on my 2.4-only SSID).

To be honest to more you tweak on the unifi ap’s usually the worse the connections get, however i’ll apply the changes you’ve suggested and evaluate if the problem persists.

No doesn’t do anything

Does a tcpdump from the AC-Pro reveal anything? Especially that 12 of 56 byte message.

That’s right didn’t think of that, wanted to look on home assistant but I can connect to the AP

Also what AP f/w are you running? There has been a lot of IOT work lately but that’s still ongoing. Especially w/ the 6.0.x and 6.2.x (EA) series.

Firmware Version6.0.21

That version worked well for my Vue2 so that’s encouraging.

Do you keep of log of HA and/or network maintenance that you can overlay w/ the beginning of the Vue2 symptoms? Or is this a brand new deployment for the Vue2?

Can’t say I see anything special in tcpdump. Some duplicate ACK frames…

I suppose I never asked when the reflash occurred.

Since the yaml does have minor (SNTP) changes I somehow thought it was deployed for a while. But if that’s not the case, I’d honestly revert to a stock config (wifi aside) from the Github and if that doesn’t work; pull it out of the panel in order to rule out deployment variables to ensure it works. I’ve always had the most success by ensuring it works “on the bench” and then moving to final location.

It’s brand new, I have about 30 devices in homeassistant, overal performance is ok. sometimes some really remote reconnects, but that’s a smart socket behind a fridge or something. I can understand that this is giving some issues. Might even understand that emporia would have connection issues, however that doesn’t seem to be the case. It’s not disconnecting from the wifi but from esphome itself. It looses the tcp connection.

Agreed from the provided data.

In all honestly, I’d pull it out, revert the config, use IP instead of mDNS (in HA); basically stripped down KISS. Then add each layer of complexity once confirmed working.

I suggest this from the perspective that my config is unaltered except wifi details. And I never use mDNS and all my ESPHome devices are registered via IP to HA w/ ping enabled in the ESPHome Add-On config.

Yep I have ping enabled as well. mDNS isn’t having an issue either. It used to but then I switched to use ping and all those issues went away.

Also updating firmware used to time out a lot but I noticed that I ping’ed a device before I updated. That the upload of the firmware wouldn’t interrupt. Hence status_use_ping=on.

EDIT:

I guess it’s fair to say that status_use_ping is probably sovling the mdns issues.

Agreed. [edit] - gunna roll this back…

The symptoms of firmware updates timing out do seem to align w/ the disconnects you are experiencing.

I’d try it out of the panel honestly. A pain in the butt for sure. At least it would rule out location definitively.

[edit] - checking my logs… …notice that my log reports the IP not .local

So yours is using mDNS unless you’ve changed it since the screenshot posted earlier.

[edit x2] now that I think about it more. You might need to add IP info into the wifi: section. For some reason I remember the ESPHome Dashboard being unable to find the device w/o it. But I always do that so it’s an old recollection.
eg

wifi:
  ssid: !secret yadda
  password: !secret yadda
  domain: !secret yadda
  power_save_mode: none
  manual_ip:
    static_ip: 192.168.6.122
    gateway: 192.168.6.1
    subnet: 255.255.255.0
    dns1: 192.168.6.254
    dns2: 192.168.6.253