A little help with a template

HI all
I have the following template in custom button card

custom_fields:
notification: |
[[[ return (states[‘sensor.daily_energy’].state ) ]]]

how can I make it return 1 decimal - insted of 5 that returns now?
the sensor.daily_energy is giving 1 decimal but not inside the template

thanks

Custom button card uses javascript templates, so you should be able to do

[[[ return (states[‘sensor.daily_energy’].state.toFixed(1)) ]]]

or possibly

[[[ return (parseFloat(states[‘sensor.daily_energy’].state).toFixed(1)) ]]]

unfortunately none of the is working. the first one it was proposed from gemini ai too (among other propositions) but with no happy ending.

the solution is

  notification: |
    [[[
      var energy = states['sensor.daily_energy'].state;
      return `
        ${parseFloat(energy).toFixed(1)}
      `;
    ]]]```