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?