Lifetime instead of Daily sensor

Hi,
I want to have a lifetime increasing energy sensor

So I added the platform: integration But I cannot figure out what to fill in at the sensor:

See my config below.
Any help is more than welcome

  - platform: ct_clamp
    sensor: ai1
    id: Measured_Current_1
    name: "Measured Current-1"
    sample_duration: 500ms
    update_interval: 20s
    accuracy_decimals: 5  
    filters:
    - calibrate_linear:
      - 0.005060 -> 0
      - 0.009490 -> 0.253
      - 0.013850 -> 0.409
      - 0.056480 -> 1.775
      - 0.114445 -> 3.61
      - 0.204695 -> 6.49
      - 0.286630 -> 9.01
      - 0.340460 -> 10.684
      - 0.535860 -> 16.89

  - platform: template
    id: power1
    name: "Power 1"
    lambda: return id(Measured_Current_1).state * id(fase1_voltage).state;
    device_class: power
    unit_of_measurement: 'W'
    update_interval: 5s

  - platform: integration
    name: 'Total Energy 1'
    sensor: ???????
    time_unit: h
    restore: true
    state_class: total_increasing
    device_class: energy

  - platform: total_daily_energy
    name: "Total Daily Energy 1"
    power_id: power1
    filters:
        - multiply: 0.001
    unit_of_measurement: kWh
    accuracy_decimals: 3
    icon: mdi:clock-alert
    device_class: energy

Same sensor id that total daily energy uses, power1

I thought so too, but I get an compile error

Linking .pioenvs/kc868-m16v2/firmware.elf
/data/cache/platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: .pioenvs/kc868-m16v2/src/main.cpp.o:(.literal._Z5setupv+0x224): undefined reference to `_ZTVN7esphome11integration17IntegrationSensorE'
collect2: error: ld returned 1 exit status
*** [.pioenvs/kc868-m16v2/firmware.elf] Error 1
========================= [FAILED] Took 417.54 seconds =========================

Try to clean build files. And make sure all sensors are indented correctly under sensor:

That did the trick.

Thank you

You’re welcome, happy holidays.

2 Likes