GPIO of a remote rpi in hA

Hello everyone,
my goal is to control the GPIO of a rpr zero by the Home assistant core which is on my NAS.
To achieve this, I thought using MQTT might be a good idea…
To do this, I made a .py file on the zero rpi so that the GPIOs communicate their status via mqtt (I have Mosquitto installed on my NAS in a container).

I installed the Mqtt integration, which works very well for my Sonoff under tasmota.

I modified the configuration.YAML

and created two entities, but they don’t recognize anything.
type: entities
entities:

  • entity: switch.gpio_17
    name: GPIO 17
  • entity: switch.gpio_18
    name: GPIO 18
    title: GPIO control

I’ll attach all the files if I can. But if anyone has an idea how to make this work, that would be great. I think I’ve already read dozens of pages trying to figure it out, with no success so far;