Using ShellyPro 2PM to measure battery storage & return

Hi, I will receive my Zendure battery pack in a week or two. I understand I can connect my HA with the vendor’s MQTT server and integrate that data into my energy dashboard. However, I am interested in measuring the energy storage and return without connecting to the vendor.

My idea is to use a Shelly Pro 2 PM switch. The switch can measure power (W) and Energy (kWh). However, it cannot deliver return values in separate entities as expected by the energy dashboard. I can get the storage, but then there is no entity left for the “return.”. The Shelly Pro 3EM gives you a return entity per channel, but apparently not the Shelly Pro 2PM.

I created helpers to work my way around that:

- sensor:
      - name: "Zendure Battery Power Consumed"
        unique_id: zendure_battery_power_consumed
        unit_of_measurement: "W"
        state_class: measurement
        device_class: power
        state: >
          {% set power = states('sensor.akku_zendure_power') | float(0) %}
          {{ power if power > 0 else 0 }}

      - name: "Zendure Battery Power Returned"
        unique_id: zendure_battery_power_returned
        unit_of_measurement: "W"
        state_class: measurement
        device_class: power
        state: >
          {% set power = states('sensor.akku_zendure_power') | float(0) %}
          {{ -power if power < 0 else 0 }}

and then I created helpers for the energy:

sensor:
    - platform: integration
      source: sensor.zendure_battery_power_consumed
      name: "Zendure Battery Energy Consumed"
      unique_id: zendure_battery_energy_consumed
      unit_prefix: k
      round: 2
      method: trapezoidal

    - platform: integration
      source: sensor.zendure_battery_power_returned
      name: "Zendure Battery Energy Returned"
      unique_id: zendure_battery_energy_returned
      unit_prefix: k
      round: 2
      method: trapezoidal

I also made sure to declare the formats:

homeassistant:
  customize:
    sensor.zendure_battery_energy_consumed:
      device_class: energy
      state_class: total_increasing
      unit_of_measurement: kWh

    sensor.zendure_battery_energy_returned:
      device_class: energy
      state_class: total_increasing
      unit_of_measurement: kWh

Now, I checked the two power sensors and they work fine. The energy sensors, however, do not show. I get two error messages (pardon my translation, I get the messages in German):

  • There is no statistical metadata available. Wait up to 5 minutes.
  • The status of this configured entity is currently not available.

What am I missing?
Is there maybe a much simpler way of resolving this?
Thank you for any help you can provide.