Legacy script and new script file from script editor. Can anyone tell me which is the format to have them both?

I just noticed that my script (legacy) do not get loaded.

Now I have a


scripts.yaml

which gets loaded

and a


script_legacy.yaml

which does not get loaded

my configuration is as follows


script: !include scripts.yaml            # nuove
script old: !include script_legacy.yaml  # vecchie

the above system works for automation but not for script

since I can’t find solution, I try to bring all my script to the new editor format.

What is the new format for these type of scripts?


  marantz_on_input_select:
    sequence:
      - service: media_player.select_source
        data_template:
          entity_id: media_player.marantz
          source: >
           {% if is_state("input_select.marantz_video_select", "Chromecast") %} Chromecast
           {% elif is_state("input_select.marantz_video_select", "Firestick") %} Firestick
           {% elif is_state("input_select.marantz_video_select", "Games") %} Games
           {% elif is_state("input_select.marantz_video_select", "Internet Radio") %} Internet Radio
           {% elif is_state("input_select.marantz_video_select", "TUNER") %} TUNER
           {% endif %}

I’m not sure why your config won’t load your old scripts.

I just tested it on my system and it worked fine.

I have my “old” scripts in a folder structure but I don’t think that should make any difference at all

## only used for the testing of the GUI editors
automation: !include automations.yaml
script: !include scripts.yaml

## All of my regular automations and scripts go here
automation old: !include_dir_merge_list automations/
script old: !include_dir_merge_named scripts/

I put a test script into scripts.yaml and it shows up in my states list.

well this I do not have, I do have my scripts and script_old in the same /config directory (as I have automations and automation old. But automation works

Your directory structure is as this?

# for the old file
/config/scripts/script_old.yaml

# for the new script editor
/config/script.yaml

the docs and examples are very confusing to me

my directory structure is:

for the UI editor scripts:

config/
|
->scripts.yaml

for the non-UI editor scripts (manually written ones):

config/
|
->scripts/
   |->script_file_one.yaml
   |->script_file_two.yaml

But you should be able to locate and call the “old” file names whatever you want as long as you reference them correctly in the !include statement.

But TBH, I never use the UI editor to write any scripts or automations. I just set it up to test it to help others with questions. Those files are usually empty unless I am testing things.

why different for script and for automation (merge list and merge name)?

Because automations are a list and scripts are named.

you can see the difference in how you enter them into the config by looking at the first character for a new entry. if the first character is a dash (-) then the entries are a list. If there is no dash then the entries are named.

automation:
  - alias: automation_1
    .
    .
  - alias: automation_2
    .
    .

script:
  script_1:
    .
    .
  script_2:
    .
    .

Don’t ask me why there is a difference in how they are entered. I’ve asked before and basically the answer was “that’s how the developer decided to do it”.

I am following your guide and still not working

this works


config/
|
->scripts.yaml

this is not loaded


config/
|
->scripts/
   |->script_file_one.yaml

this is the file script_file_one.yaml (wjhats the corrrect indentation??) it has 2 space indentation, and not written script:


##########################################  #SCRIPTS#

# script:


################## 2 spaces indentation
  flash_foyer_two:
    sequence:
      - service: light.turn_on
        data:
          entity_id: light.foyer_ball_lamp
          brightness: 254
          rgb_color: [255,96,0]

this in conffiguration


script: !include scripts.yaml            # nuove
script old: !include_dir_merge_named scripts/  # vecchie

this is the scripts.yaml (it works, and can be used inside the editor)

(no indentation)


guest_room_tv_on:
  alias: guest_room_tv_on
  sequence:
  - entity_id: switch.guest_room_tv_power_plug
    service: switch.turn_on
  - delay:
      milliseconds: 300
  - entity_id: media_player.yamaha_receiver
    service: media_player.turn_on
  - delay:
      milliseconds: 300
  - data:
      source: Shield
    entity_id: media_player.yamaha_receiver
    service: media_player.select_source
  - delay:
      milliseconds: 300
  - entity_id: switch.panasonic_tv
    service: switch.turn_on

try moving the code indentation back two spaces in the script file that’s not working. Make the first line up against the left margin and then move everything back to follow it’s lead.

I kind of remember having issues with that until I figured out the “secret”.

Hi, after the last update to 0.105.5 my scripts disappeared from my UI and the service scripts.turn_on seems disappered too.
Have someone the same issue? Con share your experience?

Thank you in advance

not sure I understand correctly, I have more then 50 script, so before trying, wish to understand well :smiley:


##########################################  #SCRIPTS#

# script:


################## change to 0 spaces indentation
flash_foyer_two:
  sequence:
    - service: light.turn_on
      data:
        entity_id: light.foyer_ball_lamp
        brightness: 254
        rgb_color: [255,96,0]

the other question I have is why are you doing all of this in the first place?

what is your end goal/need?

1 Like

I like the editor, is nice to make fast changes on the fly, and the future is for sure all in editor and no more yaml.
SO I wish to bring all script/automation there, but for some is still not possible, so I will keep both, until the editor can handle all type

Well…I made some assumptions that the automation editor and script editor work flow would be the same.

That assumption was completely incorrect! :roll_eyes:

Apparently the way the script editor works is different than the way the automation editor works when related to the old existing stuff in your config.

The docs for the automation editor says you can keep your old existing automations separately from your automations created by the editor by adding an “extender” name onto the existing “automation:” entry. the docs recommend adding “old” onto it like “automation old:”.

But that doesn’t work at all for the script entry for scripts added using the UI scripts editor.

I just tested adding a script in the UI editor and using the equivalent config for the one recommended for automations and it ended up killing all of my old scripts.

So, yeah, the bottom line is don’t do that.

What’s strange is that you can add the “script old:” entry and it will still reference all of the included files in the “script old:” and also in the “script:” locations just fine.

BUT as soon as you create a script in the UI editor that then gets added to your “scripts.yaml” file then none of the scripts located in the “script old:” location are recognized any more.

Reloading scripts or restarting HA won’t fix it either. The only way I could get my old scripts back was to remove the “script: !include scripts.yaml” entry and point it to my old scripts again using “script: !include_dir_merge_named scripts/” and after a restart everything was back to normal again.

I think I’m going to make this post it’s own thread so others know about this weird behavior.

Maybe it’s worth a bug report based on the feedback that the other thread gets.

Has been this problem solved? So, there is possibile use files with scripts and new script editor together?