Problems with configuration.yaml

Hi,

New on the forum and not very good with HA other than creating dashboards and configur in visual editor. I have a problem in my configuration.yaml file, first I had an error that did that I could not change themes. I managed to correct that, but now I have an error that I cannot use the bubble card modules. I have tried to add it in configuration file but get the following error:

bad indentation of a mapping entry (15:14)

12 | script: .include scripts.yaml
13 | scene: .include scenes.yaml
14 | template: .include template.yaml
15 | - trigger:
-------------------^
16 | - trigger: event
17 | event_type: bubble_card_update_modules

Do anyone understand why I get this message and how to rectify it?

Please don’t post pictures of text. Post the text correctly formatted for the forum with the pre-formatted text button </> (sometimes in the cog menu).

1 Like

You cannot use template: !include and then add inline YAML below it: it’s either an included file or inline YAML.

Put that Bubble Card Modules sensor configuration in template.yaml not configuration.yaml. The first line of that file should be:

- triggers:

(the plural version is the latest recommended config [docs])

My apolgies, will do that in the future.

Thank you very much! Can you also explain why i get this error:

Invalid config for 'template' at configuration.yaml, line 14: expected a dictionary '', got 'homeassistant'
Invalid config for 'template' at template.yaml, line 2: 'template' is an invalid option for 'template', check: template

Same picture of configuration.yaml as before only that line 15 to 25 is removed and added to template.yaml

Post both files as text, properly formatted using the </> button. The errors you’re getting don’t match the description of your files. Post configuration.yaml from start to at least the systemmonitor line; and all of template.yaml.

1 Like

Configuration.yaml

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

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes
  extra_module_url:
    - /local/community/custom-brand-icons/custom-brand-icons.js
    

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
template: !include template.yaml

# Example configuration.yaml entry
sensor:
  - platform: systemmonitor
    resources:
      - type: disk_use_percent
        arg: /config
      - type: memory_free
      - type: memory_use_percent
      - type: processor_use
      - type: processor_temperature

template.yaml

# Storage for Bubble Card Modules
template:
  - trigger:
      - trigger: event
        event_type: bubble_card_update_modules
    sensor:
      - name: "Bubble Card Modules"
        state: "saved"
        icon: "mdi:puzzle"
        attributes:
          modules: "{{ trigger.event.data.modules }}"
          last_updated: "{{ trigger.event.data.last_updated }}"
1 Like

I think the template: line is in there twice, once in configuration.yaml and again in the included file.

Try commenting it out in the included file and see if that helps. I comment it out instead of deleting it to remind myself how it’s going to look to HA when the includes are all pulled in.

Let’s see if I understood you correctly. I tried commenting out the template in my template.yaml file:

# Storage for Bubble Card Modules
#template:
- trigger:
    - trigger: event
      event_type: bubble_card_update_modules
  sensor:
    - name: "Bubble Card Modules"
      state: "saved"
      icon: "mdi:puzzle"
      attributes:
        modules: "{{ trigger.event.data.modules }}"
        last_updated: "{{ trigger.event.data.last_updated }}"
                

I then get this error message:

Logger: homeassistant.config
Kilde: config.py:354
Første forekomst: 12:41:57 (5 occurrences)
Sist logget: 13:54:18

Invalid config for 'template' at template.yaml, line 2: 'template' is an invalid option for 'template', check: template
Invalid config for 'template' at template.yaml, line 6: required key 'trigger' not provided

Sorry, YAML spacing is voodoo to me. I usually end up using the trial-and-error method.

What I’d do in your situation is move the contents of the template.yaml file into the configuration.yaml, and get rid of the !include.

Only when I got that working would I try to pull it out into an include file.

If it’s any help, here’s what I’ve got in my configuration.yaml:

#
template:
  - binary_sensor: !include template_binary_sensors.yaml
  - sensor: !include template_sensors.yaml

And here’s template_binary_sensors.yaml:

# template_binary_sensors.yaml
# Included in configuration.yaml
#
#template:
#  - binary_sensor: !include template_binary_sensors.yaml
#
      - name: "East Pump Cycle On"
        unique_id: 'east_pump_on'
etc.

And likewise for template_sensors.yaml.

As always with YAML, note the indentation. And make sure it’s spaces, not tabs. Like I said, voodoo. It seems there are usually a few “right” ways, but lots of “wrong” ways, to do it.

Note what Troon said about what the first line in template.yaml should be.

Indentation is the yaml newcomer demon.

Tip - if you’re branching in the config files, it’s always 2 spaces of indentation. It doesn’t matter if the branch is prefixed with a hyphen (-) either. Always 2 spaces.

If you are using hyphens, it’s only 1 space after the hyphen, then the code.

When you use !include files, build the code as if the parent branch is there. In other words, you are always going to start your code in an !include file with 2 spaces, as if it is nested directly under the parent branch.

1 Like

Thank you everyone for replies and help. I’m still struggling with error codes. I have tried to paste the Bubble Card Modules sensor in template.yaml and the modules work but still get the error codes. Started with - triggers: as mentioned by Troon (I don’t know if the entry should be adjusted after that or if it just to paste the rest after that?)

template.yaml:

 # Storage for Bubble Card Modules
- triggers:
    - trigger: event
      event_type: bubble_card_update_modules
  sensor:
    - name: "Bubble Card Modules"
      state: "saved"
      icon: "mdi:puzzle"
      attributes:
        modules: "{{ trigger.event.data.modules }}"
        last_updated: "{{ trigger.event.data.last_updated }}"
                

Error codes:

Logger: homeassistant.config
Kilde: config.py:354
Første forekomst: 12:41:57 (13 occurrences)
Sist logget: 20:13:12

Invalid config for 'template' at template.yaml, line 2: 'template' is an invalid option for 'template', check: template
Invalid config for 'template' at template.yaml, line 6: required key 'trigger' not provided
Invalid config for 'template' at template.yaml, line 3: expected str for dictionary value 'triggers->0->platform', got None
Invalid config for 'template' at template.yaml, line 3: 'template' is an invalid option for 'template', check: template
1 Like

it looks like you somehow have another template.yaml file somewhere or you aren’t properly saving the file.

the error says it found “template” at line 2 (where it was previously) in the template.yaml file but the last one you posted doesn’t contain that word.

have you reloaded the template yaml integration (or restarted HA) after you made the changes?

1 Like

@JoiLSch — what finity said, but also, what version of HA are you running? Some of the wording in the error messages suggests you might be a few versions behind…

The sensor portion works, but I’m working through the trigger issue :grimacing:

Latest reply from the owner : Can you try with - triggers: instead ? (Only for the first line)

Unfortunately, I haven’t used this HACs integration in a while…

Hi everyone. Been away a few days, but thanks again for all the help/suggestions/tips. Didn’t expect this much help when I signed up to the community, so very grateful for that.

It looks like it might have been the version of HA I was running in combination of how to “start” the template.yaml file. The template yaml file looks like this now:

 # Storage for Bubble Card Modules
- triggers:
    - trigger: event
      event_type: bubble_card_update_modules
  sensor:
    - name: "Bubble Card Modules"
      state: "saved"
      icon: "mdi:puzzle"
      attributes:
        modules: "{{ trigger.event.data.modules }}"
        last_updated: "{{ trigger.event.data.last_updated }}"
                

I have restarted HA once again just to check and error codes is gone.

Thank you everyone!

1 Like