diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index 82d12f28e..c62144f8d 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -1,8 +1,14 @@ -/* 6.2.1.2 20180906 +/* 6.2.1.3 20180907 + * Change web Configure Module GPIO drop down list order for better readability + * Fix showing Period Power in energy threshold messages + * Fix ButtonRetain to not use default topic for clearing retain messages (#3737) + * + * 6.2.1.2 20180906 * Fix KNX PA exception. Regression from 6.2.1 buffer overflow caused by subStr() (#3700, #3710) * Add command SetOption52 to control display of optional time offset from UTC in JSON messages (#3629, #3711) * Add experimental support for PZEM-003,014,016,017 Energy monitoring (#3694) * Add basic support for MP3 player using DFRobot RB-DFR-562 (#3723) + * Fix setting and getting color temperature for Philips Hue emulation (#3733) * * 6.2.1.1 20180905 * Rewrite energy monitoring using energy sensor driver modules diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 6b2e8422b..a1ab907ab 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -134,7 +134,7 @@ int ota_state_flag = 0; // OTA state flag int ota_result = 0; // OTA result int restart_flag = 0; // Sonoff restart flag int wifi_state_flag = WIFI_RESTART; // Wifi state flag -int tele_period = 0; // Tele period timer +int tele_period = 1; // Tele period timer int blinks = 201; // Number of LED blinks uint32_t uptime = 0; // Counting every second until 4294967295 = 130 year uint32_t global_update = 0; // Timestamp of last global temperature and humidity update diff --git a/sonoff/sonoff_template.h b/sonoff/sonoff_template.h index 2ab43286d..23019ff10 100644 --- a/sonoff/sonoff_template.h +++ b/sonoff/sonoff_template.h @@ -21,6 +21,8 @@ #define _SONOFF_TEMPLATE_H_ // User selectable GPIO functionality +// ATTENTION: Only add at the end of this list just before GPIO_SENSOR_END +// Then add the same name(s) in a nice location in array kGpioNiceList enum UserSelectablePins { GPIO_NONE, // Not used GPIO_DHT11, // DHT11 @@ -244,7 +246,111 @@ typedef struct MYTMPLT { myio gp; } mytmplt; -const uint8_t kNiceList[MAXMODULE] PROGMEM = { +const uint8_t kGpioNiceList[GPIO_SENSOR_END] PROGMEM = { + GPIO_NONE, // Not used + GPIO_KEY1, // Buttons + GPIO_KEY1_NP, + GPIO_KEY2, + GPIO_KEY2_NP, + GPIO_KEY3, + GPIO_KEY3_NP, + GPIO_KEY4, + GPIO_KEY4_NP, + GPIO_SWT1, // User connected external switches + GPIO_SWT1_NP, + GPIO_SWT2, + GPIO_SWT2_NP, + GPIO_SWT3, + GPIO_SWT3_NP, + GPIO_SWT4, + GPIO_SWT4_NP, + GPIO_SWT5, + GPIO_SWT5_NP, + GPIO_SWT6, + GPIO_SWT6_NP, + GPIO_SWT7, + GPIO_SWT7_NP, + GPIO_SWT8, + GPIO_SWT8_NP, + GPIO_REL1, // Relays + GPIO_REL1_INV, + GPIO_REL2, + GPIO_REL2_INV, + GPIO_REL3, + GPIO_REL3_INV, + GPIO_REL4, + GPIO_REL4_INV, + GPIO_REL5, + GPIO_REL5_INV, + GPIO_REL6, + GPIO_REL6_INV, + GPIO_REL7, + GPIO_REL7_INV, + GPIO_REL8, + GPIO_REL8_INV, + GPIO_LED1, // Leds + GPIO_LED1_INV, + GPIO_LED2, + GPIO_LED2_INV, + GPIO_LED3, + GPIO_LED3_INV, + GPIO_LED4, + GPIO_LED4_INV, + GPIO_PWM1, // RGB Red or C Cold White + GPIO_PWM1_INV, + GPIO_PWM2, // RGB Green or CW Warm White + GPIO_PWM2_INV, + GPIO_PWM3, // RGB Blue + GPIO_PWM3_INV, + GPIO_PWM4, // RGBW (Cold) White + GPIO_PWM4_INV, + GPIO_PWM5, // RGBCW Warm White + GPIO_PWM5_INV, + GPIO_CNTR1, // Counters + GPIO_CNTR1_NP, + GPIO_CNTR2, + GPIO_CNTR2_NP, + GPIO_CNTR3, + GPIO_CNTR3_NP, + GPIO_CNTR4, + GPIO_CNTR4_NP, + GPIO_I2C_SCL, // I2C SCL + GPIO_I2C_SDA, // I2C SDA + GPIO_SPI_CS, // SPI Chip Select + GPIO_SPI_DC, // SPI Data Direction + GPIO_BACKLIGHT, // Display backlight control + GPIO_DHT11, // DHT11 + GPIO_DHT22, // DHT21, DHT22, AM2301, AM2302, AM2321 + GPIO_SI7021, // iTead SI7021 + GPIO_DSB, // Single wire DS18B20 or DS18S20 + GPIO_WS2812, // WS2812 Led string + GPIO_IRSEND, // IR remote + GPIO_IRRECV, // IR receiver + GPIO_SR04_TRIG, // SR04 Trigger pin + GPIO_SR04_ECHO, // SR04 Echo pin + GPIO_TM16CLK, // TM1638 Clock + GPIO_TM16DIO, // TM1638 Data I/O + GPIO_TM16STB, // TM1638 Strobe + GPIO_SBR_TX, // Serial Bridge Serial interface + GPIO_SBR_RX, // Serial Bridge Serial interface + GPIO_MHZ_TXD, // MH-Z19 Serial interface + GPIO_MHZ_RXD, // MH-Z19 Serial interface + GPIO_SAIR_TX, // SenseAir Serial interface + GPIO_SAIR_RX, // SenseAir Serial interface + GPIO_SDS0X1, // Nova Fitness SDS011 Serial interface + GPIO_PZEM_TX, // PZEM004T Serial interface + GPIO_PZEM_RX, // PZEM004T Serial interface + GPIO_PZEM2_TX, // PZEM-003,014,016,017 Serial interface + GPIO_PZEM2_RX, // PZEM-003,014,016,017 Serial interface + GPIO_SDM120_TX, // SDM120 Serial interface + GPIO_SDM120_RX, // SDM120 Serial interface + GPIO_SDM630_TX, // SDM630 Serial interface + GPIO_SDM630_RX, // SDM630 Serial interface + GPIO_PMS5003, // Plantower PMS5003 Serial interface + GPIO_MP3_DFR562 // RB-DFR-562, DFPlayer Mini MP3 Player Serial interface +}; + +const uint8_t kModuleNiceList[MAXMODULE] PROGMEM = { SONOFF_BASIC, SONOFF_RF, SONOFF_TH, diff --git a/sonoff/sonoff_version.h b/sonoff/sonoff_version.h index 178e0af68..f068473ab 100644 --- a/sonoff/sonoff_version.h +++ b/sonoff/sonoff_version.h @@ -20,7 +20,7 @@ #ifndef _SONOFF_VERSION_H_ #define _SONOFF_VERSION_H_ -#define VERSION 0x06020102 +#define VERSION 0x06020103 #define D_PROGRAMNAME "Sonoff-Tasmota" #define D_AUTHOR "Theo Arends" diff --git a/sonoff/xdrv_01_mqtt.ino b/sonoff/xdrv_01_mqtt.ino index c47728df0..f3f33d693 100644 --- a/sonoff/xdrv_01_mqtt.ino +++ b/sonoff/xdrv_01_mqtt.ino @@ -380,9 +380,7 @@ void MqttConnected() MqttPublishPowerState(i); if (SONOFF_IFAN02 == Settings.module) { break; } // Only report status of light relay } - if (Settings.tele_period) { - tele_period = Settings.tele_period -9; - } + if (Settings.tele_period) { tele_period = Settings.tele_period -9; } // Enable TelePeriod in 9 seconds rules_flag.system_boot = 1; XdrvCall(FUNC_MQTT_INIT); } @@ -718,7 +716,6 @@ bool MqttCommand() } else if (CMND_BUTTONRETAIN == command_code) { if ((payload >= 0) && (payload <= 1)) { - strlcpy(Settings.button_topic, mqtt_topic, sizeof(Settings.button_topic)); if (!payload) { for(i = 1; i <= MAX_KEYS; i++) { SendKey(0, i, 9); // Clear MQTT retain in broker @@ -730,7 +727,6 @@ bool MqttCommand() } else if (CMND_SWITCHRETAIN == command_code) { if ((payload >= 0) && (payload <= 1)) { - strlcpy(Settings.button_topic, mqtt_topic, sizeof(Settings.button_topic)); if (!payload) { for(i = 1; i <= MAX_SWITCHES; i++) { SendKey(1, i, 9); // Clear MQTT retain in broker diff --git a/sonoff/xdrv_02_webserver.ino b/sonoff/xdrv_02_webserver.ino index 4059459c5..4398a9eb0 100644 --- a/sonoff/xdrv_02_webserver.ino +++ b/sonoff/xdrv_02_webserver.ino @@ -768,7 +768,7 @@ void HandleModuleConfiguration() page.replace(F("{v}"), FPSTR(S_CONFIGURE_MODULE)); page += FPSTR(HTTP_SCRIPT_MODULE1); for (byte i = 0; i < MAXMODULE; i++) { - midx = pgm_read_byte(kNiceList + i); + midx = pgm_read_byte(kModuleNiceList + i); snprintf_P(stemp, sizeof(stemp), kModules[midx].name); snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SCRIPT_MODULE2, midx, midx +1, stemp); page += mqtt_data; @@ -779,10 +779,10 @@ void HandleModuleConfiguration() mytmplt cmodule; memcpy_P(&cmodule, &kModules[Settings.module], sizeof(cmodule)); - for (byte j = 0; j < GPIO_SENSOR_END; j++) { - if (!GetUsedInModule(j, cmodule.gp.io)) { - snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SCRIPT_MODULE2, j, j, GetTextIndexed(stemp, sizeof(stemp), j, kSensorNames)); + midx = pgm_read_byte(kGpioNiceList + j); + if (!GetUsedInModule(midx, cmodule.gp.io)) { + snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SCRIPT_MODULE2, midx, midx, GetTextIndexed(stemp, sizeof(stemp), midx, kSensorNames)); page += mqtt_data; } } diff --git a/sonoff/xdrv_03_energy.ino b/sonoff/xdrv_03_energy.ino index 081b52d83..ac26a18da 100644 --- a/sonoff/xdrv_03_energy.ino +++ b/sonoff/xdrv_03_energy.ino @@ -304,7 +304,10 @@ void EnergyMqttShow() { // {"Time":"2017-12-16T11:48:55","ENERGY":{"Total":0.212,"Yesterday":0.000,"Today":0.014,"Period":2.0,"Power":22.0,"Factor":1.00,"Voltage":213.6,"Current":0.100}} snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_TIME "\":\"%s\""), GetDateAndTime(DT_LOCAL).c_str()); + int tele_period_save = tele_period; + tele_period = 2; EnergyShow(1); + tele_period = tele_period_save; snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s}"), mqtt_data); MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR), Settings.flag.mqtt_sensor_retain); energy_power_delta = 0; diff --git a/sonoff/xdrv_10_rules.ino b/sonoff/xdrv_10_rules.ino index df27cb4cd..930bde7d5 100644 --- a/sonoff/xdrv_10_rules.ino +++ b/sonoff/xdrv_10_rules.ino @@ -426,7 +426,7 @@ void RulesEvery100ms() { if (Settings.rule_enabled) { // Any rule enabled mqtt_data[0] = '\0'; - uint16_t tele_period_save = tele_period; + int tele_period_save = tele_period; tele_period = 2; // Do not allow HA updates during next function call XsnsNextCall(FUNC_JSON_APPEND); // ,"INA219":{"Voltage":4.494,"Current":0.020,"Power":0.089} tele_period = tele_period_save;