arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
22.12k stars 4.79k forks source link

Timezone with half an hour? #2684

Closed OmgImAlexis closed 6 years ago

OmgImAlexis commented 6 years ago

Is there currently any way to set a timezone with 30 min increments? I live in South Australia which uses +930/+1030 depending on DST.

Jason2866 commented 6 years ago

See #1192

OmgImAlexis commented 6 years ago

I tried that and it doesn't seem to be working. The current time should be 9:52AM on the 11th of May 2018.

02:21:28 MQT: home/alexis/dht/LWT = Online (retained)
02:21:28 MQT: home/alexis/dht/cmnd/POWER = 
02:21:28 MQT: Subscribe to home/alexis/dht/cmnd/#
02:21:28 MQT: home/alexis/dht/INFO1 = {"Module":"Generic","Version":"5.13.1a","FallbackTopic":"DVES_114FF8","GroupTopic":"sonoffs"}
02:21:28 MQT: home/alexis/dht/INFO2 = {"WebServerMode":"Admin","Hostname":"sensor-4088","IPAddress":"192.168.2.10"}
02:21:28 MQT: home/alexis/dht/INFO3 = {"RestartReason":"External System"}
02:21:36 MQT: home/alexis/dht/STATE = {"Time":"2018-05-11T02:21:36","Uptime":"0T00:00:13","Vcc":3.065,"Wifi":{"AP":1,"SSId":"Bella","RSSI":96,"APMac":"C8:BC:C8:DC:2C:5A"}}
02:21:36 DHT: Received 02, 5D, 00, 96, F5 =? F5
02:21:36 MQT: home/alexis/dht/SENSOR = {"Time":"2018-05-11T02:21:36","AM2301":{"Temperature":15.0,"Humidity":60.5},"TempUnit":"C"} (retained)
02:21:48 WIF: Checking connection...
02:21:48 WIF: Connected
02:21:51 CMD: timezone
02:21:51 RSL: Received Topic /timezone, Data Size 0, Data 
02:21:51 RSL: Group 0, Index 1, Command TIMEZONE, Data 
02:21:51 MQT: home/alexis/dht/RESULT = {"Timezone":99}
ascillato commented 6 years ago

Hi,

I tested your case and works without problems.

I just change on _userconfig.h file the following:

// -- Time - Start Daylight Saving Time and timezone offset from UTC in minutes
#define TIME_DST  South, First, Sun, Oct, 2, +630

// -- Time - Start Standard Time and timezone offset from UTC in minutes
#define TIME_STD  South, First, Sun, Apr, 3, +570

I compile it and flash to a Sonoff.

Then, on the console I write timezone 99.

Console Output:

00:00:02 WIF: Intentando conectar...
00:00:03 WIF: Probando conección...
00:00:03 WIF: Conectado
00:00:03 HTP: Servidor web activo en sonoff-1757 con dirección IP 192.168.1.2
00:00:03 KNX: Iniciar
00:00:03 HTP: Consola
00:00:04 RSL: INFO1 = {"Module":"Generic","Version":"5.13.1a","FallbackTopic":"DVES_F7A6DD","GroupTopic":"sonoffs"}
00:00:04 RSL: INFO2 = {"WebServerMode":"Admin","Hostname":"sonoff-1757","IPAddress":"192.168.1.2"}
00:00:04 RSL: INFO3 = {"RestartReason":"External System"}
00:00:06 RSL: RESULT = {"POWER":"OFF"}
00:00:06 RSL: POWER = OFF
00:00:10 APP: (UTC) Fri May 11 03:22:00 2018, (DST) Sun Oct 07 02:00:00 2018, (STD) Sun Apr 01 03:00:00 2018
13:52:03 RSL: STATE = {"Time":"2018-05-11T13:52:03","Uptime":"0T00:00:12","Vcc":2.785,"POWER":"OFF","Wifi":{"AP":1,"SSId":"NetWireless","RSSI":70,"APMac":"18:D6:C7:80:38:2C"}}
13:52:16 WIF: Probando conección...
13:52:16 WIF: Conectado

Time checked also using the website https://24timezones.com/

Your location has UTC +10h 30m, so if UTC=03:22:00, your time=13:52:00

Your DST is +10h30m = +630minutes

Please, use the above settings on the file _userconfig.h

Hope this solve your issue.

OmgImAlexis commented 6 years ago

Okay that's the issue. I was adding +9.5 not +930. My bad.

OmgImAlexis commented 6 years ago

So I still can't get this to work.

I'm not currently in DST time yet when I change TIME_STD nothing happens but if I change TIME_DST the time updates.

Even if I set the TIME_STD to 0 it won't change.

// -- Time - Start Daylight Saving Time and timezone offset from UTC in minutes
#define TIME_DST  South, First, Sun, Oct, 2, +570

// -- Time - Start Standard Time and timezone offset from UTC in minutes
#define TIME_STD  South, First, Sun, Apr, 3, +510
OmgImAlexis commented 6 years ago

My timezone is +930 normally with +1030 in DST. I'm also in the southern hemisphere.

According to Wikipedia my DST starts on the first Sunday in October and ends on the first Sunday in April.

ascillato commented 6 years ago

Hi,

You are right! It is giving wrong time for you.

Looking at https://24timezones.com/world_directory/time_in_adelaide.php:

image

// -- Time - Start Daylight Saving Time and timezone offset from UTC in minutes
#define TIME_DST  South, First, Sun, Oct, 2, +630     // ( 630 minutes / 60 minutes ) = +10.5 hours

