v5.13.1b - Prep for user entry DST/STD

Prep for user entry DST/STD (#2721)
This commit is contained in:
Theo Arends 2018-05-13 19:43:48 +02:00
parent 854e0f9eb8
commit 20eb04b7ef
7 changed files with 55 additions and 33 deletions

View File

@ -13,7 +13,7 @@ If you like **Sonoff-Tasmota**, give it a star, or fork it and contribute!
### Development ### Development
[![Build Status](https://img.shields.io/travis/arendst/Sonoff-Tasmota.svg)](https://travis-ci.org/arendst/Sonoff-Tasmota) [![Build Status](https://img.shields.io/travis/arendst/Sonoff-Tasmota.svg)](https://travis-ci.org/arendst/Sonoff-Tasmota)
Current version is **5.13.1a** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information. Current version is **5.13.1b** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
### Quick install ### Quick install
Download one of the released binaries from https://github.com/arendst/Sonoff-Tasmota/releases and flash it to your hardware as documented in the wiki. Download one of the released binaries from https://github.com/arendst/Sonoff-Tasmota/releases and flash it to your hardware as documented in the wiki.

View File

@ -1,4 +1,7 @@
/* 5.13.1a /* 5.13.1b
* Prep for user entry DST/STD (#2721)
*
* 5.13.1a
* Change user_config.h otaurl to http://sonoff.maddox.co.uk/tasmota/sonoff.bin (#2588, #2602) * Change user_config.h otaurl to http://sonoff.maddox.co.uk/tasmota/sonoff.bin (#2588, #2602)
* Fix configuration restore regression from 5.13.1 * Fix configuration restore regression from 5.13.1
* Fix compile error when ADC is enabled and Rules are disabled (#2608) * Fix compile error when ADC is enabled and Rules are disabled (#2608)

View File

@ -298,19 +298,6 @@ struct TIME_T {
unsigned long valid; unsigned long valid;
} RtcTime; } RtcTime;
struct TimeChangeRule
{
uint8_t hemis; // 0-Northern, 1=Southern Hemisphere (=Opposite DST/STD)
uint8_t week; // 1=First, 2=Second, 3=Third, 4=Fourth, or 0=Last week of the month
uint8_t dow; // day of week, 1=Sun, 2=Mon, ... 7=Sat
uint8_t month; // 1=Jan, 2=Feb, ... 12=Dec
uint8_t hour; // 0-23
int offset; // offset from UTC in minutes
};
TimeChangeRule DaylightSavingTime = { TIME_DST }; // Daylight Saving Time
TimeChangeRule StandardTime = { TIME_STD }; // Standard Time
struct XDRVMAILBOX { struct XDRVMAILBOX {
uint16_t valid; uint16_t valid;
uint16_t index; uint16_t index;

View File

@ -521,6 +521,8 @@ void SettingsDefaultSet2()
Settings.latitude = (int)((double)LATITUDE * 1000000); Settings.latitude = (int)((double)LATITUDE * 1000000);
Settings.longitude = (int)((double)LONGITUDE * 1000000); Settings.longitude = (int)((double)LONGITUDE * 1000000);
SettingsDefaultSet_5_13_1a();
} }
/********************************************************************************************/ /********************************************************************************************/
@ -652,6 +654,22 @@ void SettingsDefaultSet_5_10_1()
Settings.display_size = 1; Settings.display_size = 1;
} }
void SettingsDefaultSet_5_13_1a()
{
Settings.dst_flags.hemis = TIME_DST_HEMISPHERE;
Settings.dst_flags.week = TIME_DST_WEEK;
Settings.dst_flags.dow = TIME_DST_DAY;
Settings.dst_flags.month = TIME_DST_MONTH;
Settings.dst_flags.hour = TIME_DST_HOUR;
Settings.dst_offset = TIME_DST_OFFSET;
Settings.std_flags.hemis = TIME_STD_HEMISPHERE;
Settings.std_flags.week = TIME_STD_WEEK;
Settings.std_flags.dow = TIME_STD_DAY;
Settings.std_flags.month = TIME_STD_MONTH;
Settings.std_flags.hour = TIME_STD_HOUR;
Settings.std_offset = TIME_STD_OFFSET;
}
/********************************************************************************************/ /********************************************************************************************/
void SettingsDelta() void SettingsDelta()
@ -856,6 +874,10 @@ void SettingsDelta()
Settings.energy_kWhyesterday /= 1000; Settings.energy_kWhyesterday /= 1000;
RtcSettings.energy_kWhtoday /= 1000; RtcSettings.energy_kWhtoday /= 1000;
} }
if (Settings.version < 0x050D0102) {
SettingsDefaultSet_5_13_1a();
}
Settings.version = VERSION; Settings.version = VERSION;
SettingsSave(1); SettingsSave(1);
} }

View File

@ -25,7 +25,7 @@
- Select IDE Tools - Flash Size: "1M (no SPIFFS)" - Select IDE Tools - Flash Size: "1M (no SPIFFS)"
====================================================*/ ====================================================*/
#define VERSION 0x050D0101 // 5.13.1a #define VERSION 0x050D0102 // 5.13.1b
// Location specific includes // Location specific includes
#include <core_version.h> // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0) #include <core_version.h> // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0)

View File

