I have activated the API to get sensor data via APIs.
When I call my API the time reported is one hour behind my German time: “2019-02-05T15:07:16”
The date command a few seconds later reports: “Di 5. Feb 16:07:32 CET 2019”
I have activated the API to get sensor data via APIs.
When I call my API the time reported is one hour behind my German time: “2019-02-05T15:07:16”
The date command a few seconds later reports: “Di 5. Feb 16:07:32 CET 2019”
what’s your timezone? Is it -1? If so, the time under the hood that you are seeing is UTC. All programs under the hood communicate times in UTC. Once presented to the user it converts to the appropriate timezone. So, you’ll need to convert it.
If that’s not your issue, then you need to make sure the timezone is set properly in configuration.yaml as well as on the pi.
Both are “Europe/Berlin”.
$ timedatectl status | grep “Time zone”
Time zone: Europe/Berlin (CET, +0100)
configuration.yaml: time_zone: Europe/Berlin
yep, +1, so that means the time you are viewing is in UTC. Gotta convert it to your timezone. So the question is, what api is it, and what code base are you using to get the time out?
What are you using to read the information? I understand you are using curl, but are you using curl from HA, or are you just doing this from CLI?
I fire this command on my laptop:
curl -X GET -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiI0Y2NiYmQ4OWI0Nzk0MmI4YmY5MDdlMTRkMDE5ZDU4NiIsImV4cCI6MTg2NDczNDU5MiwiaWF0IjoxNTQ5Mzc0NTkyfQ.HNJ_SzmRFbW9LG_4XxNVOHU3c9Zs9gTeS" \
-H "Content-Type: application/json" https://iiiikcna91d84444.myfritz.net/api/states/sensor.cpu_temperature
Token and url changed…
I’m not sure it’s possible to do the conversion in curl. If you aren’t reporting this to any interface and it’s only 1 time curl commands, do you really need to convert it?
If you are using an interface or using it in some other way, what code language are you using for the interface.
I know it may seem like I’m beating around the bush here but there really is an end goal and you aren’t providing the information.
EDIT: Seems like this thread has information about converting a time from a string using only curl.