Help with ESPhome and Energy devices not available in "Energy" dashboard

Hi All,

I am pulling my hair out. I het a raft of ESP devices doing things around the house and i got a CircuitSetup 6 channel power monitoring board. I have got it all up and running with ESPhome and the sensors are built, I can see the Voltage, Watts, Amps and total daily consumption in kWh but it is not showing up as an option in the Energy tab, I have watched the youtube video on what to do and i have followed it even using the same YAML but changing the device names. I did have an issue at the start were i put in a duplicate name and that cause some funny behavior but has since been resolved.

This is a snippet of the YAML for the Solar channel on the board

    #CT4
    phase_a:
      current:
        name: ${disp_name} Solar L1 Amps
        id: SolarL1Amps
      power:
        name: ${disp_name} Solar L1 Watts
        id: SolarL1Watts
      gain_voltage: ${voltage_cal}
      gain_ct: ${current_cal}

#Total Solar Amps   
  - platform: template
    name: ${disp_name} Total Solar Amps
    id: totalSolarAmps
    lambda: return id(SolarL1Amps).state ;
    accuracy_decimals: 2
    unit_of_measurement: A
    icon: "mdi:flash"
    update_interval: ${update_time}         
#Total Solar Watts
  - platform: template
    name: ${disp_name} Total Solar Watts
    id: totalSolarWatts
    lambda: return id(SolarL1Watts).state ;
    accuracy_decimals: 1
    unit_of_measurement: W
    icon: "mdi:flash-circle"
    update_interval: ${update_time}

#Solar kWh
  - platform: total_daily_energy
    name: ${disp_name} Solar kWh
    power_id: totalSolarWatts
    filters:
      - multiply: 0.001
    unit_of_measurement: kWh
    device_class: energy

And what are the resulting energy sensors in HA, and their attributes.

It all seems to work in lovelace view fine, values are what i expect

Via states page in developer tools is what I was after :slight_smile:

Sorry is this what you are after ?

Yes it is, and it shows that the sensor does not have

state_class: total_increasing

But i am not 100% sure how to add this in esphome. What version of esphome are you running?

EDIT on a bit of a look, you add it like you have with device_class see Sensor Component — ESPHome

I just had a look at a TP-link smart switch that does show up and you are right the only thing that is different is

state_class: **total_increasing**
unit_of_measurement: kWh
friendly_name: light Today Energy
device_class: energy

I have no idea how to add it though ESPhome as i have followed the ESPhome guide to set it up

Looks like you missed my edit :slight_smile:

Ok sorry i am not following, I have had a look and there does not seem to be any way to change the state_class of the platform sensor in the ESPhome config

Failed config

sensor.total_daily_energy: [source /config/power-meter.yaml:184]
  platform: total_daily_energy
  name: energy-monitor Solar New kWh
  power_id: totalSolarWatts
  filters: 
    - multiply: 0.001
  unit_of_measurement: kWh
  
  Unknown value 'total_increasing', valid options are '', 'measurement'.
  state_class: total_increasing [source /config/power-meter.yaml:190]

what version of esphome? The total_increasing option may have been added recently as this energy stuff in HA is quite new.

I am running 1.19.4

total_increasing was added in esphome 2021.8. You will need to upgrade.

1 Like

Ahh!!! thank you!

Let me do that and i will report back

1 Like

AAARRRRGGGHHHHH!!!

that was it THANK YOU !

All working like a charm now

1 Like

I’ll add this to the examples in the github repo for the 6 channel meter

Hi,

I have similar problem with my Inverter Aurora, paired with an ESPHome module.

I can see daily production but it’s not available in Energy Dashboard.

Take a look to my post to help me: ESPHome - SolarPV inverter - Energy sensor not available

If you are still having an issue you will need to ensure that you have state_class: total_increasing for it to qualify in the energy dashboard as a device that can be added, As you can see my issue was from haveing a (now very) old version of ESP Home that had not been updated to include the new state class

Hi, the version of my ESPHome is the latest. Which information can I share with you to understand better the situation and try to solve the problem?

Yaml and logs are required for help.

That’s my YAML running on my ESP32 board, using ESPHome:

#https://github.com/michelsciortino/esphome-aurora-inverter?tab=readme-ov-file
#Installato il 17 aprile 2024

esphome:
  name: esp32-s2-inverter-aurora
  friendly_name: esp32-s2-inverter-aurora
  includes:
    - esp32-s2-inverter-aurora/ABBAuroraStrings.cpp
    - esp32-s2-inverter-aurora/ABBAuroraStrings.h
    - esp32-s2-inverter-aurora/ABBAuroraEnums.h
    - esp32-s2-inverter-aurora/ABBAurora.cpp
    - esp32-s2-inverter-aurora/ABBAurora.h
    - esp32-s2-inverter-aurora/InverterMonitor.h
    - esp32-s2-inverter-aurora/ABBAurora.cpp  
  libraries:
    - Wire

