Problem creating more than 1 mqtt swicth in homeassistant config file

Hi all, this is my firts post, im new to hass io but very exited on how it works. ive created several configurations into my yaml files including more than 30 cameras, envisalink devices, vera integration, locks and so on, im working on integrating 4 mqtt switches working with arduino un esp8266 mqtt and homeassistant, my problem is when i create those 4 mqtt switches into configuration yaml file and restarting homeassistant, it only creates one switch, i cant get the 4 switches to be created, hope someone can help me, this is how my config file loosks like

switch 1:

  • platform: rpi_gpio
    ports:
    2: RECAMARA
    3: LORENA
    4: BAÑO
    17: ESTACIONAMIENTO
    invert_logic: true

switch 2:

  • platform: mqtt
    mqtt_name: “ALBERCA”
    state_topic: “outTopic”
    command_topic: “inTopic”
    qos: 0
    payload_on: “1”
    payload_off: “2”
    optimistic:
    false retain: true

switch 3:

  • platform: mqtt
    mqtt_name: “RIEGO”
    state_topic: “outTopic”
    command_topic: “inTopic”
    qos: 0
    payload_on: “3”
    payload_off: “4”
    optimistic:
    false retain: true

switch 4:

  • platform: mqtt
    mqtt_name: “CASCADA”
    state_topic: “outTopic”
    command_topic: “inTopic”
    qos: 0
    payload_on: “5”
    payload_off: “6”
    optimistic:
    false retain: true

switch 5:

  • platform: mqtt
    mqtt_name: “LUCES”
    state_topic: “outTopic”
    command_topic: “inTopic”
    qos: 0
    payload_on: “7”
    payload_off: “8”
    optimistic:
    false retain: true

binary_sensor:

  • platform: rpi_gpio
    pull_mode: up
    invert_logic: false
    ports:
    27: PIR BAÑO

mqtt:
broker: core-mosquitto
username: !secret mosquitto_user
password: !secret mosquitto_password

I don’t see no “mqtt_name” attribute in the MQTT Switch configuration. There ist a “name” attribute that could be used to solve your issue.

thanks for replying, there is the mqtt_name in mqtt switch configuration for switch 2,3,4,5 not in switch 1 because th switch is rpi_gpio

Change the “mqtt_name” to “name” and you should use different state_topic for each switch for example outTopic/LUCES. Also the broker should be IP or address of your broker.

Thanks a lot, solved my issue with your advice, the problem was ussing mqtt_ name instead of name, changing ti solved everything, hope to help you soon, thanks again, nice community.