Custom Button reference for automation

Hi all,

Thought this would be straight forward ( probably is and I’m missing something ).
Simply want the selected custom button to run an automation.

Screen grab of error attached.

Code snippet is simply:

type: custom:button-card
tap_action:
action: call-service
service: automation.trigger
service_data: entity_id:automation.watering

Any help much appreciated!

Please format your code properly! We can’t see, if there are errors in there… :wink:

See here:

This seems to be your problem with service_data, it should be a dictionary.

Like so:

type: custom:button-card
tap_action:
  action: call-service
  service: automation.trigger
  service_data: # or just 'data'
    entity_id: automation.watering

Btw. that’s the difference between formatting and non-formatting, one can see the indentations and new lines, and these are really important in YAML: :slight_smile:

Apologies . My original code it formatted correctly . The error / problem is the reference to the automation . Googling example ‘suggest’ it’s correct - but clearly not …

The error clearly states what’s wrong: you’re not using a dictionary for your service_data. That’s why I changed your code. Have you tried the code I provided?

Please post the code you’re actually using, properly formatted as per the link I provided. :slight_smile: Because what you provided is wrong. Not only not-formatted for the forum to read, but as well in your code. That’s what’s the error is telling you. :slight_smile:

Or try the code exactly as I provided it (meaning with correct indentations and new lines)!

I did originally enter the text as you described. Once saved and reloaded it would revert back to being formatted incorrectly!!!
Couldn’t see what the issue was. Rebooted HA and tried again. Now the correctly formatted code stays formatted and of course works. Thank you!.