Platform: integration not creating energy sensor

hello, i am trying to make a fake power sensor for always-on near constant power devices.

The power sensor seems to be created successfully, but i am unable to create a energy sensor.

Here is the power sensor defined in configuration.yaml

template:
  - sensor:
      - name: ikea_repeater_suvartojimas
        device_class: power
        unique_id: ikea_repeater_suvartojimas
        unit_of_measurement: W
        state_class: measurement
        state: "{{ (0.5 + [0.01,-0.01,0]|random) }}"

i have created an automation using node-red


Inject node activates “update_entity” service every minute

then i created an energy sensor inside sensors.yaml

- platform: integration
  source: sensor.ikea_repeater_suvartojimas
  unique_id: ikea_repeater_energy
  name: ikea_repeater_energy
  unit_prefix: k

over 12 hours has passed but no energy sensor appeared.
What am i doing wrong? It seems that it works for other people.

I don’t know but think energy sensors need to ‘see’ significant activity before they are available in the energy dashboard.

After 12 hours yours will be reading .006kWh - maybe that’s not significant enough?

You could create a fake test sensor using the the same method but higher power - say 100W - and see if that shows up. If it does great, if it doesn’t hopefully someone else can help.

Good Luck

I have created a fake power sensor which fluctuates between 2 and 3 kW, added and integration into sensor file, but only the “power” sensor appeared.I let it run for 2 hours and nothing changed. Then, i thought maybe this “platform: integration” is not actually built-into homeassistant default installation so i went to “settings”->“devices and services”->“add integration”, found the “Integration” and filled the form. I used the same fake power sensor, gave it a different “energy” sensor name and after submitting, it actually worked. It added the energy sensor and its’ value was increasing based on fake power sensor.

I then deleted all “inegrations” from the sensor.yaml file. Added another “integration” and this time i picked my ikea repeater power sensor. After submitting, ikea energy sensor was created right away with undefined value. The value became 0.000kWh after first power sensor update was done. So i assume in two hours it should show 0.001kWh (will wait, but judging by the fake sensor, it worked well)

So i have no idea why does it not work when configuration is added to sensor.yaml file.

Are you familiar with Powercalc? It does that flawlessly, as well as a lot more.

I did try powercalc in the first place, but it didn’t work either. The energy sensors would not show up even after 2 days. I tried various configurations which i can’t recall as i have removed powercalc. I might have not understood the documentation well, this might be the problem, but i thought that “integration” integration was looking to be much easier.

At this moment the solution is to use GUI for adding “integration” sensors (it’s been almost 4 hours since my last reply and energy sensor shows 0.002kWh, which is correct (4*0.5W)).
The yaml way does not work for me.