Two location with own MQTT broker

Two remote locations connected via OpenVPN. Mine - I use HA - and the other one of my friend who is a Domoticz enthusiast.
Both locations use Mosquitto as their MQTT broker.
Of course, the best way to connect these locations would be to use MQTT Bridge.
However, my friend (using Domoticz) does not want this and sends me data from selected sensors using the script mechanism in Domoticz.
This works fine.
Now I would like to send it data from some of my sensors and run the push-on virtual button in Domoticz.
From the CLI from the terminal this works fine using the command:

mosquitto_pub -h remote_domoticz -t "domoticz/in" -m '{"command": "switchlight", "idx": 17, "switchcmd": "On" }'

However, when I try to write the script, something is wrong with the definition of “broker”. The script looks like this:

furtka_1:
  alias: Otwarcie furtki
  sequence:
  - service: mqtt.publish
    metadata: {}
    broker:
      host: remote_domoticz
      port: 1883
      username: xxxx
      password: yyyy
    data:
      qos: 0
      retain: false
      topic: domoticz/in
      payload: '{"command": "switchlight", "idx": 17, "switchcmd": "On" }'
  mode: single

So where am I going wrong?
And if it is impossible to define a separate broker, can I somehow send a command from an HA script using the previously presented command in bash?
Any other possibilities?

You could use a command line binary sensor (I meant switch here): Command Line - Home Assistant

You would just ignore the state of the sensor (or use it as a validator in your script).

But is it possible in HA script?

According to the documentation, no. MQTT - Home Assistant

But, you could use a command line switch using just a command_on command. Then in your script, turn the switch on to send your data then flip it off again (like a momentary button of sorts).

1 Like