Repository navigation
Fitbit stops updating #2083
Copy link
Copy link
Closed
Description
Make sure you run the latest version before reporting an issue. Feature requests should go in the forum: https://community.home-assistant.io/c/feature-requests
Home Assistant release (hass --version):
0.20.dev0
Python release (python3 --version):
Component/platform:
fitbit
Description of problem:
Fitbit sensor stops updating 2 hours after hass has started.
Two different tracebacks provided.
Expected:
Fitbit updating sensors.
Problem-relevant configuration.yaml entries and steps to reproduce:
Traceback (if applicable):
Traceback (most recent call last):
File "/srv/hass/src/home-assistant/homeassistant/core.py", line 801, in job_handler
func(arg)
File "/srv/hass/src/home-assistant/homeassistant/helpers/event.py", line 179, in pattern_time_change_listener
action(now)
File "/srv/hass/src/home-assistant/homeassistant/helpers/entity_component.py", line 191, in _update_entity_states
entity.update_ha_state(True)
File "/srv/hass/src/home-assistant/homeassistant/helpers/entity.py", line 145, in update_ha_state
self.update()
File "/srv/hass/src/home-assistant/homeassistant/util/__init__.py", line 289, in wrapper
result = method(*args, **kwargs)
File "/srv/hass/src/home-assistant/homeassistant/components/sensor/fitbit.py", line 365, in update
@Throttle(MIN_TIME_BETWEEN_UPDATES)
File "/media/Server/HomeAssistant/deps/fitbit/api.py", line 515, in time_series
return self.make_request(url)
File "/media/Server/HomeAssistant/deps/fitbit/api.py", line 227, in make_request
response = self.client.make_request(*args, **kwargs)
File "/media/Server/HomeAssistant/deps/fitbit/api.py", line 68, in make_request
response = self._request(method, url, data=data, auth=auth, **kwargs)
File "/media/Server/HomeAssistant/deps/fitbit/api.py", line 55, in _request
return self.session.request(method, url, **kwargs)
File "/srv/hass/lib/python3.5/site-packages/requests/sessions.py", line 461, in request
prep = self.prepare_request(req)
File "/srv/hass/lib/python3.5/site-packages/requests/sessions.py", line 394, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "/srv/hass/lib/python3.5/site-packages/requests/models.py", line 299, in prepare
self.prepare_auth(auth, url)
File "/srv/hass/lib/python3.5/site-packages/requests/models.py", line 494, in prepare_auth
r = auth(self)
File "/media/Server/HomeAssistant/deps/requests_oauthlib/oauth2_auth.py", line 35, in __call__
http_method=r.method, body=r.body, headers=r.headers)
File "/media/Server/HomeAssistant/deps/oauthlib/oauth2/rfc6749/clients/base.py", line 194, in add_token
raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired)Traceback (most recent call last):
File "/srv/hass/src/home-assistant/homeassistant/core.py", line 801, in job_handler
func(arg)
File "/srv/hass/src/home-assistant/homeassistant/helpers/event.py", line 179, in pattern_time_change_listener
action(now)
File "/srv/hass/src/home-assistant/homeassistant/helpers/entity_component.py", line 191, in _update_entity_states
entity.update_ha_state(True)
File "/srv/hass/src/home-assistant/homeassistant/helpers/entity.py", line 145, in update_ha_state
self.update()
File "/srv/hass/src/home-assistant/homeassistant/util/__init__.py", line 289, in wrapper
result = method(*args, **kwargs)
File "/srv/hass/src/home-assistant/homeassistant/components/sensor/fitbit.py", line 365, in update
response = self.client.time_series(self.resource_type, period="7d")
File "/media/Server/HomeAssistant/deps/fitbit/api.py", line 515, in time_series
return self.make_request(url)
File "/media/Server/HomeAssistant/deps/fitbit/api.py", line 227, in make_request
response = self.client.make_request(*args, **kwargs)
File "/media/Server/HomeAssistant/deps/fitbit/api.py", line 68, in make_request
response = self._request(method, url, data=data, auth=auth, **kwargs)
File "/media/Server/HomeAssistant/deps/fitbit/api.py", line 55, in _request
return self.session.request(method, url, **kwargs)
File "/srv/hass/lib/python3.5/site-packages/requests/sessions.py", line 461, in request
prep = self.prepare_request(req)
File "/srv/hass/lib/python3.5/site-packages/requests/sessions.py", line 394, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "/srv/hass/lib/python3.5/site-packages/requests/models.py", line 299, in prepare
self.prepare_auth(auth, url)
File "/srv/hass/lib/python3.5/site-packages/requests/models.py", line 494, in prepare_auth
r = auth(self)
File "/media/Server/HomeAssistant/deps/requests_oauthlib/oauth2_auth.py", line 35, in __call__
http_method=r.method, body=r.body, headers=r.headers)
File "/media/Server/HomeAssistant/deps/oauthlib/oauth2/rfc6749/clients/base.py", line 194, in add_token
raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired)
Additional info:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Priority
None yet
Activity
robbiet480 commentedon May 16, 2016
The fitbit package should be taking care of auto updating the token, but it doesn't appear it is. Will look into it soon-ish.
roflmao commentedon Jun 20, 2016
I also have this problem.
tchellomello commentedon Jul 12, 2016
Hello folks,
I'm also hitting the same problem over here.
However when restarting the HASS, the fitbit component is able to get a new token and then it works as expected.
Looking at https://community.home-assistant.io/t/fitbit-error/1087/17 we can see a patch that seemed to fix this issue, however I checked the python-fitbit code https://github.com/orcasgit/python-fitbit and the PR (orcasgit/python-fitbit#92) is not implemented on my local library. We can see the patch on shimeez branch at https://github.com/shimeez/python-fitbit/commit/762b7c6175f7efaaa06055eff5b63a009f9131e8
I've updated my local fitbit/api.py code on my devel box with shimeez's patch and I'll report the results on the next 2 days.
If that works, we might need to cherrypick the patch as well.
Best Regards,
mmello
robbiet480 commentedon Jul 12, 2016
@tchellomello Thanks for your research on this. Let me know what you find and if you come back with positive news i'll get the patch in.
tchellomello commentedon Jul 13, 2016
@robbiet480 You are very welcome teamwork++.
The good news is that it's been running for almost a day and the fitbit.conf file and the token got refreshed as expected. I had no tracebacks and the frontend is reporting the data as expected.
Yes, let's backport/import the fix and we should be fine. Thanks @turbokongen and @roflmao for reporting the issue.
@robbiet480 Please let me know if you need help. Are you planning to create a local branch for that or re-open a change request for @orcasgit ?
Thanks guys.
~ mmello
tchellomello commentedon Aug 28, 2016
I spoke with @robbiet480 and I'll work to submit a patch to the official project and I'll paste the information here.
tchellomello commentedon Aug 28, 2016
PR submitted to python-fitbit
orcasgit/python-fitbit#97
tchellomello commentedon Sep 6, 2016
PR #3244 created since upstream patches for python-fitbit were merged
orcasgit/python-fitbit#97
orcasgit/python-fitbit#99