MQTT and Multiple switch devices

I’m adding some switches using MQTT, they work fine but they are seen as 2 different entities of one device instead of 2 different devices:

image

this is my configuration:

mqtt:
  switch:
  - name: "switch_1 1"
    unique_id: "OpenBK_switch_1_relay_1"
    state_topic: "obk1F344341/1/get"
    command_topic: "obk1F344341/1/set"
    qos: 1
    payload_on: 1
    payload_off: 0
    retain: true
    availability:
      - topic: "obk1F344341/connected"

    
  
  - name: "switch_2 1"
    unique_id: "OpenBK_switch_2_relay_1"
    state_topic: "obk1F36274E/1/get"
    command_topic: "obk1F36274E/1/set"
    qos: 1
    payload_on: 1
    payload_off: 0
    retain: true
    availability:
      - topic: "obk1F36274E/connected"

Any idea?

What does this even mean?

What does this even mean?

Hi Nickrout,

A device can be made up by different entities that most of time are linked to different functionality. For istance, a switch would have an entity that rappresent the switching functionality (the turn on/off so that you understand), but also a power meter one.
In my case I have 2 different physical switches that should be seen as 2 different devices in HA but they are not, they are seen as one device (a switch) with 2 different entities.

Hope this clarify and that you will have a nice day now. :slight_smile:

OK so they are not showing as separate devices, got it thanks.

According to the docs, MQTT switches only work as devices if they are set up by discovery.

device map (optional)

Information about the device this switch is a part of to tie it into the device registry. Only works through MQTT discovery and when unique_id is set. At least one of identifiers or connections must be present to identify the device.

What are you connecting to over MQTT? It might work with discovery. MQTT - Home Assistant

I have flashed some devices using OpenBK7231T - it supports autodiscovery and seems to be set correctly. This is the config page where it also mentioned the keyword that it’s probably causing the issue…

Cool, but if discovery works, you don’t need to (and indeed shouldn’t) put anything into configuration.yaml.

I would

  1. comment out the stuff from configuration.yaml
  2. restart HA
  3. click “Start Home Assistant Discovery” in the UI you showed above.

The switches should then appear properly in HA.