Need help with Template calc

Im trying to get a Daily Display of my Energy Costs. I already have kwh per day as “sensor.tagesverbrauch” i want to multiply it by 1000 to get kwh and then multiply it by my price per kWh which is 0.30. Unfortunaly the Template sensor is not working. Can anybody point me in the right direction?

template:
  - sensor:
      - name: "Tageskosten"
        unit_of_measurement: '€'
        device_class: monetary
        state: "{{((states.sensor.tagesverbrauch | float * 1 / 1000 * 0.30)) | round(2) }}"

confyaml

This corrects your syntax but I’m not sure it does what you want it to:

template:
  - sensor:
      - name: "Tageskosten"
        unit_of_measurement: '€'
        device_class: monetary
        state: "{{ ((states('sensor.tagesverbrauch')|float(0)/1000)*0.30)|round(2) }}"

If the sensor contains daily energy use in kWh, why are you dividing by 1000 (or multiplying, as your text says)? I think you want:

template:
  - sensor:
      - name: "Tageskosten"
        unit_of_measurement: '€'
        device_class: monetary
        state: "{{ (states('sensor.tagesverbrauch')|float(0)*0.30)|round(2) }}"
1 Like