diff --git a/tasmota/tasmota_xsns_sensor/xsns_12_ads1115.ino b/tasmota/tasmota_xsns_sensor/xsns_12_ads1115.ino index baa8d23a3..431814ac5 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_12_ads1115.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_12_ads1115.ino @@ -200,15 +200,10 @@ void Ads1115Label(char* label, uint32_t maxsize, uint32_t device) { // "ADS1115-48":{"A0":3240,"A1":3235,"A2":3269,"A3":3269},"ADS1115-49":{"A0":3240,"A1":3235,"A2":3269,"A3":3269} snprintf_P(label, maxsize, PSTR("%s%c%02X"), label, IndexSeparator(), Ads1115[device].address); #ifdef USE_I2C_BUS2 - if (TasmotaGlobal.i2c_enabled[1]) { // Second bus enabled - uint8_t bus = Ads1115[0].bus; - for (uint32_t i = 1; i < ads1115_count; i++) { - if (bus != Ads1115[i].bus) { // Different busses - // "ADS1115-48-1":{"A0":3240,"A1":3235,"A2":3269,"A3":3269},"ADS1115-48-2":{"A0":3240,"A1":3235,"A2":3269,"A3":3269} - snprintf_P(label, maxsize, PSTR("%s%c%d"), label, IndexSeparator(), Ads1115[device].bus +1); - break; - } - } + if (TasmotaGlobal.i2c_enabled[1] && // Second bus enabled + (Ads1115[0].bus != Ads1115[ads1115_count -1].bus)) { // Different busses + // "ADS1115-48-1":{"A0":3240,"A1":3235,"A2":3269,"A3":3269},"ADS1115-48-2":{"A0":3240,"A1":3235,"A2":3269,"A3":3269} + snprintf_P(label, maxsize, PSTR("%s%c%d"), label, IndexSeparator(), Ads1115[device].bus +1); } #endif // USE_I2C_BUS2 } diff --git a/tasmota/tasmota_xsns_sensor/xsns_14_sht3x.ino b/tasmota/tasmota_xsns_sensor/xsns_14_sht3x.ino index b447fb541..a6e6aede0 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_14_sht3x.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_14_sht3x.ino @@ -185,20 +185,15 @@ void Sht3xUpdate(void) { void Sht3xShow(bool json) { char types[11]; - + bool dual_bus_use = (sht3x_sensors[0].bus != sht3x_sensors[sht3x_count -1].bus); for (uint32_t idx = 0; idx < sht3x_count; idx++) { if (sht3x_sensors[idx].valid) { strlcpy(types, sht3x_sensors[idx].types, sizeof(types)); if (sht3x_count > 1) { - snprintf_P(types, sizeof(types), PSTR("%s%c%02X"), types, IndexSeparator(), sht3x_sensors[idx].address); // "SHT3X-0xXX" + snprintf_P(types, sizeof(types), PSTR("%s%c%02X"), types, IndexSeparator(), sht3x_sensors[idx].address); // "SHT3X-XX" #ifdef USE_I2C_BUS2 - if (TasmotaGlobal.i2c_enabled[1]) { - for (uint32_t i = 1; i < sht3x_count; i++) { - if (sht3x_sensors[0].bus != sht3x_sensors[i].bus) { - snprintf_P(types, sizeof(types), PSTR("%s%c%d"), types, IndexSeparator(), sht3x_sensors[idx].bus + 1); // "SHT3X-0xXX-X" - break; - } - } + if (TasmotaGlobal.i2c_enabled[1] && dual_bus_use) { // Different busses + snprintf_P(types, sizeof(types), PSTR("%s%c%d"), types, IndexSeparator(), sht3x_sensors[idx].bus + 1); // "SHT3X-XX-X" } #endif // USE_I2C_BUS2 } diff --git a/tasmota/tasmota_xsns_sensor/xsns_26_lm75ad.ino b/tasmota/tasmota_xsns_sensor/xsns_26_lm75ad.ino index 759160ff7..8f818ec70 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_26_lm75ad.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_26_lm75ad.ino @@ -83,42 +83,34 @@ float LM75ADGetTemp(uint32_t sensor) { } void LM75ADShow(bool json) { + bool dual_bus_use = (Lm75.bus[0] != Lm75.bus[Lm75.count -1]); for (uint32_t sensor = 0; sensor < Lm75.count; sensor++) { + // Takes 2ms / LM75 float t = LM75ADGetTemp(sensor); -// if (!isnan(t)) { - char name[16]; - // LM75AD - strlcpy(name, "LM75AD", sizeof(name)); - if (Lm75.count > 1) { - // LM75AD-49 - snprintf_P(name, sizeof(name), PSTR("%s%c%02X"), name, IndexSeparator(), Lm75.address[sensor]); -#ifdef USE_I2C_BUS2 - if (TasmotaGlobal.i2c_enabled[1]) { // Second bus enabled - uint8_t bus = Lm75.bus[0]; - for (uint32_t i = 1; i < Lm75.count; i++) { - if (bus != Lm75.bus[i]) { // Different busses - // LM75AD-49-1 - snprintf_P(name, sizeof(name), PSTR("%s%c%d"), name, IndexSeparator(), Lm75.bus[sensor] +1); - break; - } - } - } -#endif // USE_I2C_BUS2 - } - if (json) { - ResponseAppend_P(JSON_SNS_F_TEMP, name, Settings->flag2.temperature_resolution, &t); + char name[16]; + strlcpy(name, "LM75AD", sizeof(name)); // LM75AD + if (Lm75.count > 1) { + snprintf_P(name, sizeof(name), PSTR("%s%c%02X"), name, IndexSeparator(), Lm75.address[sensor]); // LM75AD-49 +#ifdef USE_I2C_BUS2 + if (TasmotaGlobal.i2c_enabled[1] && dual_bus_use) { // Different busses + snprintf_P(name, sizeof(name), PSTR("%s%c%d"), name, IndexSeparator(), Lm75.bus[sensor] +1); // LM75AD-49-1 + } +#endif // USE_I2C_BUS2 + } + + if (json) { + ResponseAppend_P(JSON_SNS_F_TEMP, name, Settings->flag2.temperature_resolution, &t); #ifdef USE_DOMOTICZ - if ((0 == TasmotaGlobal.tele_period) && (0 == sensor)) { - DomoticzFloatSensor(DZ_TEMP, t); - } + if ((0 == TasmotaGlobal.tele_period) && (0 == sensor)) { + DomoticzFloatSensor(DZ_TEMP, t); + } #endif // USE_DOMOTICZ #ifdef USE_WEBSERVER - } else { - WSContentSend_Temp(name, t); + } else { + WSContentSend_Temp(name, t); #endif // USE_WEBSERVER - } -// } + } } }