Skip to content

Commit b835faf

Browse files
author
brentru
committed
adding the clock.json response instead, minimize code on the device
1 parent 705809c commit b835faf

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

adafruit_io/adafruit_io.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -274,14 +274,9 @@ def receive_time(self):
274274
Returns a struct_time from the Adafruit IO Server based on the device's IP address.
275275
https://circuitpython.readthedocs.io/en/latest/shared-bindings/time/__init__.html#time.struct_time
276276
"""
277-
path = self._compose_path('/integrations/time/clock.json{0}'.format(strftime_format))
278-
time_response = self._get(path, return_text=True)
279-
times = time_response.split(' ')
280-
the_date = times[0]
281-
the_time = times[1]
282-
year_day = int(times[2])
283-
week_day = int(times[3])
284-
year, month, mday = [int(x) for x in the_date.split('-')]
285-
the_time = the_time.split('.')[0]
286-
hours, minutes, seconds = [int(x) for x in the_time.split(':')]
287-
return struct_time((year, month, mday, hours, minutes, seconds, week_day, year_day, None))
277+
path = self._compose_path('integrations/time/clock.json')
278+
time = self._get(path)
279+
print(time)
280+
print(time['wday'])
281+
return struct_time((time['year'], time['mon'], time['mday'], time['hour'],
282+
time['min'], time['sec'], time['wday'], time['yday'], time['isdst']))

0 commit comments

Comments
 (0)