Executing an Automation manually from a card

Hi All,

Just a bit unsure of something. I have an automation that runs a sprinkler for 1 minute every morning. Automation works fine and obviously I can manually select execute to run it at any time I desire.

However, I would also like to put that automation into an entitys card with a button to allow the wife to click it when she thinks the sprinkler needs to run for upto a minute (or less by closing button).

I create the card and add the automation as the entity (maybe thats wrong) and when I click the button nothing happens. After some reading I believe that a script or more work is required but I wish to confirm that becuase to be honest I thought it would have been a lot easier (gui work).

I know that we could just click the main sprinkler entities card however Im trying to avoid leaving the sprinkler running hence why I wish to use the automations 1 minute timing.

Cheers.

When you click the button you dissable/enable the automation.

The service you are looking for is

  - service: automation.trigger
    entity_id: automation.whatever

Use a button card and the ‘on_tap’ action to call the service.

Note: this will ignore any conditions in the automation.

thanks @tom_l

Ive got this but getting an error:

type: entity-button
tap_action:
action: call-service
service: automation.trigger
hold_action:
action: more-info
show_icon: true
show_name: true
entity: automation.topup_fountain
icon_height: 35px

error is:
Failed to call service automation/trigger. must contain at least one of entity_id, area_id.

I changed entity: to entity_id: no change
I moved entity_id: line under service but no go.

and its not an indentation thing I just cut and pasted the above without formating sorry

Well format it then please, see How to help us help you - or How to ask a good question

You need to add the automation entity id in the service data.

@tom_l sorry for the delay in replying.
@nickrout apologise it will never happen again

type: entity-button
tap_action:
  action: call-service
  service: automation.trigger
  entity_id: 1583150465888
hold_action:
  action: more-info
show_icon: true
show_name: true
entity: automation.topup_fountain
icon_height: 25px

with the above I get:

Expected a value of type {action,navigation_path,url_path,service,service_data} | undefined for tap_action.entity_id but received 1583150465888.

If I remove the line entity_id: 1583150465888 I get no error but it fails with error written in previous post

1583150465888 is not the entity_id. The entity_id should be something like automation.xxxx. Go to Developer Tools -> States to find the entity_id of your automation.

And then it should be put in service_data:

See the example: https://www.home-assistant.io/lovelace/button/#examples

Hi @Burningstone

Under States the entity is automation.topup_fountain
id: ‘1583150465888’
friendly_name: Topup Fountain

In the code above both automation.topup_fountain (which is written as entity: ) and entity_id (1583150465888) both provide the same error.

I honestly do not know the differance between entity: and entity_id but was assuming one was the name given by myself and the other a machine dedicated number.

Funnily enough if I go to Services and put the service as automatin.trigger and the entity as automatin.notify_home and ‘call service’ it works like a charm. Its getting that to the gui that I dont get.

The first column in Developer Tools -> States is always the entity_id. The id you see, is an attribute of this entity and it is used by the system but you don’t need to care about this number.

So it should be something like this:

type: entity-button
tap_action:
  action: call-service
  service: automation.trigger
  service_data:
    entity_id: automation.topup_fountain
hold_action:
  action: more-info
show_icon: true
show_name: true
entity: automation.topup_fountain
icon_height: 25px

@Burningstone

Your sir are a legend. Thanks for providing that bit of code and more importantly the information to help me learn more.

Cheers

1 Like

Glad that it works :slight_smile: Please mark the post that contains the solution or that helped you find the solution as the solution for future readers.