fix potential RSSI name collision

This commit is contained in:
Tester23
2023-10-25 16:01:18 +02:00
parent 3e5cb27be7
commit 1308a8f5b5
2 changed files with 8 additions and 1 deletions

View File

@ -86,7 +86,13 @@ void hass_populate_unique_id(ENTITY_TYPE type, int index, char* uniq_id) {
case CURRENT_SENSOR:
sprintf(uniq_id, "%s_%s_%d", longDeviceName, "current", index);
break;
case HASS_RSSI:
sprintf(uniq_id, "%s_rssi", longDeviceName);
break;
default:
// TODO: USE type here as well?
// If type is not set, and we use "sensor" naming, we can easily make collision
//sprintf(uniq_id, "%s_%s_%d_%d", longDeviceName, "sensor", (int)type, index);
sprintf(uniq_id, "%s_%s_%d", longDeviceName, "sensor", index);
break;
}

View File

@ -63,10 +63,11 @@ typedef enum {
READONLYLOWMIDHIGH_SENSOR,
// lx unit
ILLUMINANCE_SENSOR,
// dBm unit
HASS_RSSI,
ENERGY_SENSOR,
HASS_RSSI,
} ENTITY_TYPE;
//unique_id is defined in hass_populate_unique_id and is based on CFG_GetDeviceName() whose size is CGF_DEVICE_NAME_SIZE.