@ -1288,7 +1288,7 @@ uint32_t MakeTime(TIME_T &tm)
return seconds; return seconds;
} }
uint32_t RuleToTime(TimeChangeRule r, int yr) uint32_t RuleToTime(TimeRule r, int yr)
{ {
TIME_T tm; TIME_T tm;
uint32_t t; uint32_t t;
@ -1367,8 +1367,8 @@ void RtcSecond()
} }
BreakTime(utc_time, tmpTime); BreakTime(utc_time, tmpTime);
RtcTime.year = tmpTime.year + 1970; RtcTime.year = tmpTime.year + 1970;
daylight_saving_time = RuleToTime(DaylightSavingTime, RtcTime.year); daylight_saving_time = RuleToTime(Settings.dst_flags, RtcTime.year);
standard_time = RuleToTime(StandardTime, RtcTime.year); standard_time = RuleToTime(Settings.std_flags, RtcTime.year);
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION "(" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"), snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION "(" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
GetTime(0).c_str(), GetTime(2).c_str(), GetTime(3).c_str()); GetTime(0).c_str(), GetTime(2).c_str(), GetTime(3).c_str());
AddLog(LOG_LEVEL_DEBUG); AddLog(LOG_LEVEL_DEBUG);
@ -1389,9 +1389,9 @@ void RtcSecond()
if (local_time > 1451602800) { // 2016-01-01 if (local_time > 1451602800) { // 2016-01-01
int32_t time_offset = Settings.timezone * SECS_PER_HOUR; int32_t time_offset = Settings.timezone * SECS_PER_HOUR;
if (99 == Settings.timezone) { if (99 == Settings.timezone) {
dstoffset = DaylightSavingTime.offset * SECS_PER_MIN; dstoffset = Settings.dst_offset * SECS_PER_MIN;
stdoffset = StandardTime.offset * SECS_PER_MIN; stdoffset = Settings.std_offset * SECS_PER_MIN;
if (DaylightSavingTime.hemis) { if (Settings.dst_flags.hemis) {
// Southern hemisphere // Southern hemisphere
if ((utc_time >= (standard_time - dstoffset)) && (utc_time < (daylight_saving_time - stdoffset))) { if ((utc_time >= (standard_time - dstoffset)) && (utc_time < (daylight_saving_time - stdoffset))) {
time_offset = stdoffset; // Standard Time time_offset = stdoffset; // Standard Time

View File

@ -129,6 +129,22 @@
#define NTP_SERVER2 "nl.pool.ntp.org" // [NtpServer2] Select second NTP server by name or IP address (5.39.184.5) #define NTP_SERVER2 "nl.pool.ntp.org" // [NtpServer2] Select second NTP server by name or IP address (5.39.184.5)
#define NTP_SERVER3 "0.nl.pool.ntp.org" // [NtpServer3] Select third NTP server by name or IP address (93.94.224.67) #define NTP_SERVER3 "0.nl.pool.ntp.org" // [NtpServer3] Select third NTP server by name or IP address (93.94.224.67)
// -- Time - Start Daylight Saving Time and timezone offset from UTC in minutes
#define TIME_DST_HEMISPHERE North // Northern Hemisphere
#define TIME_DST_WEEK Last
#define TIME_DST_DAY Sun
#define TIME_DST_MONTH Mar // Last sunday in march
#define TIME_DST_HOUR 2 // at 02:00
#define TIME_DST_OFFSET +120 // +120 minutes
// -- Time - Start Standard Time and timezone offset from UTC in minutes
#define TIME_STD_HEMISPHERE North // Northern Hemisphere
#define TIME_STD_WEEK Last
#define TIME_STD_DAY Sun
#define TIME_STD_MONTH Oct // Last sunday in october
#define TIME_STD_HOUR 3 // at 03:00
#define TIME_STD_OFFSET +60 // +60 minutes
// -- Location ------------------------------------ // -- Location ------------------------------------
#define LATITUDE 48.858360 // [Latitude] Your location to be used with sunrise and sunset #define LATITUDE 48.858360 // [Latitude] Your location to be used with sunrise and sunset
#define LONGITUDE 2.294442 // [Longitude] Your location to be used with sunrise and sunset #define LONGITUDE 2.294442 // [Longitude] Your location to be used with sunrise and sunset
@ -223,12 +239,6 @@
#define WEBSERVER_ADVERTISE // Provide access to webserver by name <Hostname>.local/ #define WEBSERVER_ADVERTISE // Provide access to webserver by name <Hostname>.local/
#define MQTT_HOST_DISCOVERY // Find MQTT host server (overrides MQTT_HOST if found) #define MQTT_HOST_DISCOVERY // Find MQTT host server (overrides MQTT_HOST if found)
// -- Time - Start Daylight Saving Time and timezone offset from UTC in minutes
#define TIME_DST North, Last, Sun, Mar, 2, +120 // Northern Hemisphere, Last sunday in march at 02:00 +120 minutes
// -- Time - Start Standard Time and timezone offset from UTC in minutes
#define TIME_STD North, Last, Sun, Oct, 3, +60 // Northern Hemisphere, Last sunday in october 02:00 +60 minutes
// -- Time ---------------------------------------- // -- Time ----------------------------------------
#define USE_TIMERS // Add support for up to 16 timers (+2k2 code) #define USE_TIMERS // Add support for up to 16 timers (+2k2 code)
#define USE_TIMERS_WEB // Add timer webpage support (+4k5 code) #define USE_TIMERS_WEB // Add timer webpage support (+4k5 code)