Need help with !include_dir_merge_named

i need help with the !include_dir_merge_named

everything i do it keeps spitting out errors… when you run configuration checker…
ive done 2 different ways 1 with - plaform: template and other without as it complained there was no platforum
ive tried google… and didnt help then i read another splitting up pages HA
and it shows like i guess if you wanna use group: you make a folder group
so i confused in getting it to work

as i wanna do house under packages, and then have basement_light_switchs, group, dehumidifiers… and upstairs_light_switchs
to make it easier to edit later… but its not working right
as i wanna do outside and my shop and maybe couple other break downs so i not having to look in switch.yaml i have or sensor.yaml etc

so below i use the same switchs as a place holder to get this to work

light_switchs.yaml

house_light_switchs:
  - platform: template
    switch:
      dehumidifier_3:
        friendly_name: "Dehumidifier 3"
        value_template: "{{ is_state('switch.tp_link_smart_plug_04bb_island_light', 'on') }}"
        turn_on:
          action: switch.turn_on
          target:
            entity_id: switch.tp_link_smart_plug_04bb_island_light
        turn_off:
          action: switch.turn_off
          target:
            entity_id: switch.tp_link_smart_plug_04bb_island_light
      dehumidifier_4:
        friendly_name: "Dehumidifier 4"
        value_template: "{{ is_state('switch.tp_link_smart_plug_04bb_island_light', 'on') }}"
        turn_on:
          action: switch.turn_on
          target:
            entity_id: switch.tp_link_smart_plug_04bb_island_light
        turn_off:
          action: switch.turn_off
          target:
            entity_id: switch.tp_link_smart_plug_04bb_island_light

dehumidifier.yaml

house_dehumidifier:
  switch:
    dehumidifier_3:
      friendly_name: "Dehumidifier 3"
      value_template: "{{ is_state('switch.tp_link_smart_plug_04bb_island_light', 'on') }}"
      turn_on:
        action: switch.turn_on
        target:
          entity_id: switch.tp_link_smart_plug_04bb_island_light
      turn_off:
        action: switch.turn_off
        target:
          entity_id: switch.tp_link_smart_plug_04bb_island_light
    dehumidifier_4:
      friendly_name: "Dehumidifier 4"
      value_template: "{{ is_state('switch.tp_link_smart_plug_04bb_island_light', 'on') }}"
      turn_on:
        action: switch.turn_on
        target:
          entity_id: switch.tp_link_smart_plug_04bb_island_light
      turn_off:
        action: switch.turn_off
        target:
          entity_id: switch.tp_link_smart_plug_04bb_island_light

Take another look at the documentation. When splitting up entities you do not include the top level key eg house_light_switchs and house_dehumidifier

https://www.home-assistant.io/docs/configuration/splitting_configuration/#top-level-keys

cuz i wanna do

packages / house
packages /basement
packages/outside
packages/shop

under house folder it be
light_switchs.yaml
sensor.yaml
dehumidifers.yaml
etc

under basement folder
light_switchs.yaml
sensor.yaml
etc

outside folder
etc

shop folder
etc

Sorry I missed the packages key. Looking at what you have vs the docs differs.

homeassistant:
  ...
  packages:
    pack_1: !include my_package.yaml

So something like

homeassistant:
  ...
  packages:
    house_dehumidifier: !include dehumidifier.yaml

ya i read that thats the include
but i trying to do the merge everything

there example is

homeassistant:
  packages: !include_dir_merge_named packages/
YAML
and in packages/subsystem1/functionality1.yaml:

subsystem1_functionality1:
  input_boolean:
  ...
  binary_sensor:
  ...
  automation:

so you gotta add the entire line unless i buggered up my configuration yaml… ill re look

so my configuration is

homeassistant:
  #packages: !include_dir_named ./packages/
  packages: !include_dir_merge_named ./packages/

so it should import everything under packages

so then hte
house_dehumidifier:

is supposed to be file dehumidifier.yaml under the packages/house folder
least thats how i understanding it

