One of the identical automations is unvailable when certain file name is used with packages

Hello,
I’m struggling with one of my automations. I have two identical files (for troubleshooting purposes only):

  • hvac.yaml
  • hvac_beta.yaml
    (see content below)

When I use hvac_beta.yaml with hvac.yaml commented out then hvac automations are working.
When I use hvac.yaml with hvac_beta.yaml commented out then hvac automations are NOT working.

It seems like hass has the path to hvac.yaml cached somewhere and it’s not working as it should. Also, I’m not sure if that matters but I may have removed automations from GUI manually when I first played with hvac.yaml.

I know I could just rename the file and move on but I’m trying to understand what am I doing/did wrong so I don’t repeat that mistake.

Any hints will be greatly appreciated!
Thanks

More info:
I’m using packages and I’m including them like this:

---
homeassistant:
  # customize: !include customize.yaml
  packages: !include_dir_named packages

# Enables configuration UI
config:

# Incorporate latest changes
default_config:

My file structure is as follows:

├── automations.yaml
├── configuration.yaml
├── known_devices.yaml
├── packages
│   ├── automations
│   │   ├── fire_alarm.yaml
│   │   ├── hvac.yaml
│   │   ├── hvac_beta.yaml
│   │   ├── security_alarm.yaml
│   │   └── watering.yaml
│   ├── groups
│   │   └── groups.yaml
│   ├── helpers
│   │   ├── hvac.yaml
│   │   └── security_alarm.yaml
│   ├── integrations
│   │   ├── device_tracker.yaml
│   │   ├── discord.yaml
│   │   ├── fibaro.yaml
│   │   ├── http.yaml
│   │   ├── tts.yaml
│   │   ├── waze.yaml
│   │   └── xiaomi_miio.yaml
│   ├── scenes
│   │   └── scenes.yaml
│   └── scripts
│       └── scripts.yaml
└── secrets.yaml

hvac.yaml/hvac_beta.yaml:

automation:
  # ---------------------------------------------------------------------------- #
  #                            HVAC Bathroom Automation                          #
  # ---------------------------------------------------------------------------- #

  - id: hvac_bathroom
    alias: "HVAC Bathroom"
    initial_state: true
    trigger:
      - platform: time_pattern
        minutes: "/15"
    condition:
      condition: and
      conditions:
        - condition: numeric_state
          entity_id: weather.ishome
          attribute: temperature
          below: 15
        - condition: state
          entity_id: group.family
          state: home
    action:
      - choose:
          - conditions:
              - condition: time
                after: "05:30:00"
                before: "06:29:00"
            sequence:
              - service: climate.set_temperature
                entity_id: climate.thermostat_bathroom
                data:
                  temperature: "{{ states('input_number.target_temperature_bathroom') | float }}"
          - conditions:
              - condition: time
                after: "06:30:00"
                before: "07:30:00"
            sequence:
              - service: climate.set_temperature
                entity_id: climate.thermostat_bathroom
                data:
                  temperature: "{{ states('input_number.target_temperature_bathroom') | float - 2 }}"
          - conditions:
              - condition: time
                after: "19:00:00"
                before: "20:29:00"
            sequence:
              - service: climate.set_temperature
                entity_id: climate.thermostat_bathroom
                data:
                  temperature: "{{ states('input_number.target_temperature_bathroom') | float }}"
          - conditions:
              - condition: time
                after: "20:30:00"
                before: "21:30:00"
            sequence:
              - service: climate.set_temperature
                entity_id: climate.thermostat_bathroom
                data:
                  temperature: "{{ states('input_number.target_temperature_bathroom') | float - 2 }}"
        default:
          - service: climate.set_temperature
            entity_id: climate.thermostat_bathroom
            data:
              temperature: 7

  # ---------------------------------------------------------------------------- #
  #                            HVAC Bedroom Automation                           #
  # ---------------------------------------------------------------------------- #

  - id: hvac_bedroom
    alias: "HVAC Bedroom"
    initial_state: true
    trigger:
      - platform: time_pattern
        minutes: "/15"
    condition:
      condition: and
      conditions:
        - condition: numeric_state
          entity_id: weather.ishome
          attribute: temperature
          below: 15
        - condition: state
          entity_id: group.family
          state: home
    action:
      - choose:
          - conditions:
              - condition: time
                after: "21:00:00"
                before: "23:59:00"
              - condition: template
                value_template: "{{ states('sensor.thermometer_bedroom') | float < states('input_number.target_temperature_bedroom') | float }}"
            sequence:
              - service: climate.set_temperature
                entity_id: climate.thermostat_bedroom
                data:
                  temperature: "{{ states('input_number.target_temperature_bedroom') | float }}"
          - conditions:
              - condition: time
                after: "00:00:00"
                before: "01:59:00"
              - condition: template
                value_template: "{{ states('sensor.thermometer_bedroom') | float < states('input_number.target_temperature_bedroom') | float - 1 }}"
            sequence:
              - service: climate.set_temperature
                entity_id: climate.thermostat_bedroom
                data:
                  temperature: "{{ states('input_number.target_temperature_bedroom') | float - 1 }}"
          - conditions:
              - condition: time
                after: "02:00:00"
                before: "04:00:00"
              - condition: template
                value_template: "{{ states('sensor.thermometer_bedroom') | float < states('input_number.target_temperature_bedroom') | float - 2 }}"
            sequence:
              - service: climate.set_temperature
                entity_id: climate.thermostat_bedroom
                data:
                  temperature: "{{ states('input_number.target_temperature_bedroom') | float - 2 }}"
        default:
          - service: climate.set_temperature
            entity_id: climate.thermostat_bedroom
            data:
              temperature: 7

  # ---------------------------------------------------------------------------- #
  #                          HVAC Living Room Automation                         #
  # ---------------------------------------------------------------------------- #

  - id: hvac_living_room
    alias: "HVAC Living Room"
    initial_state: true
    trigger:
      - platform: time_pattern
        minutes: "/15"
    condition:
      condition: and
      conditions:
        - condition: numeric_state
          entity_id: weather.ishome
          attribute: temperature
          below: 15
        - condition: state
          entity_id: group.family
          state: home
    action:
      - choose:
          - conditions:
              - condition: time
                after: "06:00:00"
                before: "22:00:00"
              - condition: template
                value_template: "{{ states('sensor.thermometer_living_room') | float < states('input_number.target_temperature_living_room') | float }}"
            sequence:
              - service: climate.set_temperature
                entity_id:
                  - climate.thermostat_living_room_terrace
                  - climate.thermostat_living_room_corner
                data:
                  temperature: "{{ states('input_number.target_temperature_living_room') | float }}"
        default:
          - service: climate.set_temperature
            entity_id:
              - climate.thermostat_living_room_terrace
              - climate.thermostat_living_room_corner
            data:
              temperature: 7

  # ---------------------------------------------------------------------------- #
  #                            HVAC Kitchen Automation                           #
  # ---------------------------------------------------------------------------- #

  - id: hvac_kitchen
    alias: "HVAC Kitchen"
    initial_state: true
    trigger:
      - platform: time_pattern
        minutes: "/15"
    condition:
      condition: and
      conditions:
        - condition: numeric_state
          entity_id: weather.ishome
          attribute: temperature
          below: 15
        - condition: state
          entity_id: group.family
          state: home
    action:
      - choose:
          - conditions:
              - condition: time
                after: "06:00:00"
                before: "22:00:00"
              - condition: template
                value_template: "{{ states('sensor.thermometer_kitchen') | float < states('input_number.target_temperature_living_room') | float }}"
            sequence:
              - service: climate.set_temperature
                entity_id:
                  - climate.thermostat_kitchen
                data:
                  temperature: "{{ states('input_number.target_temperature_living_room') | float }}"
        default:
          - service: climate.set_temperature
            entity_id:
              - climate.thermostat_kitchen
            data:
              temperature: 7

