From cf19dad98511ca4c028b6eace2a8f5b0c1a379ab Mon Sep 17 00:00:00 2001 From: srodgers Date: Sun, 10 Nov 2019 14:55:35 -0800 Subject: [PATCH 1/3] Fix incorrect JSON in ID field. Disable active debug statements. Update documentation at beginning of source file --- tasmota/xsns_54_ina226.ino | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tasmota/xsns_54_ina226.ino b/tasmota/xsns_54_ina226.ino index b96ae724e..93c1a0d21 100644 --- a/tasmota/xsns_54_ina226.ino +++ b/tasmota/xsns_54_ina226.ino @@ -31,6 +31,10 @@ * b. Sensor54 12 [full scale current in amperes] e.g. Sensor54 12 3.0 * c. Sensor54 2 saves the settings and restarts Tasmota. The device should show up after the system boots again. * +* +* This driver will not probe I2C bus for INA226 devices unless the full scale current is set for a device number. +* It will map device numbers as follows: +* * Device number to I2C slave address mapping * * 1 - 0x40 @@ -38,9 +42,6 @@ * 3 - 0x44 * 4 - 0x45 * -* This driver will not probe I2C bus for INA226 devices unless the full scale current is set for a device number. -* It will map device numbers as follows: -* * To set shunt resistance and full scale current, use the Sensor54 command interface as follows: * * Sensor54 10 Return channel 1 shunt resistance and full scale current @@ -124,7 +125,7 @@ static void _debug_fval(const char *str, float fval, uint8_t prec = 4 ) { char fstr[32]; dtostrfd(fval, prec, fstr); - AddLog_P2( LOG_LEVEL_NONE, PSTR("%s: %s"), str, fstr ); + //AddLog_P2( LOG_LEVEL_NONE, PSTR("%s: %s"), str, fstr ); } @@ -237,7 +238,7 @@ void Ina226Init() if (!I2cWrite16( addr, INA226_REG_CONFIG, INA226_CONFIG_RESET)){ - AddLog_P2( LOG_LEVEL_DEBUG, "No INA226 at address: %02X", addr); + //AddLog_P2( LOG_LEVEL_DEBUG, "No INA226 at address: %02X", addr); continue; // No device } @@ -512,7 +513,7 @@ void Ina226Show(bool json) if (json) { - ResponseAppend_P(PSTR(",\"%s\":{\"Id\":%02x,\"" D_JSON_VOLTAGE "\":%s,\"" D_JSON_CURRENT "\":%s,\"" D_JSON_POWERUSAGE "\":%s}"), + ResponseAppend_P(PSTR(",\"%s\":{\"Id\":%d,\"" D_JSON_VOLTAGE "\":%s,\"" D_JSON_CURRENT "\":%s,\"" D_JSON_POWERUSAGE "\":%s}"), name, i, voltage, current, power); #ifdef USE_DOMOTICZ if (0 == tele_period) { From 18a5d94a8f219f7e3b70b6ae81508756ca09e554 Mon Sep 17 00:00:00 2001 From: srodgers Date: Sun, 10 Nov 2019 16:07:03 -0800 Subject: [PATCH 2/3] Re-enable log statements per suggestion --- tasmota/xsns_54_ina226.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasmota/xsns_54_ina226.ino b/tasmota/xsns_54_ina226.ino index 93c1a0d21..6709c6e53 100644 --- a/tasmota/xsns_54_ina226.ino +++ b/tasmota/xsns_54_ina226.ino @@ -125,7 +125,7 @@ static void _debug_fval(const char *str, float fval, uint8_t prec = 4 ) { char fstr[32]; dtostrfd(fval, prec, fstr); - //AddLog_P2( LOG_LEVEL_NONE, PSTR("%s: %s"), str, fstr ); + AddLog_P2( LOG_LEVEL_NONE, PSTR("%s: %s"), str, fstr ); } @@ -238,7 +238,7 @@ void Ina226Init() if (!I2cWrite16( addr, INA226_REG_CONFIG, INA226_CONFIG_RESET)){ - //AddLog_P2( LOG_LEVEL_DEBUG, "No INA226 at address: %02X", addr); + AddLog_P2( LOG_LEVEL_DEBUG, "No INA226 at address: %02X", addr); continue; // No device } From c43e25eaf722af3c602676a4ed7ead98a0d0ecf4 Mon Sep 17 00:00:00 2001 From: srodgers Date: Sun, 10 Nov 2019 16:12:59 -0800 Subject: [PATCH 3/3] Change LOG_LEVEL_NONE to LOG_LEVEL_DEBUG --- tasmota/xsns_54_ina226.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasmota/xsns_54_ina226.ino b/tasmota/xsns_54_ina226.ino index 6709c6e53..5fd404414 100644 --- a/tasmota/xsns_54_ina226.ino +++ b/tasmota/xsns_54_ina226.ino @@ -125,7 +125,7 @@ static void _debug_fval(const char *str, float fval, uint8_t prec = 4 ) { char fstr[32]; dtostrfd(fval, prec, fstr); - AddLog_P2( LOG_LEVEL_NONE, PSTR("%s: %s"), str, fstr ); + AddLog_P2( LOG_LEVEL_DEBUG, PSTR("%s: %s"), str, fstr ); }