Script editor and split up files

Guess it is a bug then. I opened an issue (see https://github.com/home-assistant/home-assistant/issues/15628). Please upvote if you’re also affected by this.

if its any help, I use script: !include_dir_merge_named scripts in configuration.yaml, and have all scripts loaded…

several folders in the /scripts folder, and they all have more scripts in them, formatted as follows:

opstart:
  alias: Opstart
  sequence:
    - service: script.scene_opstart

opstart_direct:
  alias: Opstart direct
  sequence:
    service: input_select.select_option
    data:
      entity_id: input_select.arrive_leave
      option: Opstart

so no leading -

also all scripts in packages load without issue.

2 Likes

Also ran into this problem. Using script: !include_dir_merge_named script works fine obviously, but having anymore than one occurrence of script just fails.

script extra: !include_dir_merge_named script
script: !include scripts.yaml

Reason I would like to do this is that I have a load of scripts that are already setup and in use in the directory, but it requires a restart of HA to get changes loaded. Where as when you have the default script.yaml in root, you can use the super easy reload script setting in the UI to quick check any changes you make, or setup new scripts, and when they are working all ok, you can move them to their own yaml in the directory.

This would be a very nice so we can use the editor in the ui and separate files in a sub dir.

Anyone got this to work now?
It seems to work fine for scenes but I still struggle with using both UI version and loading my old script files from script folder

Workaround by hard linking scripts.yaml into your custom scripts folder:

ssh username@your_hass.ip
cd config
ln scripts.yaml your-script-folder/scripts.yaml

(This makes a “hard link”, that is, the file scripts.yaml now appears two places: as config/scripts.yaml that will continue to be edited by the UI script editor, and as config/your-script-folder/scripts.yaml and thus loaded just like your other scripts.)

7 Likes

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