I want to set the state(value) of a Riemann sum integral from a simulated sensor to a variable

Hey,
I want to copy the state(value) of a Riemann sum integral from a simulated sensor to a variable.

These are my sensors and variables i have:

sensor:
  - platform: simulated
    name: "SolarSimulation 7"
    unit: "W"
    amplitude: 50000
    mean: 0
    period: 1440
    phase: 0
    seed: 20
    spread: 5000
    relative_to_epoch: false
  - platform: integration
    source: sensor.SolarSimulation_7
    name: "Simulation Energy 6"
    unit_prefix: k
  - platform: integration
    source: sensor.Simulation_Energy_6
    name: "Total energy production 8"



#TestingVariable
var:
  energyconsumption:
    friendly_name: 'Energy consumption'
    initial_value: 0
    icon: mdi:lightning-bolt
    
  energyproduction:
    friendly_name: 'Energy production'
    initial_value: 0
    icon: mdi:lightning-bolt

And this is the automation:

- id: '1646324099997'
  alias: Energy production tracker
  trigger:
  - platform: state
    entity_id: sensor.simulation_energy_6
  condition: []
  action:
  - service: variable.set_variable
    data:
      variable: var.energy_production
      value: sensor.simulation_energy_6
  hide_entity: false

The automation does not work and i have not found a solution yet.
Can someone help me figure this out?

value: "{{ states('sensor.simulation_energy_6') }}"

See: https://www.home-assistant.io/docs/configuration/templating/#states

I tried it but it still doesn’t seem to work.
Do you have any other ideas?

- id: '1646324099997'
  alias: Energy production tracker
  trigger:
  - platform: state
    entity_id: sensor.simulation_energy_6
  condition: []
  action:
  - service: var.set
    data:
      variable: var.energy_production
      value: "{{ states('sensor.simulation_energy_6') }}"
  hide_entity: false