I just want to have a button that I have on the frontend that if
I click on runs a automation.
I tried to create just a automation with no trigger so it ran when turned off or on
but that does not work because it gives a error that a trigger is required.
That is what I am looking for but new to scripts.
Can you give me a complete example of where to create the script,
is it in the configuration file, or automation?
Also how I get the last part to show up in the frontend.
script:
example_script:
sequence:
# This is written using the Script Syntax
- service: light.turn_on
entity_id: light.ceiling
- service: notify.notify
data:
message: 'Turned on the ceiling light!'
and in the group section just add the script in a card (just like you would add light.yourlight or sensor.yourSensor)
- script.example_script
For a cleaner code you can also split your config using include. So the config would show only
script: !include scripts.yaml
then you create a scripts.yaml file at the root directory and put directly
example_script:
sequence:
# This is written using the Script Syntax
- service: light.turn_on
entity_id: light.ceiling
- service: notify.notify
data:
message: 'Turned on the ceiling light!'