2x Hassio setup communicating by MQTT

Hi Guys, i got a problem.
I have a problem. I have two Hassio systems:
One with a relay shield connected by GPIO
One as main controller.

I want to let them speak by MQTT but I can’t find any how to setup MQTT. The one with relay will only be used to control the relays. Both brokers are working but I need to know how to write the publish code. (How to speak) does anyone has a same configuration?
I can’t find anything about how to setup te state part of configuration…

Thanks guys!

I suggest you do not use hassio on this machine but install something like this to control the relays instead.

I have two instances of hassio talking over MQTT. You refer to “both brokers” - do you have two MQTT brokers? You only need one, to which both hassio instances pub/sub. I have a separate Mosquitto install that both talk to.

This is how I have my HA set up. Except I use Hassbian on both. One in the garage, to control switches and a motion sensor and my main system inside. I MQTT the status from the garage and send signals to control switches from my system PI.
Mosquitto on both with all the same information in the configuration of both. Then I just send and subscribe to the topics I need.
If it is setting up MQTT you might start with just a single topic and set up a test sensor, I use a fake temperature sensor and send to it to see if it is working.
If it is the code on how to do this you need, then I can post samples of what I use when I get home.

Guys thans for the replys!!
I dont have a clue what to add in the configuration file and how to write the MQTT commands for the switches and buttons… I can’t find any info on that…
so I need to have mosquito installed only on the main Hassio? And the other one just MQTT in the configuration?

Can you share these parts so I can try them on mines?

Hassio 1 = main controller I want to add some input Boolean switches for switching
Hassio 2 connected by GPIO to relay shield

I switch on Hassio 1 this sends MQTT to Hassio 2 and this will switch the relay