Calculation sensor not working

Hello,
I have a “small” problem. I have created several sensors via configuration.yaml and they work fine. Now I want to create a new sensor that takes a sensor value and calculates it * 365. The existing sensor provides data that I am ready to use and the value is also displayed correctly under “States”.
Unfortunately, the new sensor only ever returns 0. Does anyone have any idea why this might be?

This sensor works:

      # Verbrauch seit letzter Ablesung 
      - name: "Durchschnittsverbrauch seit letzter Ablesung"
        unique_id: "durchschnittsverbrauch"
        unit_of_measurement: "kWh"
        device_class: "energy"
        state_class: "total_increasing"
        state: >-
            {{ ((states('sensor.stromverbrauch_ab_referenzwert') | float(0)) / (states('sensor.vergangene_tage_seit_letzter_ablesung_2') | float(1))) | round(3) }}

the new one:

template:
  - sensor:
      - name: "Jahresverbrauch"
        unique_id: jahresverbrauch
        unit_of_measurement: "kWh"
        state_class: measurement
        device_class: energy
        state: "{{ (states('sensor.durchschnittsverbrauch') | float(0) * 365) | round(2) }}"

Try sensor.durchschnittsverbrauch_seit_letzter_ablesung instead of sensor.durchschnittsverbrauch

1 Like