You’re mixing two things here, this is exactly what packages are not for. If you want to include device or integration specific files, you don’t need to use packages
. These can be included via splitting up the configuration > advanced.
It doesn’t hurt to do it that way, but the real advantages in packages
is to not need to put all sensors or input_xy or ?? into one file each. In packages
you mix all the different things in one file which allows for a more logical approach to sort and devide like rooms or areas or whatever.
There are two ways to handle the outsourcing of things out of configuration.yaml
. One is the way you partly described, where you put every integration
like sensor
, input_boolean
, input_datetime
and so on into one file for each integration and let them load via the one command for each in configuration.yaml
.
Like this:
# configuration.yaml
sensor: !include sensor.yaml
# or for directories with different files
sensor: !include_dir_list sensors
This would work for a setup, where you have either a file sensor.yaml
in the same directory where configuration.yaml
lives, or you have a folder in that same directory where you have different files like sensor_1.yaml
, sensor_2.yaml
or whatever_name_you_want.yaml
.
# directory structure
|--- sensors/
| |--- sensor_1.yaml
| |--- sensor_2.yaml
| |--- whatever_name_you_want.yaml
|--- configuration.yaml
|--- sensor.yaml #only one is allowed, either file or directory
In every file you now can only list sensor
s:
#sensor:
- ...
If you want that, this is your way to go.
Now the second method to get things out of configuration.yaml
is packages
. As stated above, they allow for another direction to go to, where you put all things together, that belong together in the logic you invent. An example would be, you want to have all your things belonging to your front door in one file, no matter the type.
Like this:
# configuration.yaml
homeassistant:
packages: !include_dir_named packages
# directory_structure
|--- packages/
| |--- frontdoor_package.yaml
| |--- backdoor_package.yaml
|--- configuration.yaml
And in your file frontdoor_package.yaml
, you work like this:
input_boolean:
- ...
automation:
- id: whenever my door opens
...
- id: whenever my door closes
...
template:
binary_sensor:
frontdoor_is_open
alert:
- ...
As you can see, everything is in this one file. From automation
s to sensor
s and whatever your heart wants. I personally find that very appealing, it is way more of a logical order in my eyes. If i have to look for something, I finally find it on a first glance. That might have to do with my age, but I don’t want to remember how I named the one specific sensor on my front door. I just look into one file and find it.
Please don’t misunderstand me, there is no right or wrong with this, it is just a flavour question. What is the logic, you want to put behind all this? And not to forget, you can mix and match as you want. Like you did in your post above, there is surely no harm in including the package folder and use it with domains (like sensor
or ìnput_boolean
). It just doesn’t make use of the most important feature of packages
- the possibility to include every domain without naming it in configuration.yaml
.