How to fix this template?

Logger: homeassistant.helpers.template
Source: helpers/template.py:1706
First occurred: 11.28.29 (12 occurrences)
Last logged: 11.32.59

Template variable warning: 'value_template' is undefined when rendering '{{ value_template }}'
Template variable warning: None has no element 0 when rendering '{{ state_attr('switch.sonoff_100054cd9a', 'consumption').0 }}'

It would help you get answers if you actually posted the entire template.

1 Like
      forbrug_idag:
        friendly_name: Pool Forbrug
        unit_of_measurement: kWh
        value_template: "{{ state_attr('switch.sonoff_100054cd9a', 'consumption').0 }}"

The problem is your .0, you are pretty much asking for states.switch.sonoff_100054cd9a.consumption.0. What are you trying to do here?

For future reference, you’ll get better help if you adhere to these guidelines:

1 Like

In addition to @r-j-taylor’s comment, consider adding an availability to your sensor like:

{{ state_attr('switch.sonoff_100054cd9a', 'consumption') | is_number }}

1 Like

he is trying to access the first position of an array of values