Includes sound simple and yet just does not work for me!

I decided to start as I would in any programming language spliting logical chunks into seperate files. All seemed simple I thought use something like

myfile: !include myfiles.yaml

and that would include the myfiles.yaml file and add the stuff inside. Well it doesn’t and I really cannot see why. The file exists it is in the same directory as the configuration.yaml file yet it does not get included. All I get is “integration xxxx not found” when I run the checks. I’ve tried it in and out of directories and I just cannot figure out why I cannot even achieve including a file. All of the other includes seem to work i.e. groups.

I read the trouble shooting advice. Look at HomeAssistant.log. Can’t find that one, found a log in the development bit of hassio, that had nothing in though. Read the next bit access with SSH. Installed the plugin. Not allowed to connect to it.

I just want to include a file. Where am I going wrong here as it really is not obvious to me. I’ve probably been banging my head on it for too long and cannot see the obvious so please put me straight.

AFAIK, you can’t just include a file (like you would in C.) You include a file under a basic key, and myfile is not a basic key in HA.

E.g.,

group: !include groups.yaml

includes the contents of groups.yaml under the group: key. So if groups.yaml contains:

abc:
  ...
xyz:
  ...

That would be the equivalent of:

group:
  abc:
    ...
  xyz:
    ...

FWIW, I find packages to be the most useful. E.g.:

homeassistant:
  packages: !include_dir_named packages

Then any file in <config>/packages are effectively included they way you’re thinking. E.g., if I had a file named <config>/packages/package1.yaml, it could contain things like:

input_boolean:
  abc:
automation:
  - alias: Automation 1
    trigger:
       ...
sensor:
  - platform: template
    ...
1 Like

What domain or integration is “myfile”?

1 Like

Ah that makes sense, and it sounds like packages are what I need to be using. I’m just trying not to end up with a configuration file that is totally enormous and would prefer to break it down into logical chunks.

The articles I read on this did not make that very clear at all. So I’m off to give packages a go.

1 Like

Alas package does not work either. I still get integration not found until I remove it.

I also tried creating a file called remotes.yaml that contained

platform: harmony
name: harmony
host: 10.0.20.4

and created a command
remote: !include remotes.yaml

That failed too. I clearly am not getting this. I just put the whole remote shebang in configuration.yaml and it cleared configuration fine.

Packages work (I have a lot of them), but you might have gotten the syntax wrong. Feel free to share what you’ve done here and maybe we can spot the problem.

Your second attempt (with remote: !include remotes.yaml) probably didn’t work because you didn’t have the syntax correct. E.g., I suspect this is what you have in configuration.yaml:

remote:
  - platform: harmony
    name: harmony
    host: 10.0.20.4

If you want to split that up using packages, you should be able to copy that exact code into a package file. Or, with your other layout (using remote: !include remotes.yaml), remotes.yaml should contain:

- platform: harmony
  name: harmony
  host: 10.0.20.4

BTW, when you post YAML code you really need to format it properly so we can read it correctly.

Packages is a SUBSET of homeassistant:

Ah, I figured that the - was just how the platform: was split from remote: learning Yaml on the fly is not as straightforward as I thought :wink:

I got that working and then discovered that the remote already existed. No idea what is bringing it into existence, i found it in the developer bit when looking for help with what was going wrong. I feel like I am just barely in control of HA. Thanks for the help with it. This is just the first thing I was trying to get working. I have a house full of lightwaveRF stuff run currently from domoticz that I want to bring over. Thought I’d start simple though and keep it clean :slight_smile:

This is how basic my setup is so far, it is literally straight from install with the customize.yaml added as it was missing and the package down the bottom.

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123

# Text to speech
tts:
  - platform: google_translate

homeassistant:
  customize: !include customize.yaml

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

package: !include_dir_named larch

person:

I have a directory called larch directly in config. Right now it has no yaml files in it though.
If I don’t comment the package line out I get

Configuration validation

Validate your configuration if you recently made some changes to your configuration and want to make sure that it is all valid

Configuration invalid

Component error: package - Integration package not found
package: !include_dir_named larch

No

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

Then put your larch.yaml package in the packages directory.

1 Like

Got it, thank you.

So essentially all of the names are preset, you cannot customise them or group things in other directories than predefined names?

No, you just included packages: in the wrong place. It has to be under homeassistant:. Oh, and it’s packages: not package:.

People can, you can’t yet because you don’t know what you’re doing so best to stick with convention for now until you learn enough to customize your configuration to your wildest desires.

Yeah, sounds logical. Yaml is all very illogical and picky to me at this point. Too many years spent with C type languages :wink: Like a challenge though. Thank you very much for the help.

1 Like

It’s picky, but not illogical at all.