Convert W value to kWh, am I doing it right? (Enphase Envoy-S)

Hi,

I’m sorry, this question has been asked several times but I can’t find a solution for the specific situation I’m in.

So, I’m running the Enphase Envoy-S. I’m using the DEV HACS intergration to get the sensors from the device. The only working sensors it’s pulling are

  • Current Power Consumption
  • Current Power Production
  • All the inverters production

So, taking a look at usable sensors I would grab the “Current Power Production” sensor. However, this is in W and not kWh, so I would need to convert this. To do this, I would create a helper > Riemann sensor.

Source will be the sensor for current production, the intergration method would be “Left riemann sum” (I’ve read that this one is better for tese things?) The metric will be in k (kilo) for kWh and it wil measure it in seconds (so it’s in realtime?!).

However, when doing the above, the sensor it NOT showing up as selectable within the Energy dashboard? What am I doing wrong? I know the Energy dashboards only wants kWh sensors, but I thought that the Riemann sensor converts the W to kWh’s? Or do I need to do an extra step?

When looking at the status it’s showing a big number… when looking at the Energy dashboard the value of the P1Monitor are all x.xx kWh and not xxx.xx kWh.

Love to hear it from you guys,

Thanks!

I am not an expert in the energy dashboard but here is an example of one of mine and it is selectable. I don’t have any that use seconds…

sensor:
  - platform: integration
    source: sensor.den_ac_power
    name: Den AC Energy Meter
    method: trapezoidal
    unit_prefix: k
    unit_time: h
    round: 2

Hey mate, thanks!

I’ve copied your config and I can see a “normal” value, but it’s not showing up as selectable sensor in my energy dashboard, any idea?

Your device is not getting the “energy” device_class. Here is mine.

Try this just as an experiment…

Create a new sensor the exact way you did before, but change the name to something new.

For example, change…

name: solarproductie_pv

to…

name: solarproductie_pv_new

Aaaaaaaaaah.

Ok, I got it!!

So, just for the people reading through this topic with the same issue. I’ve now made a Riemann sensor with the config above from @whoismoses then I create a NEW sensor in YAML and took the Riemann sensor I’ve created as a source to take the value from. This YAML sensor is getting the “Energy” class which enables me to add it in the Energy dashboard.

Riemann sensor:

sensor:
  - platform: integration
    source: sensor.envoy_122225066668_current_power_production
    name: Opbrengst Solar
    method: trapezoidal
    unit_prefix: k
    unit_time: h
    round: 2

YAML sensor (just a duplicate, but this one gets the energy class so it can be selected within the Energy dashboard:

- sensor:
    - name: Solarproductie
      unit_of_measurement: "kWh"
      state: "{{ states('sensor.opbrengst_solar') }}"
      state_class: "total_increasing"
      device_class: "energy"

Both sensors in the status tab;

I faced this issue before. Because the sensor was setup prior with different units for power and time it did not get updated when you fixed the sensor. There are ways to delete the old setting so you can use the same name.

Yeah, I have many sensors withouth an unique ID attached to it, so when I open the dropdown in the Energy dashboard I see alot of my old sensors still in there but they are non-removable from HA as they don’t exist in the config anymore. I’ve seen that by purging the database can remove them, but I don’t want to go down that way, it could also F up my HA instance haha.

Backup first if you do! :grinning:

hi all

after several hours spent, i need some guidance please.
I have a huawei solar inverter and 2 strings.

I would like to a daily/monthly/yearly statistics for each string.

I created below a sensor for String 2 :

  - sensor:
    - name: "Solar Fotovoltaice String 1 Sud"
      unit_of_measurement: "W"
      unique_id: "solar_foto_string1_sud"
      state_class: measurement
      device_class: power
      state: >
          {{((states('sensor.inverter_pv_1_voltage')|float) * (states('sensor.inverter_pv_1_current')|float))|int(0)}}

This sensor multiplies String Voltage with String Current resulting power in Watts.
How to convert it in kWh? just dividing it the whole sum to 1000?

I’ve tried using utility meter but it is in Watt expressed.

I was thinking in creating below sensor already in kWh and use it in utility meter for statistics but it gives me ~+25% deviation:

#Productie string 2 in kWh
  - sensor:
    - name: "Productie Fotovoltaice String #2"
      unique_id: productie_solar_string2_test2
      unit_of_measurement: 'kWh'
#      icon: mdi:transmission-tower
      state: >
        {{(((states('sensor.inverter_pv_2_voltage')|float) * (states('sensor.inverter_pv_2_current')|float))|int(0))/1000}}             
      device_class: energy
      state_class: total_increasing

How would you do it to store the statistics in kWh ?