Is an invalid entity ID for dictionary value 'source', got

Maybe someone came across this. I can’t add a second energy sensor, it gives an error

Invalid config for ‘integration’ from integration ‘sensor’ at configuration.yaml, line 65: Entity ID my_sensor_ac_in_watt_2 is an invalid entity ID for dictionary value ‘source’, got ‘my_sensor_ac_in_watt_2’

# Loads default set of integrations. Do not remove.
default_config:




# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

panel_custom:
  - name: server_state
    sidebar_title: 'System'
    sidebar_icon: mdi:server
    js_url: /api/hassio/app/entrypoint.js
    url_path: 'hassio/system'
    embed_iframe: true
    require_admin: true
    config:
     ingress: core_configurator
     
     

template:
  - sensor:
    - name: "my_sensor_ac_in_watt_2"
      unit_of_measurement: 'W'
      unique_id: 89789421231236541562416
      device_class: energy
      state: >
          {% set calculated_value = states("sensor.solar2mqtt_ac_out_watt") | float(0) - states("sensor.solar2mqtt_pv_charging_power") | float(0) %}
          {{ calculated_value if calculated_value > 0 else 0 }}         
      state_class: total_increasing
      



   
sensor:
    - platform: integration
      source: sensor.solar2mqtt_pv_charging_power
      name: solar_energy_spent
      unique_id: 45648974121654654dsd
      unit_prefix: k
      round: 2
      
    - platform: integration
      source: my_sensor_ac_in_watt_2
      name: power_energy_spent
      unique_id: 56465465465465654564
      unit_prefix: k
      round: 2

The error tells you the problem:

Should be:

source: sensor.my_sensor_ac_in_watt_2

thanks I didn’t notice that

Now when adding this sensor to energy it gives an error:

Unexpected device class
The following entities do not have the expected device class:

  • sensor.power_energy_spent

So give it device_class: energy.

You should probably be getting an error for that, too. Watts are a measure of power, not energy. Use device_class: power here.


    - platform: integration
      source: sensor.my_sensor_ac_in_watt_2
      name: power_energy_spent
      unique_id: 56465465465465654564555
      device_class: energy
      unit_prefix: k
      round: 2

got an error

Configuration warnings

Invalid config for ‘integration’ from integration ‘sensor’ at configuration.yaml, line 58: ‘device_class’ is an invalid option for ‘sensor.integration’, check: device_class

This device class should be power not energy.

You can remove the device class from this one, it will happen automatically:

    - platform: integration
      source: sensor.my_sensor_ac_in_watt_2
      name: power_energy_spent
      unique_id: 56465465465465654564555
      device_class: energy
      unit_prefix: k
      round: 2

should I delete it? device_class:energy

No you should replace it with device_class: power, as I said above.

it worked, thank you very much

I’m new to Home Assistant

Now I will have accurate data from the solar inverter