Trying to create a MQTT discovery configuration

I have sucessfully created my device / sensors but I cannot get the Ids / cns items to display on the device panel, name, model, manufacturer and software all show up as expected but nor cns or ids.
JSON is as below, can anybody hel please? Is the JSON correct?

{
  "stat_t": "ha/sensor/sn22/state",
  "expire_after": 600,
  "dev": {
    "name": "sn22",
    "mdl": "IOTBear-4",
    "mf": "GlebeTech",
    "sw": "192.168.1.204",
    "cns": [
      [
        "MAC",
        "18:FE:34:D6:C5:3D"
      ]
    ],
    "ids": [
      "test_ID"
    ]
  },
  "name": "sn22_ldr",
  "uniq_id": "sn22_ldr",
  "val_tpl": "{{value_json['ldr']}}",
  "unit_of_meas": "%",
  "device_class": "illuminance"
}

Nothing jumps out after a quick look; not sure why it is rejected.

FWIW, I checked examples within the core.device_registry file and it shows "mac" in lower case as opposed to upper case. I’d be surprised if it rejects upper case but it’s worth a try (it also shows the address is lower case but it’s hard to believe upper case would be rejected).

BTW, is it possible you have an existing sensor whose unique_id is sn22_ldr? Attempting to create a duplicate would result in an error message in the log regarding the inability to assign a unique_id.

Hi, Thank you for your reply. I have tried using lower case for the mac and ip address. No joy. I also tried changing the unique_id and the names, still no joy. The way I read ‘supported abbreviations’ for the device registry I would assume that anything correctly formatted would appear in the list for the device. In my case name, model, manufacturer and version all work and include mixed case. I haven’t tried ‘suggested_area’ because I don’t really need it.
Is there anything else I can try ??

I published your MQTT Discovery payload to homeassistant/sensor/test/config and it produced the following result (no connections displayed):

Screenshot from 2022-01-31 10-36-53

However, the connections information was received and is present in the (hidden) core.device_registry file:

Therefore, that information simply isn’t displayed in the UI.

However, if you click the MQTT Info button, it shows you what’s in the payload and that’s where you can see the connections information:

Thank you for your help is resolving this issue. I have marked it as solved on the basis that your explanation has resolved the issue I had and confirmed that there were not any errors in my code.

1 Like