I’m trying to transition to packages, and want to know what, exactly, I can include. I understand things like switch: and sensor entries are possible. But how about things like include/exclude lists for records or homekit? If I add another sensor in a package, can I also include it in my homekit component within the package? Exclude it from the recorder, inside the package?
For example, can I have something like this in a package file:
and have it work correctly? Where these specific inclusions/exclusions will be merged in with other items from other packages to create the fill inclusion/exclusion set?
I don’t use those buttons anyway, so that’s not a downside.
For me, the advantage is that everything related to something will be in one place. For example, everything connected to the living room lighting - PIR sensors, timers, light controls, automations, customizations, etc. If I need to change something, I don’t need to look in 5 different places, it’s all right there.
I love packages because I can group everything for a specific task or item into one yaml file.
For example I have an ensuite_light.yaml which has the code for the light itself (yeelight) plus the automations and scripts associated with that light. I have a kitchen_light.yaml with a similar setup. So when I want to make a change for a particular item in my house, its only a matter of editing one file.
I guess my main (most complex) package is for my retic (irrigation for the non-aussies ) which has almost every domain in HA! (switch, sensor, binary_sensor, input_datetime, input_number, script, automation… you get the idea) If this was not a package I’d have A LOT of different files to play with for one ‘task’.
The reload thing isn’t much of an issue when a full HA restart only takes a minute or so.
Nice topic. Im thing also to change my config to packages.
I want split them up into rooms: Livingroom, Bedroom, etc…
Global stuff like some automations will into global_system.yaml
I think this makes editing much more easier. I have now everything split up in many files
What you can do is simply have folders for each room then yaml files for each item in that room. Eg: I have a yaml file for my kitchen lights which then has all the input_numbers, automations, scripts etc for that entity
That’s a yaml anchor. For some reason people tend to dump them at the top of packages even though most of the time they’re not beneficial.
What it does is prevent duplication, so if you’re reusing the same values all the time you just write a reference to them once and then include the reference whenever you want to duplicate the code.
The best example I can give is here…
Basically the turn_off action for the switch is identical to the turn_on, so I anchored the turn_on and replicated it in the turn_off saving several lines of code.
Thanks, very nice way solution.
To understand it bit more. When i add a anchor in 1 yaml file, i can use them also in other yaml files to prevent duplicates, or only inside the same yaml file?
Otherwise i create a yaml file where i put all the anchor parts.
And HA is not complaining that it miss a script part while restart? When it load a yaml script without the anchor already loaded, how does it handle that?
Sorry for all the questions, but want to understand it well before change everything
They only work in the file they’re declared in, so if you think you’re going to have a lot of duplicated code try to formulate your packages around that.