Skip to content

fitbit.exceptions.HTTPServerError when setting alarm. #124

Description

@shaunakg

I'm getting an exception from python with the following code:

# authorization code goes before this, etc. Note that fb = fitbit
reccurance = ['MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY','SATURDAY','SUNDAY']
device_id = '123456789' # In the actual program this is a real device ID
fb.add_alarm(device_id, alarm_time, reccurance, recurring=False, enabled=True, label='Find Device Alarm', snooze_length=None, snooze_count=None, vibe='DEFAULT')

I've checked datetime formats and everything, but it still gives me the following output:

Traceback (most recent call last):
  File "PATH\TO\MY\PROGRAM\main.py", line 29, in <module>
    fb.add_alarm(device_id, alarm_time, reccurance, recurring=False, enabled=True, label='Find Device Alarm', snooze_length=None, snooze_count=None, vibe='DEFAULT')
  File "C:\Users\somebody\AppData\Local\Programs\Python\Python36-32\lib\site-packages\fitbit\api.py", line 716, in add_alarm
    return self.make_request(url, data=data, method="POST")
  File "C:\Users\somebody\AppData\Local\Programs\Python\Python36-32\lib\site-packages\fitbit\api.py", line 223, in make_request
    response = self.client.make_request(*args, **kwargs)
  File "C:\Users\somebody\AppData\Local\Programs\Python\Python36-32\lib\site-packages\fitbit\api.py", line 99, in make_request
    exceptions.detect_and_raise_error(response)
  File "C:\Users\somebody\AppData\Local\Programs\Python\Python36-32\lib\site-packages\fitbit\exceptions.py", line 94, in detect_and_raise_error
    raise HTTPServerError(response)
fitbit.exceptions.HTTPServerError: An error occurred with the Fitbit Web API while processing the request. Error id: A29E0282:7651_A92D91CB:01BB_59D3331F_4A63FA7:3D47

Any help with this? My program is just to set an alarm 20 seconds after the current time.

NB: Other commands like get_devices() and get_alarms() do work.

Activity

  1. LEXmono commented on Oct 21, 2017

    @LEXmono

    You are not including the timezone in your request. Per the code, alarm_time should be a timezone aware datetime object.

    You can do this with another module called pytz.

    import pytz

    tz = pytz.timezone("US/Eastern")
    alarm_time = datetime.datetime(2017, 10, 21, 16, 0)
    alarm_time = tz.localize(alarm_time, is_dst=None)

    reccurance = ['MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY','SATURDAY','SUNDAY']
    device_id = '########' # In the actual program this is a real device ID
    client.add_alarm(device_id, alarm_time, reccurance, recurring=False, enabled=True, label='Find Device Alarm', snooze_length=None, snooze_count=None, vibe='DEFAULT')

    {'trackerAlarm': {'alarmId': ##########,
    'deleted': False,
    'enabled': True,
    'label': 'Find Device Alarm',
    'recurring': False,
    'snoozeCount': 1,
    'snoozeLength': 9,
    'syncedToDevice': False,
    'time': '16:00-04:00',
    'vibe': 'DEFAULT',
    'weekDays': []}}

  2. shaunakg commented on Oct 23, 2017

    @shaunakg
    Author

    Thank you for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions