From e5a566f0bb0704a5cafd0bb92042da52f791fb77 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 17 Mar 2021 17:51:12 +0100 Subject: [PATCH] Hide I2C address for single sensors Hide I2C address for single sensors (#11323) --- tasmota/xsns_14_sht3x.ino | 5 ++++- tasmota/xsns_63_aht1x.ino | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tasmota/xsns_14_sht3x.ino b/tasmota/xsns_14_sht3x.ino index 4e29742e5..0f791f78a 100644 --- a/tasmota/xsns_14_sht3x.ino +++ b/tasmota/xsns_14_sht3x.ino @@ -99,7 +99,10 @@ void Sht3xShow(bool json) float h; if (Sht3xRead(t, h, sht3x_sensors[i].address)) { char types[11]; - snprintf_P(types, sizeof(types), PSTR("%s%c0x%02X"), sht3x_sensors[i].types, IndexSeparator(), sht3x_sensors[i].address); // "SHT3X-0xXX" + strlcpy(types, sht3x_sensors[i].types, sizeof(types)); + if (sht3x_count > 1) { + snprintf_P(types, sizeof(types), PSTR("%s%c%02X"), sht3x_sensors[i].types, IndexSeparator(), sht3x_sensors[i].address); // "SHT3X-0xXX" + } TempHumDewShow(json, ((0 == TasmotaGlobal.tele_period) && (0 == i)), types, t, h); } } diff --git a/tasmota/xsns_63_aht1x.ino b/tasmota/xsns_63_aht1x.ino index 88da71890..bb47873eb 100644 --- a/tasmota/xsns_63_aht1x.ino +++ b/tasmota/xsns_63_aht1x.ino @@ -175,7 +175,10 @@ void AHT1XShow(bool json) { float tem = ConvertTemp(aht1x_sensors[i].temperature); float hum = ConvertHumidity(aht1x_sensors[i].humidity); char types[11]; // AHT1X-0x38 - snprintf_P(types, sizeof(types), PSTR("%s%c0x%02X"), aht1x_sensors[i].types, IndexSeparator(), aht1x_sensors[i].address); // "X-0xXX" + strlcpy(types, aht1x_sensors[i].types, sizeof(types)); + if (aht1x.count > 1) { + snprintf_P(types, sizeof(types), PSTR("%s%c%02X"), aht1x_sensors[i].types, IndexSeparator(), aht1x_sensors[i].address); // "X-0xXX" + } TempHumDewShow(json, ((0 == TasmotaGlobal.tele_period) && (0 == i)), types, tem, hum); } }