Fixed Fitbit resting heart rate attribute (#3835)

* Fixed Fitbit restingHeartRate field to grab the correct field from dictionary

In [31]: r['activities-heart'][-1].get('value')
Out[31]:
{'customHeartRateZones': [],
 'heartRateZones': [{'caloriesOut': 126.18348,
   'max': 94,
   'min': 30,
   'minutes': 67,
   'name': 'Out of Range'},
  {'caloriesOut': 27.21339,
   'max': 131,
   'min': 94,
   'minutes': 5,
   'name': 'Fat Burn'},
  {'caloriesOut': 0, 'max': 159, 'min': 131, 'minutes': 0, 'name': 'Cardio'},
  {'caloriesOut': 0, 'max': 220, 'min': 159, 'minutes': 0, 'name': 'Peak'}],
 'restingHeartRate': 69}

In [32]: r['activities-heart'][-1].get('value').get('restingHeartRate')
Out[32]: 69

* Renamed sensor to Resting Heart Rate to match it

* Fixed lint style
This commit is contained in:
Marcelo Moreira de Mello 2016-10-13 12:22:05 -04:00 committed by Paulus Schoutsen
parent 9a0bb62654
commit 6330d9cde6

View File

@ -359,6 +359,8 @@ class FitbitSensor(Entity):
pretty_resource = pretty_resource.title()
if pretty_resource == 'Body Bmi':
pretty_resource = 'BMI'
elif pretty_resource == 'Heart':
pretty_resource = 'Resting Heart Rate'
self._name = pretty_resource
unit_type = FITBIT_RESOURCES_LIST[self.resource_type]
if unit_type == "":
@ -403,7 +405,8 @@ class FitbitSensor(Entity):
response = self.client.time_series(self.resource_type, period='7d')
self._state = response[container][-1].get('value')
if self.resource_type == 'activities/heart':
self._state = response[container][-1].get('restingHeartRate')
self._state = response[container][-1]. \
get('value').get('restingHeartRate')
config_contents = {
ATTR_ACCESS_TOKEN: self.client.client.token['access_token'],
ATTR_REFRESH_TOKEN: self.client.client.token['refresh_token'],