You still need to remove the top level keys

dehumidifier.yaml


  switch:
    dehumidifier_3:
      friendly_name: "Dehumidifier 3"
      value_template: "{{ is_state('switch.tp_link_smart_plug_04bb_island_light', 'on') }}"
      turn_on:
        action: switch.turn_on
        target:
          entity_id: switch.tp_link_smart_plug_04bb_island_light
      turn_off:
        action: switch.turn_off
        target:
          entity_id: switch.tp_link_smart_plug_04bb_island_light
    dehumidifier_4:
      friendly_name: "Dehumidifier 4"
      value_template: "{{ is_state('switch.tp_link_smart_plug_04bb_island_light', 'on') }}"
      turn_on:
        action: switch.turn_on
        target:
          entity_id: switch.tp_link_smart_plug_04bb_island_light
      turn_off:
        action: switch.turn_off
        target:
          entity_id: switch.tp_link_smart_plug_04bb_island_light

removing the top line just gives me error
and you can see it says you gotta put the folder name and file name in the config when using merg to merg all the files in folder of package


so my understand is

homeassistant:
  #packages: !include_dir_named ./packages/
  packages: !include_dir_merge_named ./packages/

if you had 50 yamls under packages it would import all 50 yamals and you wouldnt need 50 lines of import lines

Ok so with that each yaml file gets the top level key, like you have. Each yaml file needs it’s own sub folder. /packages/house_dehumidifier/dehumidifier.yaml

then add to configuration.yaml

homeassistant:
  packages: !include_dir_merge_named packages/

ya i have that
reason im stuck not work

so i have
/packages/house/dehumidifer.yaml is the file location

then in the yaml first line i have
house_dehumidifier:

to be folder house and file name dehumidifer.yaml but its not liking that theres where i got the orginal errors

then i get the platform error or key errors… thats where i stuck

so for dehumidifer.yaml i get error

Invalid config for 'switch' at packages/house/dehumidifier.yaml, line 3: required key 'platform' not provided
house_dehumidifier:
  switch:
    dehumidifier_3:
      friendly_name: "Dehumidifier 3"
      value_template: "{{ is_state('switch.tp_link_smart_plug_04bb_island_light', 'on') }}"
      turn_on:
        action: switch.turn_on
        target:
          entity_id: switch.tp_link_smart_plug_04bb_island_light
      turn_off:
        action: switch.turn_off
        target:
          entity_id: switch.tp_link_smart_plug_04bb_island_light
    dehumidifier_4:
      friendly_name: "Dehumidifier 4"
      value_template: "{{ is_state('switch.tp_link_smart_plug_04bb_island_light', 'on') }}"
      turn_on:
        action: switch.turn_on
        target:
          entity_id: switch.tp_link_smart_plug_04bb_island_light
      turn_off:
        action: switch.turn_off
        target:
          entity_id: switch.tp_link_smart_plug_04bb_island_light

but then i get different error when i add -platform: template so i just been spinning in circles stuck

so when i add the platform: template i get this error

Setup of package 'house_dehumidifier' failed: Invalid package definition 'house_dehumidifier': expected a dictionary. Package will not be initialized
house_dehumidifier:
  - platform: template
    switch:
      dehumidifier_3:
        friendly_name: "Dehumidifier 3"
        value_template: "{{ is_state('switch.tp_link_smart_plug_04bb_island_light', 'on') }}"
        turn_on:
          action: switch.turn_on
          target:
            entity_id: switch.tp_link_smart_plug_04bb_island_light
        turn_off:
          action: switch.turn_off
          target:
            entity_id: switch.tp_link_smart_plug_04bb_island_light
      dehumidifier_4:
        friendly_name: "Dehumidifier 4"
        value_template: "{{ is_state('switch.tp_link_smart_plug_04bb_island_light', 'on') }}"
        turn_on:
          action: switch.turn_on
          target:
            entity_id: switch.tp_link_smart_plug_04bb_island_light
        turn_off:
          action: switch.turn_off
          target:
            entity_id: switch.tp_link_smart_plug_04bb_island_light

