Multiplication in template not working

I want to set up a time triggered template to calculate the money i saved with my pv every day. This involves a subtraction of two sensor values first and then a multiplication of the result with another value. If I only include the subtraction, everythings works fine, but adding the multiplication always breaks it. Could anyone please point out to me what I’m doing wrong?

This is how it looks:


template:
  - trigger:
      - platform: time
        at: "23:59:55"
    sensor:
      - name: "PV-Ersparnis am Tag"
        unique_id: "pv_ersparnis_am_tag"
        state_class: total
        unit_of_measurement: "€"
        state: "{{ (states('sensor.tagliche_hauseinspeisung_wr')|float (0) - states('sensor.tagliche_netzeinspeisung')|float (0)) * states(input_number.aktueller_strompreis)|float (0) }}"

This float filter with a default of 0 is this:

float(0)

Not this:

float (0)

No space when specifying arguments for a filter.

Thanks for pointing that out, but it still does’nt work. I removed all the spaces and still get “Not available” when the trigger fires.

The input number entity id needs to be quoted as well.

states('input_number.aktueller_strompreis')

You’re absolutely right. That was it. Sometimes you just can’t see those things anymore. Now it’s working like a charm. Thanks.

1 Like