esp32:
  board: esp32-s2-saola-1
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "90vfcUJLhGIyqom1/Yuyp7+zTC+EPfoReKlzIHC9wr8="

ota:
  password: "031574bb6ab0a4224aa030f7e4e42052"

wifi:
  networks:
  - ssid: !secret wifi_ssid
    password: !secret wifi_password
  - ssid: "Home Network_EXT"
    password: !secret wifi_password
  power_save_mode: none
  manual_ip:
    static_ip: 192.168.0.205
    gateway: 192.168.0.254
    subnet: 255.255.255.0

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Nodemcu-Inverter-Aurora"
    password: "k85RyVlR4g2S"

captive_portal:

sensor:
  - platform: custom
    lambda: |-
      auto monitor = InverterMonitor::get_instance();
      App.register_component(monitor);
      App.register_sensor(monitor->v_in_1);
      App.register_sensor(monitor->v_in_2);
      App.register_sensor(monitor->i_in_1);
      App.register_sensor(monitor->i_in_2);
      App.register_sensor(monitor->power_in_1);
      App.register_sensor(monitor->power_in_2);
      App.register_sensor(monitor->power_in_total);
      App.register_sensor(monitor->power_peak_today);
      App.register_sensor(monitor->power_peak_max);
      App.register_sensor(monitor->temperature_inverter);
      App.register_sensor(monitor->temperature_booster);
      App.register_sensor(monitor->cumulated_energy_today);
      App.register_sensor(monitor->cumulated_energy_week);
      App.register_sensor(monitor->cumulated_energy_month);
      App.register_sensor(monitor->cumulated_energy_year);
      App.register_sensor(monitor->cumulated_energy_total);

      return {
        monitor->v_in_1,
        monitor->v_in_2,
        monitor->i_in_1,
        monitor->i_in_2,
        monitor->power_in_1,
        monitor->power_in_2,
        monitor->power_in_total,
        monitor->power_peak_today,
        monitor->power_peak_max,
        monitor->temperature_inverter,
        monitor->temperature_booster,
        monitor->cumulated_energy_today,
        monitor->cumulated_energy_week,
        monitor->cumulated_energy_month,
        monitor->cumulated_energy_year,
        monitor->cumulated_energy_total
      };
    sensors: 
      #Voltage
      - name: v_in_1
        unit_of_measurement: V
        accuracy_decimals: 2
        icon: "mdi:lightning-bolt-outline"
      - name: v_in_2
        unit_of_measurement: V
        accuracy_decimals: 2
        icon: "mdi:lightning-bolt-outline"
      #Current
      - name: i_in_1
        unit_of_measurement: A
        accuracy_decimals: 2
        icon: "mdi:current-ac"
      - name: i_in_2
        unit_of_measurement: A
        accuracy_decimals: 2
        icon: "mdi:current-ac"
      #Power
      - name: power_in_1
        unit_of_measurement: W
        accuracy_decimals: 0
        icon: "mdi:solar-power"
      - name: power_in_2
        unit_of_measurement: W
        accuracy_decimals: 0
        icon: "mdi:solar-power"
      - name: power_in_total
        unit_of_measurement: W
        accuracy_decimals: 0
        icon: "mdi:solar-power"
      - name: power_peak_today
        unit_of_measurement: W
        accuracy_decimals: 0
        icon: "mdi:solar-power"
      - name: power_peak_max
        unit_of_measurement: W
        accuracy_decimals: 0
        icon: "mdi:solar-power"
      #Temperatures
      - name: inverter_temp
        unit_of_measurement: "°C"
        accuracy_decimals: 2
        icon: "mdi:thermometer"
      - name: booster_temp
        unit_of_measurement: "°C"
        accuracy_decimals: 2
        icon: "mdi:thermometer"
      #Energy
      - name: cumulated_energy_today
        unit_of_measurement: "Wh"
        accuracy_decimals: 0
        icon: "mdi:car-battery"
      - name: cumulated_energy_week
        unit_of_measurement: "Wh"
        accuracy_decimals: 0
        icon: "mdi:car-battery"
      - name: cumulated_energy_month
        unit_of_measurement: "Wh"
        accuracy_decimals: 0
        icon: "mdi:car-battery"
      - name: cumulated_energy_year
        unit_of_measurement: "Wh"
        accuracy_decimals: 0
        icon: "mdi:car-battery"
      - name: cumulated_energy_total
        unit_of_measurement: "Wh"
        accuracy_decimals: 0
        icon: "mdi:car-battery"

text_sensor:
  - platform: custom
    lambda: |-
      auto monitor = InverterMonitor::get_instance();
      App.register_text_sensor(monitor->connection_status);
      return { monitor->connection_status };
    text_sensors: 
      #Status
      - name: connection_status
        icon: "mdi:connection"```