Currently, I have 4 xiaomi mijia lywsd03mmc integrated using an esp32 running the development brach of openmqttgateway.
For each device, 5 sensors are created, but they are not tied together, they don’t create a device to tie them together and assign them to an area.
homeassistant/sensor/A4C138C9BC21-LYWSD03MMC-tempc/config
{
"stat_t":"home/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C138C9BC21",
"name":"LYWSD03MMC-tempc",
"uniq_id":"A4C138C9BC21-LYWSD03MMC-tempc",
"dev_cla":"temperature",
"val_tpl":"{{ value_json.tempc | is_defined }}",
"unit_of_meas":"C"
}
homeassistant/sensor/A4C138C9BC21-LYWSD03MMC-tempf/config
{
"stat_t": "home/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C138C9BC21",
"name": "LYWSD03MMC-tempf",
"uniq_id": "A4C138C9BC21-LYWSD03MMC-tempf",
"dev_cla": "temperature",
"val_tpl": "{{ value_json.tempf | is_defined }}",
"unit_of_meas": "F"
}
homeassistant/sensor/A4C138C9BC21-LYWSD03MMC-hum/config
{
"stat_t": "home/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C138C9BC21",
"name": "LYWSD03MMC-hum",
"uniq_id": "A4C138C9BC21-LYWSD03MMC-hum",
"dev_cla": "humidity",
"val_tpl": "{{ value_json.hum | is_defined }}",
"unit_of_meas": "%"
}
homeassistant/sensor/A4C138C9BC21-LYWSD03MMC-batt/config
{
"stat_t": "home/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C138C9BC21",
"name": "LYWSD03MMC-batt",
"uniq_id": "A4C138C9BC21-LYWSD03MMC-batt",
"dev_cla": "battery",
"val_tpl": "{{ value_json.batt | is_defined }}",
"unit_of_meas": "%"
}
homeassistant/sensor/A4C138C9BC21-LYWSD03MMC-volt
{
"stat_t": "home/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C138C9BC21",
"name": "LYWSD03MMC-volt",
"uniq_id": "A4C138C9BC21-LYWSD03MMC-volt",
"val_tpl": "{{ value_json.volt | is_defined }}",
"unit_of_meas": "V"
}
I tried to change, in ZmqttDiscovery.ino
# ifdef ZgatewayBT
void createDiscoveryFromList(char* mac, char* sensorList[][8], int sensorCount) {
for (int i = 0; i < sensorCount; i++) {
Log.trace(F("CreateDiscoverySensor %s" CR), sensorList[i][1]);
String discovery_topic = String(subjectBTtoMQTT) + "/" + String(mac);
String unique_id = String(mac) + "-" + sensorList[i][1];
createDiscovery(sensorList[i][0],
(char*)discovery_topic.c_str(), sensorList[i][1], (char*)unique_id.c_str(),
will_Topic, sensorList[i][3], sensorList[i][4],
sensorList[i][5], sensorList[i][6], sensorList[i][7],
0, "", "", false, "");
}
}
# endif
to
# ifdef ZgatewayBT
void createDiscoveryFromList(char* mac, char* sensorList[][8], int sensorCount) {
for (int i = 0; i < sensorCount; i++) {
Log.trace(F("CreateDiscoverySensor %s" CR), sensorList[i][1]);
String discovery_topic = String(subjectBTtoMQTT) + "/" + String(mac);
String unique_id = String(mac) + "-" + sensorList[i][1];
createDiscovery(sensorList[i][0],
(char*)discovery_topic.c_str(), sensorList[i][1], (char*)unique_id.c_str(),
will_Topic, sensorList[i][3], sensorList[i][4],
sensorList[i][5], sensorList[i][6], sensorList[i][7],
0, "", "", true, "");
}
}
# endif
But this has not the desired effect, I end up with something like
homeassistant/sensor/A4C138C9BC21-LYWSD03MMC-tempc/config
{
"stat_t":"home/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C138C9BC21",
"name":"LYWSD03MMC-tempc",
"uniq_id":"A4C138C9BC21-LYWSD03MMC-tempc",
"dev_cla":"temperature",
"val_tpl":"{{ value_json.tempc | is_defined }}",
"unit_of_meas":"C"
"device": {
"name": "OpenMQTTGateway_ESP32_BLE",
"manufacturer": "OMG_community",
"sw_version": "version_tag",
"identifiers": [
"4C11AE74F584"
]
}
}
What I want to achieve, is to end up with something like this :
homeassistant/sensor/A4C138C9BC21-LYWSD03MMC-tempc/config
{
"stat_t":"home/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C138C9BC21",
"name":"LYWSD03MMC-tempc",
"uniq_id":"A4C138C9BC21-LYWSD03MMC-tempc",
"dev_cla":"temperature",
"val_tpl":"{{ value_json.tempc | is_defined }}",
"unit_of_meas":"C"
"device": {
"name": "LYWSD03MMC",
"manufacturer": "OMG_community",
"identifiers": [
"A4C138C9BC21"
]
}
}
and same device block for all 5 sensors for the same LYWSD03MMC
So I end up with something like this in HA