so i dont know what i doing wrong i thought i followed the examples best i could understand

The format for the template switch should be like this.

switch:
  - platform: template
    switches:
      dehumidifier_3:
      friendly_name: "Dehumidifier 3"
      value_template: "{{ is_state('switch.tp_link_smart_plug_04bb_island_light', 'on') }}"
      turn_on:
        action: switch.turn_on
        target:
          entity_id: switch.tp_link_smart_plug_04bb_island_light
      turn_off:
        action: switch.turn_off
        target:
          entity_id: switch.tp_link_smart_plug_04bb_island_light

ya had that but that gave me orginal error before the orginal post

Invalid config for 'homeassistant' at packages/house/dehumidifier.yaml, line 1: expected dict for dictionary value 'packages->house_dehumidifier', got None
house_dehumidifier:
switch:
  - platform: template
    switches:
      dehumidifier_3:
        friendly_name: "Dehumidifier 3"
        value_template: "{{ is_state('switch.tp_link_smart_plug_04bb_island_light', 'on') }}"
        turn_on:
          action: switch.turn_on
          target:
            entity_id: switch.tp_link_smart_plug_04bb_island_light
        turn_off:
          action: switch.turn_off
          target:
            entity_id: switch.tp_link_smart_plug_04bb_island_light
      dehumidifier_4:
        friendly_name: "Dehumidifier 4"
        value_template: "{{ is_state('switch.tp_link_smart_plug_04bb_island_light', 'on') }}"
        turn_on:
          action: switch.turn_on
          target:
            entity_id: switch.tp_link_smart_plug_04bb_island_light
        turn_off:
          action: switch.turn_off
          target:
            entity_id: switch.tp_link_smart_plug_04bb_island_light

Switch needs to be indented 2 spaces

house_dehumidifier:
  switch:
    - platform: template

ya had that but that gave me orginal error before the orginal post

Invalid config for 'homeassistant' at packages/house/dehumidifier.yaml, line 1: expected dict for dictionary value 'packages->house_dehumidifier', got None
house_dehumidifier:
switch:
  - platform: template
    switches:
      dehumidifier_3:
        friendly_name: "Dehumidifier 3"
        value_template: "{{ is_state('switch.tp_link_smart_plug_04bb_island_light', 'on') }}"
        turn_on:
          action: switch.turn_on
          target:
            entity_id: switch.tp_link_smart_plug_04bb_island_light
        turn_off:
          action: switch.turn_off
          target:
            entity_id: switch.tp_link_smart_plug_04bb_island_light
      dehumidifier_4:
        friendly_name: "Dehumidifier 4"
        value_template: "{{ is_state('switch.tp_link_smart_plug_04bb_island_light', 'on') }}"
        turn_on:
          action: switch.turn_on
          target:
            entity_id: switch.tp_link_smart_plug_04bb_island_light
        turn_off:
          action: switch.turn_off
          target:
            entity_id: switch.tp_link_smart_plug_04bb_island_light

You need to go over your spacing and formatting again. I entreated this in config.yaml

image

Created the folder structure

image

Used this yaml file, I switched the entity to one in my install

house_dehumidifier:
  switch:
    - platform: template
      switches:
        dehumidifier_3:
          friendly_name: "Dehumidifier 3"
          value_template: "{{ is_state('switch.kitchen_counter', 'on') }}"
          turn_on:
            action: switch.turn_on
            target:
              entity_id: switch.kitchen_counter
          turn_off:
            action: switch.turn_off
            target:
              entity_id: switch.kitchen_counter
        dehumidifier_4:
          friendly_name: "Dehumidifier 4"
          value_template: "{{ is_state('switch.kitchen_counter', 'on') }}"
          turn_on:
            action: switch.turn_on
            target:
              entity_id: switch.kitchen_counter
          turn_off:
            action: switch.turn_off
            target:
              entity_id: switch.kitchen_counter

and