Skip to content

Commit

Permalink
Updates for release 6.3.0
Browse files Browse the repository at this point in the history
Updates for release 6.3.0
  • Loading branch information
arendst committed Oct 30, 2018
1 parent 1843463 commit 6d58580
Show file tree
Hide file tree
Showing 13 changed files with 380 additions and 276 deletions.
20 changes: 12 additions & 8 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ See [Tasmota ESP/Arduino library version related issues](https://github.com/aren

| Feature or Sensor | minimal | basic | classic | sonoff | knx | sensors | Remarks
|--------------------------------|---------|-------|---------|--------|------|---------|--------
| ESP/Arduino lib v2.3.0 | 344k | xxxk | 485k | 491k | 510k | 516k |
| ESP/Arduino lib v2.4.2 | 363k | xxxk | 499k | 509k | 526k | 532k | No sleep
| ESP/Arduino lib v2.3.0 | 343k | 425k | 484k | 490k | 508k | 517k |
| ESP/Arduino lib v2.4.2 | 372k | 451k | 497k | 517k | 533k | 541k | No sleep
| | | | | | | |
| MY_LANGUAGE en-GB | x | x | x | x | x | x |
| MQTT_LIBRARY_TYPE PUBSUBCLIENT | x | x | x | x | x | x |
Expand Down Expand Up @@ -173,10 +173,11 @@ Version 6.3.0 20181030
* Add command SerialSend5 to send raw serial data like "A5074100545293"
* Add command WebRefresh 1000..10000 to control web page refresh in milliseconds. Default is 2345
* Add command WeightRes 0..3 to control display of decimals for kilogram
* Add command SetOption52 to control display of optional time offset from UTC in JSON messages (#3629, #3711)
* Add command RGBWWTable to support color calibration (#3933)
* Add command Reset 4 (reset to defaults but keep wifi params) and Reset 5 (as reset 4 and also erase flash) (#4061)
* Add command SetOption35 0..255 (seconds) to delay mDNS initialization to control possible Wifi connect problems
* Add command SetOption52 0/1 to control display of optional time offset from UTC in JSON messages (#3629, #3711)
* Add command SetOption53 0/1 to toggle gui display of Hostname and IP address (#1006, #2091)
* Add authentication to HTTP web pages
* Add decimals as input to commands PowerSet, VoltageSet and CurrentSet
* Add tools/decode-config.py by Norbert Richter to decode configuration data. See file for information
Expand All @@ -185,18 +186,21 @@ Version 6.3.0 20181030
* Add auto reload of main web page to some web restarts
* Add TasmotaModbus library as very basic modbus wrapper for TasmotaSerial
* Add more API callbacks and document API.md
* Add Apparent Power and Reactive Power to Energy Monitoring devices (#251)
* Add token %hostname% to command FullTopic (#3018)
* Add Wifi channel number to state message (#3664)
* Add user configurable GPIO02 and GPIO03 on H801 devices (#3692)
* Add network information to display start screen (#3704)
* Add toggle function RGBW lights (#3695, #3697)
* Add network information to display start screen (#3704)
* Add sleep to Nova Fitness SDS01X sensor (#2841, #3724, #3749)
* Add Analog input AD0 enabled to sonoff-sensors.bin (#3756, #3757)
* Add userid/password option to decode-status.py (#3796)
* Add power value below 5W to Sonoff Pow R2 and S31 (#3745)
* Add force_update to Home Assistant discovery (#3873)
* Add RF Receiver control to module MagicHome to be used on Arilux LC10 (#3792)
* Add userid/password option to decode-status.py (#3796)
* Add delay after restart before processing rule sensor data (#3811)
* Add force_update to Home Assistant discovery (#3873)
* Add rule triggers SWITCH1#BOOT and POWER1#BOOT (#3904, #3910)
* Add Apparent Power and Reactive Power to Energy Monitoring devices (#251)
* Add RF Receiver control to module MagicHome to be used on Arilux LC10 (#3792)
* Add Hebrew language file (#3960)
* Add TotalStartTime to Energy JSON message (#3971)
* Add whitespace removal from RfRaw and SerialSend5 (#4020)
* Add support for two BMP/BME sensors (#4195)
16 changes: 10 additions & 6 deletions sonoff/_changelog.ino
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@
* Add command SerialSend5 to send raw serial data like "A5074100545293"
* Add command WebRefresh 1000..10000 to control web page refresh in milliseconds. Default is 2345
* Add command WeightRes 0..3 to control display of decimals for kilogram
* Add command SetOption52 to control display of optional time offset from UTC in JSON messages (#3629, #3711)
* Add command RGBWWTable to support color calibration (#3933)
* Add command Reset 4 (reset to defaults but keep wifi params) and Reset 5 (as reset 4 and also erase flash) (#4061)
* Add command SetOption35 0..255 (seconds) to delay mDNS initialization to control possible Wifi connect problems
* Add command SetOption52 0/1 to control display of optional time offset from UTC in JSON messages (#3629, #3711)
* Add command SetOption53 0/1 to toggle gui display of Hostname and IP address (#1006, #2091)
* Add authentication to HTTP web pages
* Add decimals as input to commands PowerSet, VoltageSet and CurrentSet
* Add tools/decode-config.py by Norbert Richter to decode configuration data. See file for information
Expand All @@ -67,21 +68,24 @@
* Add auto reload of main web page to some web restarts
* Add TasmotaModbus library as very basic modbus wrapper for TasmotaSerial
* Add more API callbacks and document API.md
* Add Apparent Power and Reactive Power to Energy Monitoring devices (#251)
* Add token %hostname% to command FullTopic (#3018)
* Add Wifi channel number to state message (#3664)
* Add user configurable GPIO02 and GPIO03 on H801 devices (#3692)
* Add network information to display start screen (#3704)
* Add toggle function RGBW lights (#3695, #3697)
* Add network information to display start screen (#3704)
* Add sleep to Nova Fitness SDS01X sensor (#2841, #3724, #3749)
* Add Analog input AD0 enabled to sonoff-sensors.bin (#3756, #3757)
* Add userid/password option to decode-status.py (#3796)
* Add power value below 5W to Sonoff Pow R2 and S31 (#3745)
* Add force_update to Home Assistant discovery (#3873)
* Add RF Receiver control to module MagicHome to be used on Arilux LC10 (#3792)
* Add userid/password option to decode-status.py (#3796)
* Add delay after restart before processing rule sensor data (#3811)
* Add force_update to Home Assistant discovery (#3873)
* Add rule triggers SWITCH1#BOOT and POWER1#BOOT (#3904, #3910)
* Add Apparent Power and Reactive Power to Energy Monitoring devices (#251)
* Add RF Receiver control to module MagicHome to be used on Arilux LC10 (#3792)
* Add Hebrew language file (#3960)
* Add TotalStartTime to Energy JSON message (#3971)
* Add whitespace removal from RfRaw and SerialSend5 (#4020)
* Add support for two BMP/BME sensors (#4195)
*
* 6.2.1 20180905
* Fix possible ambiguity on command parameters if StateText contains numbers only (#3656)
Expand Down
1 change: 1 addition & 0 deletions sonoff/i18n.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
#define D_JSON_TIME "Time"
#define D_JSON_TODAY "Today"
#define D_JSON_TOTAL "Total"
#define D_JSON_TOTAL_START_TIME "TotalStartTime"
#define D_JSON_TVOC "TVOC"
#define D_JSON_TYPE "Type"
#define D_JSON_UPTIME "Uptime"
Expand Down
6 changes: 3 additions & 3 deletions sonoff/my_user_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@
#ifdef USE_I2C
#define USE_SHT // Enable SHT1X sensor (+1k4 code)
#define USE_HTU // Enable HTU21/SI7013/SI7020/SI7021 sensor (I2C address 0x40) (+1k5 code)
#define USE_BMP // Enable BMP085/BMP180/BMP280/BME280 sensor (I2C address 0x76 or 0x77) (+4k code)
// #define USE_BME680 // Enable support for BME680 sensor using Bosch BME680 library (+4k code)
#define USE_BMP // Enable BMP085/BMP180/BMP280/BME280 sensors (I2C addresses 0x76 and 0x77) (+4k1 code)
// #define USE_BME680 // Enable support for BME680 sensors using Bosch BME680 library (+4k4 code)
#define USE_BH1750 // Enable BH1750 sensor (I2C address 0x23 or 0x5C) (+0k5 code)
// #define USE_VEML6070 // Enable VEML6070 sensor (I2C addresses 0x38 and 0x39) (+1k5 code)
#define USE_VEML6070_RSET 270000 // VEML6070, Rset in Ohm used on PCB board, default 270K = 270000ohm, range for this sensor: 220K ... 1Meg
Expand Down Expand Up @@ -397,7 +397,7 @@
\*********************************************************************************************/

//#define USE_CLASSIC // Create sonoff-classic with initial configuration tools WPS, SmartConfig and WifiManager
//#define USE_BASIC // Create sonoff-basic without sensors
//#define USE_BASIC // Create sonoff-basic with no sensors
//#define USE_SENSORS // Create sonoff-sensors with useful sensors enabled
//#define USE_KNX_NO_EMULATION // Create sonoff-knx with KNX but without Emulation
//#define USE_DISPLAYS // Create sonoff-display with display drivers enabled
Expand Down
5 changes: 3 additions & 2 deletions sonoff/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t timers_enable : 1; // bit 0 (v6.1.1b)
uint32_t user_esp8285_enable : 1; // bit 1 (v6.1.1.14)
uint32_t time_append_timezone : 1; // bit 2 (v6.2.1.2)
uint32_t spare03 : 1;
uint32_t gui_hostname_ip : 1; // bit 3 (v6.2.1.20)
uint32_t spare04 : 1;
uint32_t spare05 : 1;
uint32_t spare06 : 1;
Expand Down Expand Up @@ -322,8 +322,9 @@ struct SYSCFG {
uint16_t mcp230xx_int_timer; // 718
uint8_t rgbwwTable[5]; // 71A

byte free_71F[153]; // 71F
byte free_71F[149]; // 71F

uint32_t energy_kWhtotal_time; // 7B4
unsigned long weight_item; // 7B8 Weight of one item in gram * 10

byte free_7BC[2]; // 7BC
Expand Down
3 changes: 2 additions & 1 deletion sonoff/sonoff.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ typedef unsigned long power_t; // Power (Relay) type

#define MQTT_TOKEN_PREFIX "%prefix%" // To be substituted by mqtt_prefix[x]
#define MQTT_TOKEN_TOPIC "%topic%" // To be substituted by mqtt_topic, mqtt_grptopic, mqtt_buttontopic, mqtt_switchtopic
#define MQTT_TOKEN_HOSTNAME "%hostname%" // To be substituted by mqtt_topic, mqtt_grptopic, mqtt_buttontopic, mqtt_switchtopic
#define MQTT_TOKEN_ID "%id%" // To be substituted by mqtt_topic, mqtt_grptopic, mqtt_buttontopic, mqtt_switchtopic

#define WIFI_HOSTNAME "%s-%04d" // Expands to <MQTT_TOPIC>-<last 4 decimal chars of MAC address>
Expand Down Expand Up @@ -180,7 +181,7 @@ enum WeekInMonthOptions {Last, First, Second, Third, Fourth};
enum DayOfTheWeekOptions {Sun=1, Mon, Tue, Wed, Thu, Fri, Sat};
enum MonthNamesOptions {Jan=1, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec};
enum HemisphereOptions {North, South};
enum GetDateAndTimeOptions { DT_LOCAL, DT_UTC, DT_RESTART };
enum GetDateAndTimeOptions { DT_LOCAL, DT_UTC, DT_RESTART, DT_ENERGY };

enum LoggingLevels {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE, LOG_LEVEL_ALL};

Expand Down
1 change: 1 addition & 0 deletions sonoff/sonoff.ino
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ void GetTopic_P(char *stopic, byte prefix, char *topic, const char* subtopic)
}
fulltopic.replace(F(MQTT_TOKEN_PREFIX), Settings.mqtt_prefix[prefix]);
fulltopic.replace(F(MQTT_TOKEN_TOPIC), topic);
fulltopic.replace(F(MQTT_TOKEN_HOSTNAME), my_hostname);
String token_id = WiFi.macAddress();
token_id.replace(":", "");
fulltopic.replace(F(MQTT_TOKEN_ID), token_id);
Expand Down
8 changes: 7 additions & 1 deletion sonoff/support.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1946,6 +1946,10 @@ String GetDateAndTime(byte time_type)
TIME_T tmpTime;

switch (time_type) {
case DT_ENERGY:
BreakTime(Settings.energy_kWhtotal_time, tmpTime);
tmpTime.year += 1970;
break;
case DT_UTC:
BreakTime(utc_time, tmpTime);
tmpTime.year += 1970;
Expand All @@ -1964,7 +1968,8 @@ String GetDateAndTime(byte time_type)
snprintf_P(dt, sizeof(dt), PSTR("%04d-%02d-%02dT%02d:%02d:%02d"),
tmpTime.year, tmpTime.month, tmpTime.day_of_month, tmpTime.hour, tmpTime.minute, tmpTime.second);

if (Settings.flag3.time_append_timezone && (time_type == DT_LOCAL)) {
if (Settings.flag3.time_append_timezone && (DT_LOCAL == time_type)) {
// if (Settings.flag3.time_append_timezone && ((DT_LOCAL == time_type) || (DT_ENERGY == time_type))) {
snprintf_P(dt, sizeof(dt), PSTR("%s%+03d:%02d"), dt, time_timezone / 10, abs((time_timezone % 10) * 6)); // if timezone = +2:30 then time_timezone = 25
}

Expand Down Expand Up @@ -2225,6 +2230,7 @@ void RtcSecond()
}
local_time += time_offset;
time_timezone = time_offset / 360; // (SECS_PER_HOUR / 10) fails as it is defined as UL
if (!Settings.energy_kWhtotal_time) { Settings.energy_kWhtotal_time = local_time; }
}
BreakTime(local_time, RtcTime);
if (!RtcTime.hour && !RtcTime.minute && !RtcTime.second && RtcTime.valid) {
Expand Down
22 changes: 21 additions & 1 deletion sonoff/xdrv_01_webserver.ino
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const char HTTP_HEAD_STYLE[] PROGMEM =
#else
"<h3>{ha " D_MODULE "</h3>"
#endif
"<h2>{h}</h2></div>";
"<h2>{h}</h2>{j}</div>";
const char HTTP_SCRIPT_CONSOL[] PROGMEM =
"var sn=0;" // Scroll position
"var id=0;" // Get most of weblog initially
Expand Down Expand Up @@ -453,6 +453,25 @@ void ShowPage(String &page, bool auth)
page.replace(F("{a}"), String(Settings.web_refresh));
page.replace(F("{ha"), my_module.name);
page.replace(F("{h}"), Settings.friendlyname[0]);

String info = "";
if (Settings.flag3.gui_hostname_ip) {
uint8_t more_ips = 0;
info += F("<h3>"); info += my_hostname;
if (mdns_begun) { info += F(".local"); }
info += F(" (");
if (static_cast<uint32_t>(WiFi.localIP()) != 0) {
info += WiFi.localIP().toString();
more_ips++;
}
if (static_cast<uint32_t>(WiFi.softAPIP()) != 0) {
if (more_ips) { info += F(", "); }
info += WiFi.softAPIP().toString();
}
info += F(")</h3>");
}
page.replace(F("{j}"), info);

if (HTTP_MANAGER == webserver_state) {
if (WifiConfigCounter()) {
page.replace(F("<body>"), F("<body onload='u()'>"));
Expand Down Expand Up @@ -1241,6 +1260,7 @@ void HandleInformation()
func += F("}1" D_AP); func += String(Settings.sta_active +1);
func += F(" " D_SSID " (" D_RSSI ")}2"); func += Settings.sta_ssid[Settings.sta_active]; func += F(" ("); func += WifiGetRssiAsQuality(WiFi.RSSI()); func += F("%)");
func += F("}1" D_HOSTNAME "}2"); func += my_hostname;
if (mdns_begun) { func += F(".local"); }
if (static_cast<uint32_t>(WiFi.localIP()) != 0) {
func += F("}1" D_IP_ADDRESS "}2"); func += WiFi.localIP().toString();
func += F("}1" D_GATEWAY "}2"); func += IPAddress(Settings.ip_address[1]).toString();
Expand Down
5 changes: 3 additions & 2 deletions sonoff/xdrv_03_energy.ino
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ boolean EnergyCommand()
RtcSettings.energy_kWhtotal = lnum *100;
Settings.energy_kWhtotal = RtcSettings.energy_kWhtotal;
energy_total = (float)(RtcSettings.energy_kWhtotal + energy_kWhtoday) / 100000;
if (!energy_total) { Settings.energy_kWhtotal_time = LocalTime(); }
break;
}
}
Expand Down Expand Up @@ -612,8 +613,8 @@ void EnergyShow(boolean json)
}

if (json) {
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"" D_RSLT_ENERGY "\":{\"" D_JSON_TOTAL "\":%s,\"" D_JSON_YESTERDAY "\":%s,\"" D_JSON_TODAY "\":%s%s,\"" D_JSON_POWERUSAGE "\":%s"),
mqtt_data, energy_total_chr, energy_yesterday_chr, energy_daily_chr, (show_energy_period) ? speriod : "", active_power_chr);
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"" D_RSLT_ENERGY "\":{\"" D_JSON_TOTAL_START_TIME "\":\"%s\",\"" D_JSON_TOTAL "\":%s,\"" D_JSON_YESTERDAY "\":%s,\"" D_JSON_TODAY "\":%s%s,\"" D_JSON_POWERUSAGE "\":%s"),
mqtt_data, GetDateAndTime(DT_ENERGY).c_str(), energy_total_chr, energy_yesterday_chr, energy_daily_chr, (show_energy_period) ? speriod : "", active_power_chr);
if (!energy_type_dc) {
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"" D_JSON_APPARENT_POWERUSAGE "\":%s,\"" D_JSON_REACTIVE_POWERUSAGE "\":%s,\"" D_JSON_POWERFACTOR "\":%s%s"),
mqtt_data, apparent_power_chr, reactive_power_chr, power_factor_chr, (!isnan(energy_frequency)) ? sfrequency : "");
Expand Down
44 changes: 36 additions & 8 deletions sonoff/xdrv_16_tuyadimmer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ boolean tuya_ignore_dim = false; // Flag to skip serial send to preve
uint8_t tuya_cmd_status = 0; // Current status of serial-read
uint8_t tuya_cmd_checksum = 0; // Checksum of tuya command
uint8_t tuya_data_len = 0; // Data lenght of command
bool tuya_wifi_state = false;

char tuya_buffer[TUYA_BUFFER_SIZE]; // Serial receive buffer
int tuya_byte_counter = 0; // Index in serial receive buffer
Expand Down Expand Up @@ -142,12 +143,15 @@ void TuyaPacketProcess()
ExecuteCommand(scmnd, SRC_SWITCH);
}
}
else if (tuya_byte_counter == 8 && tuya_buffer[3] == 5 && tuya_buffer[5] == 1 && tuya_buffer[7] == 5 ) { // reset WiFi settings packet - to do: reset red MCU LED after WiFi is up
else if (tuya_byte_counter == 8 && tuya_buffer[3] == 5 && tuya_buffer[5] == 1 && tuya_buffer[7] == 5 ) { // reset WiFi settings packet

AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: WiFi Reset Rcvd"));
TuyaResetWifi();
}
else if (tuya_byte_counter == 7 && tuya_buffer[3] == 3 && tuya_buffer[6] == 2) { // WiFi LED has been sucessfully reset.

snprintf_P(scmnd, sizeof(scmnd), D_CMND_WIFICONFIG " 2");
ExecuteCommand(scmnd, SRC_BUTTON);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: WiFi LED reset ACK"));
tuya_wifi_state = true;
}
}

Expand Down Expand Up @@ -221,6 +225,21 @@ boolean TuyaModuleSelected()
return true;
}

void TuyaResetWifiLed(){
snprintf_P(log_data, sizeof(log_data), "TYA: Reset WiFi LED");
AddLog(LOG_LEVEL_DEBUG);

TuyaSerial->write((uint8_t)0x55); // header 55AA
TuyaSerial->write((uint8_t)0xAA);
TuyaSerial->write((uint8_t)0x00); // version 00
TuyaSerial->write((uint8_t)0x03); // command 03 - set wifi state
TuyaSerial->write((uint8_t)0x00);
TuyaSerial->write((uint8_t)0x01); // following data length 0x01
TuyaSerial->write((uint8_t)0x03); // wifi state 4 (configured and connected)
TuyaSerial->write((uint8_t)0x06); // checksum:sum of all bytes in packet mod 256
TuyaSerial->flush();
}

void TuyaInit()
{
if (!Settings.param[P_TUYA_DIMMER_ID]) {
Expand All @@ -245,18 +264,24 @@ void TuyaInit()
}
}

void TuyaResetWifi()
{
if (!Settings.flag.button_restrict) {
char scmnd[20];
snprintf_P(scmnd, sizeof(scmnd), D_CMND_WIFICONFIG " %d", 2);
ExecuteCommand(scmnd, SRC_BUTTON);
tuya_wifi_state = false;
}
}

boolean TuyaButtonPressed()
{
if ((PRESSED == XdrvMailbox.payload) && (NOT_PRESSED == lastbutton[XdrvMailbox.index])) {

snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_LEVEL_10), XdrvMailbox.index +1);
AddLog(LOG_LEVEL_DEBUG);
TuyaResetWifi();

if (!Settings.flag.button_restrict) {
char scmnd[20];
snprintf_P(scmnd, sizeof(scmnd), D_CMND_WIFICONFIG " %d", 2);
ExecuteCommand(scmnd, SRC_BUTTON);
}
}
return true; // Serviced here
}
Expand Down Expand Up @@ -288,6 +313,9 @@ boolean Xdrv16(byte function)
case FUNC_BUTTON_PRESSED:
result = TuyaButtonPressed();
break;
case FUNC_EVERY_SECOND:
if(TuyaSerial && !tuya_wifi_state) { TuyaResetWifiLed(); }
break;
}
}
return result;
Expand Down
2 changes: 1 addition & 1 deletion sonoff/xdrv_17_rcswitch.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
xdrv_17_rcswitch.ino - RF transceiver using RcSwitch library for Sonoff-Tasmota
Copyright (C) 2017 Theo Arends
Copyright (C) 2018 Theo Arends
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
Loading

0 comments on commit 6d58580

Please sign in to comment.