From 6d64dbcd8c82e81de8362d02873a407e898865f0 Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 23 May 2026 15:33:26 -0500 Subject: [PATCH] [BT] Emit hex-valued BLE properties as text sensors (no state_class) (#2315) iBeacon uuid/mfid (and any decoder property with unit "hex") were built as HA sensors with state_class "measurement" and unit "hex". Home Assistant rejects a measurement sensor whose value is non-numeric, so it logged "non-numeric value" errors on every iBeacon decode. Route "hex" units through the same path as "string" units: plain text sensor, no state_class, no unit_of_measurement. Co-authored-by: Claude Opus 4.7 (1M context) --- main/gatewayBT.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main/gatewayBT.cpp b/main/gatewayBT.cpp index a1994ad..b147b68 100644 --- a/main/gatewayBT.cpp +++ b/main/gatewayBT.cpp @@ -1113,7 +1113,11 @@ void launchBTDiscovery(bool overrideDiscovery) { 0, "", "", false, "", model.c_str(), brand.c_str(), model_id.c_str(), macWOdots.c_str(), false, stateClassMeasurement, nullptr, nullptr, "[\"lb\",\"kg\",\"jin\"]"); - } else if (strcmp(prop.value()["unit"], "string") == 0 && strcmp(prop.key().c_str(), "mac") != 0) { + } else if ((strcmp(prop.value()["unit"], "string") == 0 || strcmp(prop.value()["unit"], "hex") == 0) && strcmp(prop.key().c_str(), "mac") != 0) { + // Non-numeric properties (e.g. iBeacon uuid/mfid/manufacturerdata + // carry unit "hex"). HA rejects a sensor that has state_class + // "measurement" but a non-numeric value, so emit these as plain + // text sensors: no state_class, no unit_of_measurement. createDiscovery(HASS_TYPE_SENSOR, discovery_topic.c_str(), entity_name.c_str(), unique_id.c_str(), will_Topic, prop.value()["name"], value_template.c_str(),