Are you restarting homeassistant between changing which files are used?

When you say you’re ‘commenting’ them out, you should never comment out a whole file, simply change the file extension to .txt so that homeassistant doesn’t pick it up.

Also, if you’re using automations in packages, you shouldn’t be using the id key for them. I mean you can, but it’s pointless and could lead to problems if you accidentally use the same id for more than one automation.

I suspect the latter is the problem here. You have 2 files with identical contents, including automations with duplicate id fields. Nothing good can come from this.

Thanks for prompt reply @anon43302295.

Yes, I am restarting between changes.

By commenting out I mean I am commenting out the content of the file. It’s essentially an empty file so I don’t get any id dups. Also, I know that my ids are unique now but they may not have been some time ago when I was starting to set up hass for the first time.

For testing, I renamed hvac_beta.yaml to hvac_beta.txt but problem still persists.

Errors in the log?

I’ve also just realised that you have two hvac.yaml packages. One in automation and one in helpers.

I’m curious why you’re using packages rather than includes for this structure anyway? The point of packages is to group multiple components in to a a logical function.

One but not related. On my todo list:

2020-11-27 09:47:19 WARNING (SyncWorker_13) [homeassistant.components.waze_travel_time.sensor] Error on retrieving data: empty response

Also config is valid as well:

automations ha core check
Processing... Done.

Command completed successfully.

Fully agree on second hvac.yaml in helpers. I will be merging it with hvac.yaml in automations. Just wanted to understand this problem first.

hvac.yaml in helpers for reference:

---
input_number:
  target_temperature_living_room:
    name: Salon
    icon: mdi:thermometer
    min: 7
    max: 35
    step: 1
    mode: box
    unit_of_measurement: °C
  target_temperature_bedroom:
    name: Sypialnia
    icon: mdi:thermometer
    min: 7
    max: 35
    step: 1
    mode: box
    unit_of_measurement: °C
  target_temperature_bathroom:
    name: Łazienka
    icon: mdi:thermometer
    min: 7
    max: 35
    step: 1
    mode: box
    unit_of_measurement: °C

But nevertheless you have two packages called ‘hvac’ - this won’t work.

The configuration checker only checks that the yaml is valid, not the logic.

I suspect when you use the hvac package in automations, it is immediately overwritten by the one in helpers as h comes after a in the alphabet.

Ah, I thought I can have the same filenames under different paths.
That was it, after changing the name of the hvac in helpers everything started to work again.

Just to confirm - folders in packages are only for organizing the content and aren’t referenced in the map that’s being returned from !include_dir_named?

Thank you!

1 Like

Exactly that. Your package will be ‘named’ after the yaml file it’s in.

Perfect, many thanks!

1 Like