MQTT device with multiple entities

Hi
I have some data from node red, that goes into my MQTT, that goes into the topic Test:

{
  "temp1": "17.3",
  "pct": "0",
  "temp2": "10",
  "kW": "3",
  "Lx": "0",
  "Status": "running",
  "kg": "0.002",
  "Alarm": "0"
}

Now how do I get all this into a single device, with multiple entities, when there are multiple classes of the same (e.g. temperature)?

I tried to send it to the MQTT discover topic (HA) like this:

HA/sensor/Test/temperature/config
{"unit_of_measurement":"°C","device_class":"temperature","value_template":"{{ value_json.temp1 }}","state_topic":"Test","name":"temp1","unique_id":"Test_temp1","device":{"identifiers":["Test"],"name":"Test","model":"temp","manufacturer":"temp"}}

But how do i add temp2? and can this be added without MQTT discover or perhaps directly with the node red integration?

thanks

1 Like

Just send new discovery messages for each sensor, but keep the device block the same.

Yes that what I thought so too, but what do I miss? I only get the last entity added to the device.
I send those two to the topic; HA/sensor/Test/temperature/config:

{"unit_of_measurement":"°C","device_class":"temperature","value_template":"{{ value_json.temp1 }}","state_topic":"Test","name":"temp1","unique_id":"Test_temp1","device":{"identifiers":["Test"],"name":"Test","model":"temp","manufacturer":"temp"}}
{"unit_of_measurement":"°C","device_class":"temperature","value_template":"{{ value_json.temp2 }}","state_topic":"Test","name":"temp2","unique_id":"Test_temp2","device":{"identifiers":["Test"],"name":"Test","model":"temp","manufacturer":"temp"}}

But then on my device I only have one entity with the name temp2, but having entity_id= sensor.temp1 :thinking:

Each temperature sensor needs its own configuration topic.

HA/sensor/Test/temperature1/config
HA/sensor/Test/temperature2/config

Just changed my BLE openmqttgateway to ceate devices

Now I have (for one LYWSD03MMC)

homeassistant/sensor/A4C138C38EE5-LYWSD03MMC-batt/config

{"stat_t":"home/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C138C38EE5","name":"LYWSD03MMC-batt","uniq_id":"A4C138C38EE5-LYWSD03MMC-batt","dev_cla":"battery","val_tpl":"{{ value_json.batt | is_defined }}","unit_of_meas":"%","device":{"name":"A4C138C38EE5","model":"LYWSD03MMC","manufacturer":"OMG_community","identifiers":["A4C138C38EE5"]}}

homeassistant/sensor/A4C138C38EE5-LYWSD03MMC-volt/config

{"stat_t":"home/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C138C38EE5","name":"LYWSD03MMC-volt","uniq_id":"A4C138C38EE5-LYWSD03MMC-volt","val_tpl":"{{ value_json.volt | is_defined }}","unit_of_meas":"V","device":{"name":"A4C138C38EE5","model":"LYWSD03MMC","manufacturer":"OMG_community","identifiers":["A4C138C38EE5"]}}

homeassistant/sensor/A4C138C38EE5-LYWSD03MMC-tempc/config

{"stat_t":"home/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C138C38EE5","name":"LYWSD03MMC-tempc","uniq_id":"A4C138C38EE5-LYWSD03MMC-tempc","dev_cla":"temperature","val_tpl":"{{ value_json.tempc | is_defined }}","unit_of_meas":"°C","device":{"name":"A4C138C38EE5","model":"LYWSD03MMC","manufacturer":"OMG_community","identifiers":["A4C138C38EE5"]}}

homeassistant/sensor/A4C138C38EE5-LYWSD03MMC-tempf/config

{"stat_t":"home/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C138C38EE5","name":"LYWSD03MMC-tempf","uniq_id":"A4C138C38EE5-LYWSD03MMC-tempf","dev_cla":"temperature","val_tpl":"{{ value_json.tempf | is_defined }}","unit_of_meas":"F","device":{"name":"A4C138C38EE5","model":"LYWSD03MMC","manufacturer":"OMG_community","identifiers":["A4C138C38EE5"]}}

homeassistant/sensor/A4C138C38EE5-LYWSD03MMC-hum/config

{"stat_t":"home/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C138C38EE5","name":"LYWSD03MMC-hum","uniq_id":"A4C138C38EE5-LYWSD03MMC-hum","dev_cla":"humidity","val_tpl":"{{ value_json.hum | is_defined }}","unit_of_meas":"%","device":"name":"A4C138C38EE5","model":"LYWSD03MMC","manufacturer":"OMG_community","identifiers":["A4C138C38EE5"]}}

For this message :

{"id":"A4:C1:38:C3:8E:E5","name":"ATC_C38EE5","rssi":-73,"model":"LYWSD03MMC_ATC","tempc":24.3,"tempf":75.74,"hum":50,"batt":49,"volt":2.522}

Ahh that wasn’t clear. Thanks for fast replies to both of you. It is working now. now just some finetuning