Setup more than one switch (MQTT)

I was able to configure one switch to work via MQTT:

switch:

  • platform: mqtt

    name: “Flur”

    command_topic: “cmnd/sonoff-22/POWER”

    state_topic: “stat/sonoff-22/POWER”

    qos: 1

    optimistic: false

    payload_on: “ON”

    payload_off: “OFF”

    retain: true

But I need 7 of these, so I need to understand the syntax to add more devices.

image

This doesn’t work :frowning:

Thanks for your help

Multi

The problem is described in the screenshot “Bad indentation” (and the correct domain name is switch not switches).

Even if you fix it, you will face another problem because you are using the old, deprecated format for defining MQTT switches. Refer to the examples in the documentation to see the new format.

Example

mqtt:
  switch:
    - unique_id: bedroom_switch
      name: "Bedroom Switch"
      state_topic: "home/bedroom/switch1"
      command_topic: "home/bedroom/switch1/set"
      availability:
        - topic: "home/bedroom/switch1/available"
      payload_on: "ON"
      payload_off: "OFF"
      state_on: "ON"
      state_off: "OFF"
      optimistic: false
      qos: 0
      retain: true
1 Like

That change made it for me, now I can add via unique_id more switches.
Thanks,
Multi