MQTT Discovery Error

I’m trying to use MQTT discovery to set up a device with 6 entities. I had this working in 2022, but when I finally got around to physically installing the device, HomeAssistant wasn’t receiving data from it even though the data was visible using MQTT Explorer.

Poking around, I found this error in my logs:


2024-07-28 17:39:57.675 ERROR (MainThread) [homeassistant.components.mqtt.mixins] Error 'value should be a string for dictionary value @ data['device']['name']' when processing MQTT discovery message topic: 'homeassistant/sensor/omronT/config', message: '{'device': {'identifiers': ['ff1'], 'name': ['furn']}, 'force_update': True, 'unit_of_measurement': '°F', 'state_topic': 'furn/state', 'value_template': '{{ value_json.temperatureO }}', 'unique_id': 'furn/omronT', 'name': 'Temperature', 'device_class': 'temperature', 'platform': 'mqtt'}'
2024-07-28 17:39:57.684 ERROR (MainThread) [homeassistant.components.mqtt.mixins] Error 'value should be a string for dictionary value @ data['device']['name']' when processing MQTT discovery message topic: 'homeassistant/sensor/omronP/config', message: '{'device': {'identifiers': ['ff1'], 'name': ['furn']}, 'force_update': True, 'unit_of_measurement': 'Pa', 'state_topic': 'furn/state', 'value_template': '{{ value_json.pressure }}', 'unique_id': 'furn/omronP', 'name': 'Pressure', 'device_class': 'pressure', 'platform': 'mqtt'}'
2024-07-28 17:39:57.694 ERROR (MainThread) [homeassistant.components.mqtt.mixins] Error 'value should be a string for dictionary value @ data['device']['name']' when processing MQTT discovery message topic: 'homeassistant/sensor/dhtT/config', message: '{'device': {'identifiers': ['ff1'], 'name': ['furn']}, 'force_update': True, 'unit_of_measurement': '°F', 'state_topic': 'furn/state', 'value_template': '{{ value_json.temperatureD }}', 'unique_id': 'furn/dhtT', 'name': 'Temperature', 'device_class': 'temperature', 'platform': 'mqtt'}'
2024-07-28 17:39:57.707 ERROR (MainThread) [homeassistant.components.mqtt.mixins] Error 'value should be a string for dictionary value @ data['device']['name']' when processing MQTT discovery message topic: 'homeassistant/sensor/dhtH/config', message: '{'device': {'identifiers': ['ff1'], 'name': ['furn']}, 'force_update': True, 'unit_of_measurement': '%', 'state_topic': 'furn/state', 'value_template': '{{ value_json.humidity }}', 'unique_id': 'furn/dhtH', 'name': 'Humidity', 'device_class': 'humidity', 'platform': 'mqtt'}'
2024-07-28 17:39:57.719 ERROR (MainThread) [homeassistant.components.mqtt.mixins] Error 'value should be a string for dictionary value @ data['device']['name']' when processing MQTT discovery message topic: 'homeassistant/sensor/dhtI/config', message: '{'device': {'identifiers': ['ff1'], 'name': ['furn']}, 'force_update': True, 'unit_of_measurement': '°F', 'state_topic': 'furn/state', 'value_template': '{{ value_json.heatindex }}', 'unique_id': 'furn/dhtI', 'name': 'Heat Index', 'device_class': 'temperature', 'platform': 'mqtt'}'
2024-07-28 17:39:57.731 ERROR (MainThread) [homeassistant.components.mqtt.mixins] Error 'value should be a string for dictionary value @ data['device']['name']' when processing MQTT discovery message topic: 'homeassistant/sensor/airWF/config', message: '{'device': {'identifiers': ['ff1'], 'name': ['furn']}, 'force_update': True, 'unit_of_measurement': 'dBm', 'state_topic': 'furn/state', 'value_template': '{{ value_json.wifi }}', 'unique_id': 'furn/airWF', 'name': 'Wifi Strength', 'device_class': 'signal_strength', 'platform': 'mqtt'}'

For reference, here is the retained message for one of the sensors, homeassistant/sensor/omronP/config:

{
  "name": "Pressure",
  "stat_t": "furn/state",
  "unit_of_meas": "Pa",
  "dev_cla": "pressure",
  "frc_upd": true,
  "val_tpl": "{{ value_json.pressure }}",
  "uniq_id": "furn/omronP",
  "dev": {
    "ids": [
      "ff1"
    ],
    "name": [
      "furn"
    ]
  }
}

And my setup in MQTT Explorer

What’s gone wrong? Has something changed since I created this in 2022?

I’m expecting a device with 6 sensors entities attached.

Hello tofof,
1 trick I found ia looking at the text that you have highlighted in MQTT Explorer. If it is mono-colored, it means that is is not valid JSON. If it is multicolored, it is valid JSON. Something to watch.

Then, the error says something should be a string, so find something that is being fed in as not a number.

The device name (not the entity name) needs to be a string, not a list. You’ve provided a list: ['furn']. The identifiers do have to be a list however, and you correctly have them specified as such. So don’t change the ids when you fix the name.

1 Like