How to put multiple packages in the same file?

I want to put several packages in one file, while I have other packages in other files. Apparently I have to give them package names, otherwise I get ‘duplicate key’ for input_number etc. But if I add a name, zzz_test_room_heating_package, then I get the error

Configuration warnings

Setup of package ‘heating_x2_definitions’ failed: Integration ‘zzz_test_room_heating_package’ not found.

This is the latest draft of the code:

###
### ZZZ Test room heating control 	
###

zzz_test_room_heating_package:

  input_number:

    zzz_test_room_heating_manual_temperature:
      name: ZZZ Test room heating manual temperature
      min: 0
      max: 100
      step: 0.5
      mode: box
      icon: mdi:temperature-celsius

    zzz_test_room_heating_required_temperature:
      name: ZZZ Test room heating required temperature
      min: 0
      max: 100
      step: 0.5
      mode: box
      icon: mdi:temperature-celsius

  input_text:

    zzz_test_room_heating_setting_reason:
      name: ZZZ Test room heating setting reason
      initial: “”
      icon: mdi:card-text-outline

  timer:

    zzz_test_room_heating_manual_override_timer:
      name: ZZZ Test room heating manual override timer
      duration: "00:00:00"
      restore: true
      icon: mdi:av-timer

    zzz_test_room_heating_warmup_timer:
      name: ZZZ Test room heating warmup timer
      duration: "00:00:00"
      restore: true
      icon: mdi:av-timer

    zzz_test_room_heating_door_or_window_open_timer:
      name: ZZZ Test room heating door or window open timer
      duration: "00:00:00"
      restore: true
      icon: mdi:av-timer

    zzz_test_room_heating_room_unoccupancy_timer:
      name: ZZZ Test room heating room unoccupancy timer
      duration: "00:00:00"
      restore: true
      icon: mdi:av-timer

    zzz_test_room_heating_echoblock_timer:
      name: ZZZ Test room heating echoblock timer
      duration: "00:00:00"
      restore: true
      icon: mdi:av-timer

  template:

    - sensor: 
      - name: ZZZ Test room west TRV set temperature
        unique_id: zzz_test_room_west_trv_set_temperature
        unit_of_measurement: 'C'
        icon: mdi:thermometer
        state: "{{ state_attr('climate.zzz_test_room_west_trv', 'temperature') }}"

    - sensor:
      - name: ZZZ Test room west TRV measured temperature 
        unique_id: zzz_test_room_west_trv_measured_temperature
        unit_of_measurement: 'C'
        icon: mdi:thermometer
        state: "{{ state_attr('climate.zzz_test_room_west_trv', 'current_temperature') }}"

    - binary_sensor:
      - name: ZZZ Test room west TRV heat demand
        unique_id: zzz_test_room_west_trv_heat_demand
        icon: mdi:heat-wave
        state: "{{ float(state_attr('climate.zzz_test_room_west_trv, 'temperature'),0) > float(state_attr('climate.zzz_test_room_west_trv, 'current_temperature'),99) }}" 

  automation:
    - id: zzz_test_room_heating_control
      alias: ZZZ Test room heating control
      description: Controls the heating for the ZZZ Test room using the ZZZ Test room heating schedule calendar
      use_blueprint:
        path: AndySymons/heating_x2.yaml
        input:
          thermostat_controls:
          - zzz_test_room_west_trv
          - zzz_test_room_east_trv
          away_switch: input_boolean.away
          door_or_window_open_sensors: []
          room_occupancy_sensors: []
          room_calendar: calendar.zzz_test_room_heating_schedule
          manual_temperature: input_number.zzz_test_room_heating_manual_temperature
          required_temperature: input_number.zzz_test_room_heating_required_temperature
          setting_reason: input_text.zzz_test_room_heating_setting_reason
          door_or_window_open_timer: timer.zzz_test_room_heating_door_or_window_open_timer
          unoccupancy_timer: timer.zzz_test_room_heating_room_unoccupancy_timer
          warmup_timer: timer.zzz_test_room_heating_warmup_timer
          manual_override_timer: timer.zzz_test_room_heating_manual_override_timer
          echoblock_timer: timer.zzz_test_room_heating_echoblock_timer
          minimum_thermostat_temperature: 5
          maximum_thermostat_temperature: 30
          away_temperature: 5
          background_temperature: 5
          door_or_window_open_period: 00:02:00
          unoccupancy_period: 00:30:00
          warmup_period: 02:00:00
          manual_override_period: 02:00:00

That’s not the way packages work.

each package yaml file is an equivalent configuration.yaml file unto itself.

it can only be configured in the same syntax structure that configuration.yaml is done.

each package has to be in it’s own yaml file and all package yaml files have to be in one single directory.

Mmm, as I feared. That rather scuppers my plan to make the Heating X2 Code Generator more efficient :disappointed_relieved:

The Code Generator currently works by creating separate files for each type of helper, templates and automations. That means you have to run it 5 times. It would be nice to get that down to one, but creating a file for each Room is a house woud be more work for anyone with more than 5 rooms!

I guess there is no such thing as a sub-package? I tried writing packages: at the top of my file, but it would not accept it. Perhaps I should write a Feature Request?

I’ve never heard of such a thing so I doubt it.

I guess it couldn’t hurt.

But I’m not sure if that would help since then those package files would suffer from the same limitations.

According to the Packages documentation, you can define packages in one file by writing …

homeassistant:
  ...
  packages:
    pack_1:
      ...package 1 configuration here...
    pack_2:
      ...package 2 configuration here...
    pack_3:
      ...package 3 configuration here...

… but that has to be all written in the configuration.yaml file. Putting each package in its own file is presented as an alternative, whereby apparently the package name (pack_1 etc.) is replaced by the name of the file within the packages directory. That is rather strange, and not the way !include files work.

What I would like is to be able to put pack_1 in one file and pack_2 and pack_3 both together in a second file. This could easily be achieved by restoring the pack name as a key within the files and ignoring the file name. That would be consistent with the way !include files work but sadly not backward compatible with the current system.