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
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)
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”… , 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.