Hi,
I want to synchronize the time on a NodeMCU8266 (*) with the time Domoticz shows in the upper left corner of the dashboard page. This way I can avoid issues with summer and winter time, which are quite difficult to manage when using an NTP-server as source.
Of course I can synchronize with a CustomEvent every X hours, but then I have to maintain code on both the NodeMCU and in Domoticz. Is a JSON call available that I can use to get the time? I looked for it in the API/JSON guide but didn't find it. With a JSON call I only have to maintain the NodeMCU side since the Domoticz side is taken care of by Domoticz itself.
Thanks,
Peter
(*) Great stuff to combine with Domoticz by the way!
Retrieve Domoticz time in API/JSON call [Solved]
Moderator: leecollings
-
- Posts: 374
- Joined: Friday 23 May 2014 7:55
- Target OS: Linux
- Domoticz version: 2022.1
- Location: Saint Pierre de Jards
- Contact:
Re: Retrieve Domoticz time in API/JSON call
This should do it:
Code: Select all
/json.htm?type=command¶m=getSunRiseSet
Debian buster on NUC and three RPi with buster.
-
- Posts: 81
- Joined: Sunday 04 January 2015 0:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest-1
- Location: /dev/null
- Contact:
Re: Retrieve Domoticz time in API/JSON call
Not sure why you post this in dzVents if you want to call the API but you could use
Although you are not interested in sunrise or sunset there is also a 'ServerTime' attribute with the current time.
--Gerard
Code: Select all
/json.htm?type=command¶m=getSunRiseSet
--Gerard
-
- Posts: 93
- Joined: Saturday 07 November 2020 21:41
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Contact:
Re: Retrieve Domoticz time in API/JSON call [SOLVED]
Hi all,
I found it. In the JSON/API guide there's a JSON commandstring /json.htm?type=command¶m=getSunRiseSet. In addition to the sunrise and sunset times it also gives the ServerTime, which is what I was looking for. I then tried the commandstring /json.htm?type=command¶m=getServerTime and that worked to. The response from Domoticz was:
{
"ServerTime" : "2021-01-13 22:00:37",
"status" : "OK",
"title" : "getServerTime"
}
I hope this undocumented feature may exist until forever
Peter
I found it. In the JSON/API guide there's a JSON commandstring /json.htm?type=command¶m=getSunRiseSet. In addition to the sunrise and sunset times it also gives the ServerTime, which is what I was looking for. I then tried the commandstring /json.htm?type=command¶m=getServerTime and that worked to. The response from Domoticz was:
{
"ServerTime" : "2021-01-13 22:00:37",
"status" : "OK",
"title" : "getServerTime"
}
I hope this undocumented feature may exist until forever

Peter
-
- Posts: 93
- Joined: Saturday 07 November 2020 21:41
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Contact:
Re: Retrieve Domoticz time in API/JSON call [Solved]
Hi Gerard and Number 8,
Our posts crossed each other.
Peter
Our posts crossed each other.
Peter
Who is online
Users browsing this forum: No registered users and 0 guests