Can I nest include files?

Can I nest include files?

In my configuration.yaml I have my switches all defined in: switch: !include switch.yaml
But one of my platforms, Broadlink, is threatening to grow quite large. For example:

#Broadlink IR Mini remote
#switch
  - platform: broadlink
    host: 192.168.1.39
    mac: '78:0F:77:48:30:DE'
    switches:
      kenmorefan_power:
        friendly_name: "Kenmore Fan Power"
        command_on: 'JgBoAAABKJUSORIUERUSExEVEhMRFBEVERUSORA6EjkSORA6EjkROhA6EjkSFBAVERQRFRIUEBUSExIUETkSNhU5EjgSORE6ETkSORIUERQSExIUEhQRFBITEhQSORA6EjkROhA6EToRAA0F'
        command_off: 'JgBoAAABKJUSORIUERUSExEVEhMRFBEVERUSORA6EjkSORA6EjkROhA6EjkSFBAVERQRFRIUEBUSExIUETkSNhU5EjgSORE6ETkSORIUERQSExIUEhQRFBITEhQSORA6EjkROhA6EToRAA0F'

Under switches: I am likely to have dozens of command codes in my switch.yaml file. so I am wondering if I could put all these definitions in another include file?

Thanks,
Steve

!include dir_list / !include dir_merge_list depending on how you do the split…

Thanks, I’m surprised that didn’t show up when I googled it.

1 Like

Thanks. I am still stumbling along. I tried to split out the IR codes as follows. Here’s my switch.yaml:

#switch
  - platform: broadlink
    host: 192.168.1.39
    mac: '78:0F:77:48:30:DE'
    switches: !Include broadlink.yaml

My broadlink.yaml contains the IR codes:

#    switches:
      kenmorefan_power:
        friendly_name: "Kenmore Fan Power"
        command_on: 'JgBoAAABKJUSORIUERUSExEVEhMRFBEVERUSORA6EjkSORA6EjkROhA6EjkSFBAVERQRFRIUEBUSExIUETkSNhU5EjgSORE6ETkSORIUERQSExIUEhQRFBITEhQSORA6EjkROhA6EToRAA0F'
        command_off: 'JgBoAAABKJUSORIUERUSExEVEhMRFBEVERUSORA6EjkSORA6EjkROhA6EjkSFBAVERQRFRIUEBUSExIUETkSNhU5EjgSORE6ETkSORIUERQSExIUEhQRFBITEhQSORA6EjkROhA6EToRAA0F'

But check config gives this error:

Error loading /config/configuration.yaml: could not determine a constructor for the tag '!Include'

Any tips to resolve this would be appreciated. Is it as simple as an indent error?

Try !include case sensitive likely?

Case sensitive include as @firstof9 says above, and move the k of kenmore_fan to the far left edge of the new file and preserve the indentation below (so friendly_name is 2 spaces from the left edge).

firstof9 - Thanks. I knew the first problem had to be something simple. As one who is anal about grammar and proper sentence structure (because I failed English in High School quite regularly), it’s difficult for me to ignore the shift-key.

mf_social - Also thanks. You saved me from my second problem that I hadn’t even seen yet.

Thanks both of you for your quick response. All is working fine now.
(Now, if I can only figure out how to write automations.)

2 Likes