Why do I get this error message with this template?

Why do I get this error message with this template?

      hausverbrauch_actual:
        friendly_name: "Hausverbrauch (aktuell)"
        unique_id: Hausverbrauch_actual
        unit_of_measurement: 'W'
        device_class: power
        value_template: '{{ (states("sensor.inverter_active_power") |float) - (states("sensor.power_meter_active_power") |float) }}'

Are you sure unique_id is supported by the old format of template sensors? And are you sure unique_id supports upper case?

Try this instead:

template:
  - sensor:
      - name: Hausverbrauch (aktuell)
        unique_id: hausverbrauch_actual
        unit_of_measurement: 'W'
        device_class: power
        availability: '{{ is_number(states("sensor.inverter_active_power")) and is_number(states("sensor.power_meter_active_power"))}}'
        state: '{{ (states("sensor.inverter_active_power") |float) - (states("sensor.power_meter_active_power") |float) }}'

And do you get any error when you reload the template entities configuration or when you do a config check in Developer Tools?

1 Like

I forgot to enter template and sensor in the yaml.
Thank you very much.


1 Like