Not loading automations from packages/automations.yaml

I’m hoping somebody can verify this for me, because I thought i was absolutely going crazy. I have been reorganizing my YAML into packages, and while I used to have a giant file of automations called ‘automations.yaml’, I have been slowing moving each automation into various categorized files where they make sense. However, all the automations that I haven’t moved yet still live in ‘automations.yaml’, which I just moved wholesale into the ‘packages’ folder.

After doing this I had started to notice that some of my automations weren’t even showing up in the dev-states view anymore, and it turns out they were all of the automations in the ‘packages/automations.yaml’ file. I could not figure out why they wouldn’t be loading. The check config button still showed errors in that file, but none of those automations showed up. The “Initialized trigger” line in the log file didn’t show up for any of those particular automations.

Finally, on a whim, I renamed that file to something else, and all the automations in the file showed up again!

Please verify my sanity or lack thereof :slight_smile:

without further code we can’t judge anything much, but you do have a header for automation: in your package?

Yeah I did. I literally just renamed the file. Changed none of the contents.

depending on the way you included your automation.yaml that might be off, can’t just rename it to package. In automation.yaml there wouldn’t have been a header automation: since that is in your configuration.yaml. that included file would only have listed automations.

the package however needs the header automation: since it is in the packages folder (pointed to in configuration,yaml) and can contain any domain, so needs the domain name.

Yep. Totally understood, and I did / do have the “automaton:” header in that file both before and after I renamed it. For the record, all my other packages are working exactly as expected.

I’ll post the entire file here. I’ve renamed it from “automations.yaml” to “general_automations.yaml”. Just ones I didn’t find a better, less general place for yet.

automation:
  - id: homeassistant_upgrade_available
    alias: homeassistant_upgrade_available
    trigger:
      - platform: state
        entity_id: updater.updater
    action:
      - service: persistent_notification.create
        data_template:
          title: 'Home Assistant'
          message: >
            An upgrade to Home Assistant is available (v{{ trigger.to_state.state }}).
            Read the release notes here: {{ trigger.to_state.attributes.release_notes }}

  - id: ifttt
    alias: ifttt
    trigger:
      platform: event
      event_type: ifttt_webhook_received
      event_data:
        action: call_service
    action:
      service_template: '{{ trigger.event.data.service }}'
      data_template:
        entity_id: '{{ trigger.event.data.entity_id }}'
        value: '{{ trigger.event.data.value }}'

  - id: weekday_morning
    alias: weekday_morning
    trigger:
      - platform: time
        at: '06:00:00'
    condition:
      - condition: time
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
    action:
      - condition: template
        value_template: >
          {% set temp = state_attr('weather.dark_sky', 'temperature') %}
          {{ (temp > 24) or (temp < 10) }}
      - service: script.turn_on
        data_template:
          entity_id: >
            {%- set temp = state_attr('weather.dark_sky', 'temperature') -%}
            {%- if (temp > 24) -%}script.upstairs_cool
            {%- elif (temp < 5) -%}script.upstairs_heat,script.downstairs_heat
            {%- elif (temp < 10) -%}script.upstairs_heat
            {%- endif -%}

  - id: weekend_morning
    alias: weekend_morning
    trigger:
    - platform: time
      at: '06:30:00'
    condition:
      - condition: time
        weekday:
          - sat
          - sun
    action:
      - condition: template
        value_template: >
          {% set temp = state_attr('weather.dark_sky', 'temperature') %}
          {{ (temp > 24) or (temp < 10) }}
      - service: script.turn_on
        data_template:
          entity_id: >
            {%- set temp = state_attr('weather.dark_sky', 'temperature') -%}
            {%- if (temp > 24) -%}script.upstairs_cool
            {%- elif (temp < 5) -%}script.upstairs_heat,script.downstairs_heat
            {%- elif (temp < 10) -%}script.upstairs_heat
            {%- endif -%}

  - id: christmas_light_6_hour_bump
    alias: christmas_light_6_hour_bump
    initial_state: 'ON'
    # The christmas laser lights will automatically turn off after 6 hours
    # of being on, so this automation will turn them off and back on again
    # after 6 hours.
    trigger:
      - platform: state
        entity_id: switch.outdoor_switch
        to: 'on'
        for: '05:59:00'
    condition:
      - condition: template
        value_template: >
          {{ (now().month == 12) or (now().month == 1) }}
    action:
      - service: switch.turn_off
        data:
          entity_id: switch.outdoor_switch
      - delay: "00:00:01"
      - service: switch.turn_on
        data:
          entity_id: switch.outdoor_switch

Sorry for picking up this old thread but I seem to have this issue, too.

My configuration is with three packages (beside normal automations in automations.yaml).
All three packages have automations in them and I made subfolders “packages/mypackage/automation.yaml”.

What I found here is that if I name the file in all three packages the same (e.g. “automation.yaml”) only the automations of the first package in the alphabet are loaded (so e.g. having three packages “A_mypackage”, “B_mypackage” and “C_mypackage” only automations from “A_mypackage” are loaded).

If I rename the file inside into e.g. “packages/A_mypackage/A_automation.yaml”, “packages/B_mypackage/B_automation.yaml” and “packages/C_mypackage/C_automation.yaml”, all automations are loaded correctly.

Can somebody confirm this behaviour?
Is this by design or a bug?

I suspect (but it’s a guess) that the issue is that the files all have the same name. From the Packages documentation:

With !include_dir_named , the file name is used as the package name. File names must be unique.

yes - the documentation did not include this information as I wrote the question 3 years!! ago ^^
It was just added in june 2023 :wink:
Update Packages folder - simplify (#27176) · home-assistant/home-assistant.io@b2e7272 (github.com)