Run automation with button to click

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.

Hi @wakeskate, you can use a script for this.
If you have it in a group and customize it with:

    script.vdr_ambilight_off:
      friendly_name: "VDR & Ambilight OFF"
      can_cancel: false

it looks like:
grafik

2 Likes

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.

Thanks…

in your configuration, just put somewhere

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!'
2 Likes

Not sure what I am missing.

This is what I put in the configuration.yaml file

Script:
  test_script:
    sequence:
      - service: light.turn_off
        entity_id: light.sengled_e11g13_0306678e_1
      - service: light.turn_on
        entity_id: light.cree_connected_a19_60w_equivalent_fe06c273_10
        data:
          brightness_pct: 25
      - service: light.turn_off
        entity_id: light.sengled_e11g13_03092691_1

in groups.yaml

lights_out:
  name: "Lights Out"
    - script.test.script

But nothing shows up in the front end as a card

I got it.
typo

Thanks for the help

Yep. I assume it was just

  • script.test_script

You can check any of the message as the solution, so that people will find it directly if they come across this topic :wink: