Script question, no "entity_id"?

I have two scripts to enable/disable my ESP OTA mode. Basically I publish a retained message telling my espHome device to ignore deep sleep. And another to clear the retained message. The scripts work fine- I can perform OTA on my espHome devices.

But, that isn’t my question.

I would like to create switches on my Lovelace UI to run the scripts.
Here is my script to turn off the OTA mode:

alias: ESP OTA mode off
sequence:
  - data:
      payload: 'OFF'
      retain: false
      topic: esp/ota_mode
    service: mqtt.publish
  - data:
      payload: ''
      retain: true
      topic: esp/ota_mode
    service: mqtt.publish
mode: single

But it presents in developer tools/states as:

 script.1621011309750
 ...
 friendly_name: ESP_OTA_mode_off

So, how do I get an entity ID that makes a bit more sense. Like “script.ESP_OTA_mode_off”?

What is my script missing?

Normally, for, e.g.,

script:
  all_off:
    alias: Switch everything off
    sequence:
[...]

The script will be named script.all_off

Thanks, I appreciate the tip. This makes sense, but when I tried inserting a script name I am getting a “Message malformed” error:
Message malformed: extra keys not allowed @ data['esp_ota_mode_off']
(I am really still struggling with YAML)

Here’s my latest attempt.:

esp_ota_mode_off:
  alias: ESP_OTA_mode_off
  sequence:
    - data:
        payload: 'OFF'
        retain: false
        topic: esp/ota_mode
      service: mqtt.publish
    - data:
        payload: ''
        retain: true
        topic: esp/ota_mode
      service: mqtt.publish
  mode: single

Where do you put that code?
If it’s directly in configuration.yaml, you have to declare what class you’re defining, hence the script: above

I start by using the script editor in the front-end, New script then edit in YAML.

The script editor then puts my code into scripts.yaml, which is included in my configuration.yaml.

I can change the script name in scripts.yaml and I get the entity:
script.esp_ota_mode_off
Which is what I want.

When I add the exact same script name in the script editor, I get the malformed YAML error. (Maybe I should change my screen name to “MalfoYaml”… :laughing:, but I understand that I can’t edit scripts.yaml directly because the next time I use the scripts editor, scripts.yaml gets completely rewritten.