Control an other pin's raspberry with home assistant (MQTT)

Hi everyone,

I’m a new home assistant user, I’ve a little trouble in a gpio’s raspberry configuration.

So, I’ve a home assistant on a Raspberry pi 3B (hassos_rpi3 on it) and I want to control a relay (the relay control a lamp) wired on a second raspberry pin (Raspberry pi zero w). I want do this with MQTT.

I install mosquitto broker with the home assistant add-on on the RPI 3.

In the configuration.yaml :

#MQTT lampe
# Example configuration.yaml entry
  - platform: mqtt
    name: "Brightness light"
    state_topic: "office/light/status"
    command_topic: "office/light/switch"
    payload_off: "OFF"
    brightness_state_topic: 'office/light/brightness'
    brightness_command_topic: 'office/light/brightness/set'
    on_command_type: 'brightness'

Source :

On the RPI 0, I install pi-mqtt-gpio github (

In a configuration.yml file, I write :

 host: my_ip_broker
 port: 1883
 user: "user"
 password: "password"
 topic_prefix: office/light

 - name: raspberrypi
  module: raspberrypi

- name: lights
 module: raspberrypi
 pin: 4
 on_payload: "ON"
 off_payload: "OFF"
 initial: low
 retain: yes

When I run this program, there are :

mqtt_gpio (INFO): Startup
mqtt_gpio (INFO): Connected to the MQTT broker with protocol v3.1.1.
mqtt_gpio (INFO): Subscribed to topic: 'office/light/output/lights/set'
mqtt_gpio (INFO): Subscribed to topic: 'office/light/output/lights/set_on_ms'
mqtt_gpio (INFO): Subscribed to topic: 'office/light/output/lights/set_off_ms'

On The RPI3 in SSH the lamp is ON with :

mosquitto_pub -h ip_broker -d -u user -P password -t home/light/output/lights/set_off_ms -m 1

Why in the off topic ?

And when I want integrate a MQTT light on Home assistant it isn’t work.

So if anyone knows the answer and how fix this ?

Thanks for reading.