State sensor (time) as virtual utility meter

Hi Folks!

(I can’t find any similar question or sensor modification in the past, so let me show my problem.)

I have a sonoff thermo sensor which controll an electric heater.
I see the daily usage with history:

  - platform: history_stats
    name: electric heater
    entity_id: switch.sonoff
    state: "on"
    type: time
    start: "{{ now().replace(hour=0, minute=0, second=0) }}"
    end: "{{ now() }}"

The heater use a constant energy which is 1.1kW / hour
So i try multiply this with previous sensor

  - platform: template
    sensors:
      electric_heater_kwh:
        friendly_name: electric heater kWh
        value_template: "{{ states('sensor.electric_heater') | float(0) * 1.1 }}"
        unit_of_measurement: "kWh"

but it show me only 0

Maybe i have to modify the history sensor output for a natural number like 2,12 but i’ve lost with it.

Please if you have any idea write me.
Thank you

Thank you guys, appreciate the help