From 1308a8f5b5ad226e4e155cbc0838c4e7733dcc81 Mon Sep 17 00:00:00 2001 From: Tester23 Date: Wed, 25 Oct 2023 16:01:18 +0200 Subject: [PATCH] fix potential RSSI name collision --- src/httpserver/hass.c | 6 ++++++ src/httpserver/hass.h | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/httpserver/hass.c b/src/httpserver/hass.c index cd8c00947..8884f66ab 100644 --- a/src/httpserver/hass.c +++ b/src/httpserver/hass.c @@ -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; } diff --git a/src/httpserver/hass.h b/src/httpserver/hass.h index 788fe1dfa..3986d8e87 100644 --- a/src/httpserver/hass.h +++ b/src/httpserver/hass.h @@ -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.