// -- Time - Start Standard Time and timezone offset from UTC in minutes
#define TIME_STD  South, First, Sun, Apr, 3, +570      // ( 570 minutes / 60 minutes ) = +9.5 hours

Results in:

00:00:06 APP: (UTC) Sat May 12 00:21:06 2018, (DST) Sun Oct 07 02:00:00 2018, (STD) Sun Apr 01 03:00:00 2018
10:51:12 RSL: STATE = {"Time":"2018-05-12T10:51:12","Uptime":"0T00:00:12","Vcc":2.788,"POWER":"OFF","Wifi":{"AP":1,"SSId":"NetWireless","RSSI":36,"APMac":"18:D6:C7:80:38:2C"}}
10:51:47 WIF: Checking connection...
10:51:47 WIF: Connected

UTC (00:21) + STD (+9.5hs) = 09:51

But it is resulting in 10:51. That is wrong. It is using DST instead of STD. Should be using STD (starting on 1 APR)


Let's test another country from the Southern Hemisphere: As Argentina don't use DST and STD, I can not put that as example but looking at Chile, they have DST and STD.

image

// -- Time - Start Daylight Saving Time and timezone offset from UTC in minutes
#define TIME_DST  South, Second, Sun, Aug, 0, -180     // ( 180 minutes / 60 minutes ) = -3 hours

// -- Time - Start Standard Time and timezone offset from UTC in minutes
#define TIME_STD  South, Second, Sun, May, 0, -240      // ( 240 minutes / 60 minutes ) = -4 hours

Results in:

00:00:06 APP: (UTC) Sat May 12 01:51:06 2018, (DST) Sun Aug 12 00:00:00 2018, (STD) Sun May 13 00:00:00 2018
22:51:14 RSL: STATE = {"Time":"2018-05-11T22:51:14","Uptime":"0T00:00:14","Vcc":2.784,"POWER":"OFF","Wifi":{"AP":1,"SSId":"NetWireless","RSSI":60,"APMac":"18:D6:C7:80:38:2C"}}
22:51:27 WIF: Checking connection...
22:51:27 WIF: Connected

UTC (01:51) + DST (-3hs) = 22:51

And it is correct. Chile is using DST now.

So, @arendst can you look at this?

ascillato commented 6 years ago

Today Chile changed from DST to STD. But testing Tasmota on a Sonoff stays on DST. Is not correct.

Found that the code that checks for DST and STD for Southern Hemisphere had a bug on RTCSecond() routine in support.ino file

Made the PR #2714 to fix this.

Tested new code with settings for Australia, Chile and Netherlands and works fine.


Chile Example, Tasmota's console:

Sonoff without the proposed fix:

23:59:34 WIF: Probando conección...
23:59:34 WIF: Conectado
23:59:56 WIF: Probando conección...
23:59:56 WIF: Conectado
00:00:18 WIF: Probando conección...
00:00:18 WIF: Conectado
00:00:41 WIF: Probando conección...
00:00:41 WIF: Conectado
00:00:50 RSL: STATE = {"Time":"2018-05-13T00:00:50","Uptime":"0T00:43:47","Vcc":2.784,"POWER":"OFF","Wifi":{"AP":1,"SSId":"NetWireless","RSSI":56,"APMac":"18:D6:C7:80:38:2C"}}
00:01:03 WIF: Probando conección...
00:01:03 WIF: Conectado
00:01:24 WIF: Probando conección...
00:01:24 WIF: Conectado
00:01:42 APP: (UTC) Sun May 13 03:01:42 2018, (DST) Sun Aug 12 00:00:00 2018, (STD) Sun May 13 00:00:00 2018
00:01:46 WIF: Probando conección...
00:01:46 WIF: Conectado
00:02:01 RSL: UPTIME = {"Time":"2018-05-13T00:02:01","Uptime":"0T00:44:58"}
00:02:08 WIF: Probando conección...
00:02:08 WIF: Conectado

Another Sonoff with the proposed fix:

(time equal to https://24timezones.com/world_directory/time_in_santiago.php)

23:59:37 WIF: Probando conección...
23:59:37 WIF: Conectado
23:59:59 WIF: Probando conección...
23:59:59 WIF: Conectado
23:00:13 MQT: tele/living/STATE = {"Time":"2018-05-12T23:00:13","Uptime":"0T00:43:38","Vcc":2.696,"POWER":"OFF","Wifi":{"AP":2,"SSId":"NetWireless","RSSI":62,"APMac":"18:D6:C7:80:38:2C"}}
23:00:20 WIF: Probando conección...
23:00:20 WIF: Conectado
23:00:42 WIF: Probando conección...
23:00:42 WIF: Conectado
23:01:04 WIF: Probando conección...
23:01:04 WIF: Conectado
23:01:25 WIF: Probando conección...
23:01:25 WIF: Conectado
23:01:42 APP: (UTC) Sun May 13 03:01:42 2018, (DST) Sun Aug 12 00:00:00 2018, (STD) Sun May 13 00:00:00 2018
23:01:47 WIF: Probando conección...
23:01:47 WIF: Conectado
23:02:00 MQT: tele/living/UPTIME = {"Time":"2018-05-12T23:02:00","Uptime":"0T00:45:25"}
23:02:09 WIF: Probando conección...
23:02:09 WIF: Conectado
ascillato commented 6 years ago

Hi @OmgImAlexis

The fix was applied. Please, test it again.

And if the problem is solved for you, please close this issue. Thanks.