Solar production custom sensor confusing

I have managed to get data from my solar system and want to integrate them the Energy panel as well… I have created the sensor that stored the daily energy produced in kWh and added it to the energy panel as solar production. This made the icon to appear in the dashboard but the value is always zero! Below is the configuration.yaml sensor definition that comes from a script producing a json line. Tried with state_class total_increasing as well with tjhe same results… Documentation is not very detailed… Understanding Home Energy Management - Home Assistant

  - sensor:
      unique_id: "pvmg_edaily"
      name: "PV E-Daily"
      unit_of_measurement: 'kWh'
      state_class: total
      device_class: energy
      state: '{{ state_attr("sensor.pv_input_power","edaily") }}'