Custom button to mqtt publish upon click

I just ceated a custom button to send an mqtt message upon click (see code below). However, When I click the button I get the following error: “Failed to call service mqtt/publish. must contain at least one of topic, topic_template”. Can’t figure it out…

show_name: true
show_icon: true
card_size: 1
type: custom:button-card
name: Feed Max
  action: call-service
  service: mqtt.publish
    topic: set/relay/feed
    payload: 20
    qos: 1
    retain: 0
icon: mdi:dog
show_state: false
    - height: 100px

1 Like

data not service-data

Docs: mqtt.publish

1 Like

Should be service_data
EDIT: Sorry, missed Didgery’s post.

1 Like

Thanks. It worked by using service_data, although I am confused since the docs posted by Didgerydrew specify the use of "data:’ instead.

Did you try data ?
Not sure, but i think in the UI both should work.

Tried data but didn’t work.

Got it. data and service_data work in core card actions.
custom:button card only with service_data. :upside_down_face: