I am finding a bunch of esxamples for the other way around *ESPHome sensor triggers event withint HomeAssistant". But I need the inverse. If something happens within HomeAssistant I want run a script defined in my ESPHome device configuraton: I thought that exposing the script via the api: section would make the scripts available as an entity, something like esphome.<my_service_id> but that does not seem to work.
Here's my config:
substitutions:
name: <friendly-name>
script:
- id: error_tone_garage_rear
then:
- output.turn_on: buzzer_out
- delay: 60ms
- output.turn_off: buzzer_out
- delay: 50ms
- output.turn_on: buzzer_out
- delay: 60ms
- output.turn_off: buzzer_out
- delay: 50ms
- output.turn_on: buzzer_out
- delay: 60ms
- output.turn_off: buzzer_out
...
api:
encryption:
key: <key>
services:
- service: toggle_error
variables: {}
then:
- script.execute: error_tone_garage_rear
Then I looked for esphome.toggle_error or <friendly-name>.toggle_error or just toggle_error but cannot find anything.
I know I must be doing something wrong but I cannot find a good example of how to do this.
Thanks!