How to create a button that issue a mosquitto_pub command

Hi.
I’ve installed on my RPi5 a Mosquitto Broker and all works fine.
Anyway I’d need to associate a command like this to an Home Assistant button so that , every time it is pressed, issue the comand:

mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoBT -m '{
  "ble_write_address":"AA:BB:CC:DD:EE:FF",
  "ble_write_service":"cba20d00-224d-11e6-9fb8-0002a5d5c51b",
  "ble_write_char":"cba20002-224d-11e6-9fb8-0002a5d5c51b",
  "ble_write_value":"TEST",
  "value_type":"STRING",
  "ttl":4,
  "immediate":true }

Is it possible?
Thanks in advance

what doesn’t mqtt.publish do that you want?

example from the docs (MQTT - Home Assistant):

service: mqtt.publish
data:
  topic: homeassistant/sensor/Acurite-986-1R-51778/config
  payload: >-
    {"device_class": "temperature",
    "unit_of_measurement": "\u00b0C",
    "value_template": "{{ value|float }}",
    "state_topic": "rtl_433/rtl433/devices/Acurite-986/1R/51778/temperature_C",
    "unique_id": "Acurite-986-1R-51778-T",
    "device": {
    "identifiers": "Acurite-986-1R-51778",
    "name": "Bathroom",
    "model": "Acurite-986",
    "manufacturer": "rtl_433" }
    }
1 Like

Hi armedad.
Thanks for your reply.
I’ll try