• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Datetime
#1
I've updated to the latest dev code and added datetime in my config.json.

Code:
"datetime": {
                        "name": "Datum & Zeit",
                        "protocol": [ "datetime" ],
                        "id": [{
                                "longitude": "7.262925",
                                "latitude": "49.415133",
                    "ntp-server": "0.north-america.pool.ntp.org"
                        }],
                        "year": 2014,
                        "month": 4,
                        "day": 20,
                        "hour": 8,
                        "minute": 53,
                        "second": 55
                },

Now after starting pilight service, this error occurs

Code:
root@raspberrypi:/home/pi# service pilight start
[....] Starting : pilight[Apr 20 08:54:51:753014] pilight-daemon: ERROR: setting #3 "id" of "datetime", invalid
failed!

Also in the log is only this

Code:
[ Apr 20 09:00:04:41994] pilight-daemon: INFO: version 3.0, commit v3.0-118-g86324d3


lcd4linux
 
Reply
#2
Wiki is updated.
 
Reply
#3
I haved installed version 4.0 to use ELRO HE875 switches. Works fine
with protocol elro_he.
I added protocol datetime in config.json on my raspberry.
Date and time show up in the web-gui, but time is wrong to my timzone
Europe/Berlin on the raspi.
actual local time is for example 22:23 but the web-gui shows 23:23.

the config section is:
Code:
"datetime": {
                        "name": "Datum / Uhrzeit",
                        "protocol": [ "datetime" ],
                        "id": [{
                                "longitude": "13.4060912",
                                "latitude": "52.519171",
                                "ntpserver": "ptbtime1.ptb.de"
                        }],
                        "gui-datetime-format": "DD.MM.YYYY HH:mm:ss",
                        "year": 2014,
                        "month": 5,
                        "day": 8,
                        "hour": 21,
                        "minute": 27,
                        "second": 37
                },
the ntpserver is reachable with ping from my raspi:
Code:
root@raspberrypi:/etc/pilight# ping ptbtime1.ptb.de
PING ptbtime1.ptb.de (192.53.103.108) 56(84) bytes of data.
64 bytes from ptbtime1.ptb.de (192.53.103.108): icmp_req=1 ttl=56
time=14.7 ms
64 bytes from ptbtime1.ptb.de (192.53.103.108): icmp_req=2 ttl=56
time=13.7 ms
64 bytes from ptbtime1.ptb.de (192.53.103.108): icmp_req=3 ttl=56
time=15.1 ms
^C
--- ptbtime1.ptb.de ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 13.795/14.581/15.173/0.579 ms
seems that timzone-data in tzdata.json in /etc/pilight is not correct
for daylight-saving for timezone Europe/Berlin

any idea how to get the correct local time in the web-gui of pilight ?
 
Reply
#4
I made a small standalone script to test my library. This is what it says:
Code:
[...]
#include "json.h"
#include "datetime.h"

int main(void) {
    char *tz = coord2tz(52.519171, 13.4060912);
    char utc[] = "Europe/London";
    char *p = utc;
    printf("\nTimezone: %s\nDST: %d\nOffset: %d\n", tz, isdst(tz), tzoffset(p, tz));
}

Code:
loading timezone database...
Timezone: Europe/Berlin
DST: 1
Offset: 1
So the timezone is recognized correctly, and it says that DST is active and the timezone is +1 CEST
 
Reply
#5
You're right, i totally forgot to include it in the package. Will do right away Smile

Reinstall by using:
Code:
sudo apt-get update
sudo apt-get install --reinstall pilight
 
Reply
#6
Thanks for the quick follow up CurlyMo.
After reinstall and restoring the settings.json and hardware.json the daemon starts without error.

The displayed time in the webgui is wrong 18:45 instead of 20:45. Looks I have a similar problem now as det@pi reported.

time on my RPI seems to be OK:
Code:
pi@raspbmc:/etc/pilight$ date
Wed May 14 20:49:02 CEST 2014
pi@raspbmc:/etc/pilight$ sudo su
root@raspbmc:/etc/pilight# date
Wed May 14 20:49:14 CEST 2014

Is there any way to debug?
 
Reply
#7
it took me some time to figure out it is caused by a bug.
it appeared longitude and latitude are switched.

This sample program proves:
Code:
[...]
#include "json.h"
#include "datetime.h"

int main(void) {
    double longitude = 13.4060912;
    double latitude = 52.519171;
    char *tz = coord2tz(longitude, latitude);
    char utc[] = "Europe/London";
    char *p = utc;
    printf("\nTimezone: %s\nDST: %d\nOffset: %d\n", tz, isdst(tz), tzoffset(p, >
}

I fixed it in datetime.c by swapping x and y:
Code:
int y = (int)round(latitude*(int)pow(10, PRECISION));
int x = (int)round(longitude*(int)pow(10, PRECISION));

As workaround det@pi can interchange the coordinates in config.json

I am not familiar with committing in git and will spent some time on that later. I suppose CurlyMo will review and make sure it will work in a next release.
 
Reply
#8
I had the same problem. Time was 2 hours off for my timezone and DST.
But I didn't change datetime.c but interchanged longitude and latitude values in the config.json file. That also solves the problem.
 
Reply
#9
Hello all on this wonderfull christmasday,

Since the latest version my datetime won't work anymore...

My config is no changed since the upgrade (nightly from last week) and set like:
Code:
"datetime": {
                        "protocol": [ "datetime" ],
                        "id": [{
                                "longitude": "5.0472832",
                                "latitude": "52.8421337",
                                "ntpserver": "0.nl.pool.ntp.org"
                        }],
                        "year": 2014,
                        "month": 12,
                        "day": 25,
                        "hour": 15,
                        "minute": 56,
                        "second": 8
                },

The error I got isn't quite supportive with:
Code:
pilight-daemon: ERROR: config device setting #2 "id" of "datetime", invalid

Any idea's?

Best regards,

Netopyr
 
Reply
#10
https://github.com/pilight/pilight/commi...edea64c115
 
Reply
  


Forum Jump:


Browsing: 1 Guest(s)