Invalid config for [template]

Logger: homeassistant.config
Source: config.py:978
First occurred: 13 juli 2023 kl. 18:26:00 (1 occurrences)
Last logged: 13 juli 2023 kl. 18:26:00
Invalid config for [template]: [name] is an invalid option for [template]. Check: template->name. (See /config/configuration.yaml, line 57)

# Loads default set of integrations. Do not remove.
default_config:
my:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

# Text to speech
tts:
  - platform: google_translate

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
#sensor: !include sensor.yaml


sensor:
  - platform: nordpool

    # Should the prices include vat? Default True
    VAT: False

    # What currency the api fetches the prices in
    # this is only need if you want a sensor in a non local currency
    currency: "SEK"
    
    # Option to show prices in cents (or the equivalent in local currency)
    price_in_cents: false

    # Helper so you can set your "low" price
    # low_price = hour_price < average * low_price_cutoff
    low_price_cutoff: 0.95

    # What power regions your are interested in.
    # Possible values: "DK1", "DK2", "FI", "LT", "LV", "Oslo", "Kr.sand", "Bergen", "Molde", "Tr.heim", "Tromsø", "SE1", "SE2", "SE3","SE4", "SYS", "EE"
    region: "SE3"

    # How many decimals to use in the display of the price
    precision: 3

    # What the price should be displayed in default
    # Possible values: MWh, kWh and Wh
    # default: kWh
    price_type: kWh

    # This option allows the usage of a template to add a tariff.
    # now() always refers start of the hour of that price.
    # this way we can calculate the correct costs add that to graphs etc.
    # The price result of the additional_costs template expects this additional cost to be in kWh and not cents as a float
    # default {{0.0|float}}
    additional_costs: "{{0.0|float}}"


template:
 - sensor:
   name: "stromverbrauch"
   unit_of_measurement: kWh
   state_class: total_increasing
   device_class: energy
   state: "{{ states('input_number.stromablesen') }}"
   



 - sensor:

     - name: sophamtning_days

       state: >-

         {{ min(((state_attr('calendar.sophamtning', 'start_time') | as_timestamp - today_at('00:00') | as_timestamp) / 86400) | int,2) }}

       attributes:

         days: >-

           {{ ((state_attr('calendar.sophamtning', 'start_time') | as_timestamp - today_at('00:00') | as_timestamp) / 86400) | int }}

On line 57 it’s

template:

  • sensor:

So something with that one, what am i doing wrong? Help out a beginner :slight_smile:

you only need - sensor: once, and each - name: needs to be aligned.
Try this:

template:
  - sensor:
      - name: "stromverbrauch"
        unit_of_measurement: kWh
        state_class: total_increasing
        device_class: energy
        state: "{{ states('input_number.stromablesen') }}"
   
      - name: sophamtning_days
        [...]

[edited for typos and clarity]

template:
 - sensor:
   name: "stromverbrauch"
   unit_of_measurement: kWh
   state_class: total_increasing
   device_class: energy
   state: "{{ states('input_number.stromablesen') }}"
   

  - name: sophamtning_days

    state: >-

    {{ min(((state_attr('calendar.sophamtning', 'start_time') | as_timestamp - today_at('00:00') | as_timestamp) / 86400) | int,2) }}

    attributes:

    days: >-

    {{ ((state_attr('calendar.sophamtning', 'start_time') | as_timestamp - today_at('00:00') | as_timestamp) / 86400) | int }}

gives error

63 | state: "{{ states('input_numbe …
64 |
65 |
66 | - name: sophamtning_days
--------^
67 |
68 | state: >-

My bad, now i got this.

template:
 - sensor:
   name: "stromverbrauch"
   unit_of_measurement: kWh
   state_class: total_increasing
   device_class: energy
   state: "{{ states('input_number.stromablesen') }}"
   

 - name: sophamtning_days

   state: >-

     {{ min(((state_attr('calendar.sophamtning', 'start_time') | as_timestamp - today_at('00:00') | as_timestamp) / 86400) | int,2) }}

   attributes:

    days: >-

     {{ ((state_attr('calendar.sophamtning', 'start_time') | as_timestamp - today_at('00:00') | as_timestamp) / 86400) | int }}

shall check and see if its alright :slight_smile:

You have the name section indented wrong and you are missing the dash.

…you have:

template:
 - sensor:
   name: "stromverbrauch"

and you should have:

template:
  - sensor:
      - name: "stromverbrauch"

…copy/paste what I wrote and then line* everything up to it.

[edit: typo*]

1 Like