From 04ab04ccfc1d471477659d205ba409453efb3edb Mon Sep 17 00:00:00 2001 From: XJ <38142124+xjikka@users.noreply.github.com> Date: Wed, 26 Mar 2025 22:15:18 +0100 Subject: [PATCH] HASS - Sensor name 'Battery' also for BATTERY_CHANNEL_SENSOR (#1583) * Sensor name 'Battery' also for BATTERY_CHANNEL_SENSOR * . * changed unique_id to battery_ch to avoid collision * spaces * updated comment --- src/httpserver/hass.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/httpserver/hass.c b/src/httpserver/hass.c index 56ce65103..82ce40201 100644 --- a/src/httpserver/hass.c +++ b/src/httpserver/hass.c @@ -89,6 +89,11 @@ void hass_populate_unique_id(ENTITY_TYPE type, int index, char* uniq_id, int ase case BATTERY_SENSOR: sprintf(uniq_id, "%s_%s_%d", longDeviceName, "battery", index); break; + case BATTERY_CHANNEL_SENSOR: + //20250326 XJIKKA previously there was default "sensor" - the probability of a collision was high + //I used battery_ch (because battery could also collide on channel 0 with BATTERY_SENSOR, where channel 0 is hardcoded) + sprintf(uniq_id, "%s_%s_%d", longDeviceName, "battery_ch", index); + break; case VOLTAGE_SENSOR: case BATTERY_VOLTAGE_SENSOR: sprintf(uniq_id, "%s_%s_%d", longDeviceName, "voltage", index); @@ -168,6 +173,7 @@ void hass_populate_device_config_channel(ENTITY_TYPE type, char* uniq_id, HassDe case ENERGY_SENSOR: case TIMESTAMP_SENSOR: case BATTERY_SENSOR: + case BATTERY_CHANNEL_SENSOR: case BATTERY_VOLTAGE_SENSOR: case TEMPERATURE_SENSOR: case HUMIDITY_SENSOR: @@ -284,6 +290,7 @@ HassDeviceInfo* hass_init_device_info(ENTITY_TYPE type, int index, const char* p sprintf(g_hassBuffer, "Tvoc"); break; case BATTERY_SENSOR: + case BATTERY_CHANNEL_SENSOR: isSensor = true; sprintf(g_hassBuffer, "Battery"); break;