Script editor and split up files

I can confirm that this works. It is not pretty, but it does the job :hugs:

Issue opened again. 2018ā€™s issue went stale and got closed.

I commented on Github however why donā€™t you use packages to accomplish this? I have a scripts package for example however I could have multiple packages containing scripts.

1 Like

I will try this out

this solved it for me.

Yes, but this was not the isue.
We would like to have both manual scripts in a folder structure AND the script.yaml which is needed in the root of config to be able to use the UI editor.

To get multiple script files form a folder is no issue as you can see earlier in the thread. It is coexistence with UI edito.

Great, thx.
This worked wonder until they fixed the issue.

1 Like

I wondered why I hadnā€™t split out my scripts until now and then I remembered, after spending a few hours scratching my head, as to why. Looks like itā€™s one of those things that involves a lot of work for the actual size of the problem.

In the short term, the docs need updating as they donā€™t reference the adding of multiple directories with automation xxxxx: Not sure of the proper terminology for this or Iā€™d do it myself?
Also it would be helpful to remind which components must be used with !include_dir_merge_list (automations only?) and which must be used with !include_dir_merge_named

Here is how I combined

script: # for UI editable scripts which are left in the original /config/scripts.yaml file
# with
script manual: # for manually created (and non UI editable) scripts which I separately placed in /config/scripts folder

First, edit your /config/configuration.yaml file:

script: !include_dir_merge_named /scripts

Then, create a /config/scripts folder which will include
- all your manually created scripts
- and a ui_scripts.yaml file which will refer to the UI generated scripts

  manual_script_1.yaml
  manual_script_2.yaml
  manual_script_3.yaml
  ui_scripts.yaml

Finally, edit this last ui_scripts.yaml with :

!include ../scripts.yaml

After that, manually created and UI generated scripts will co-exist but UI edition will only work for UI generated scripts of course.

11 Likes

@neilimixamo Thank you!!! I was super frustrated by this and you solved it perfectly. I can still edit scripts in the UI, and the scripts I auto-generate and drop in the scripts folder are available for use (and since they are generated I have no reason to edit them in the UI). Itā€™s perfect!

1 Like

youā€™re welcome :wink: :+1:

1 Like

Love it! Thanks @neilimixamo

1 Like

Thank you very much @neilimixamo

Is perfect

For anybody seeing no scripts after Script editor and split up files - #29 by neilimixamo -

You need to now add relative directory (the . before /scripts)

# Full line
script: !include_dir_merge_named ./scripts

Works perfectā€¦

and in configuration.yaml do this:

script: !include_dir_merge_named /config/#path_to_your_sub-folder

Then put your split folders here for scripts. Add your other scripts in other xxx.yaml files into this folder and they will be used in the config as well.

This links a file placeholder in your sub-folder to contain the actual scripts.yaml data for the config process to use, and it allows the Home Assistant UI editor to parse, destroy, and re-create the /config/scripts.yaml file anytime it needs to for editing.

I didnā€™t care about the scripts UI editor until I started doing blueprints and needed the script UI editor to actually work.

Following the suggestions for setting automations in the official doc, I tried the same also for scripts. And it works!

# Scripts created and edited in the UI
script ui: !include scripts.yaml
# Scripts created and edited manually
script manual: !include_dir_merge_named scripts/
1 Like

Is it possible to make:

script manual: !include_dir_merge_named scripts/

editable? By moving all scripts from scripts.yaml files to separate files there?