coveralls: 
[![Coverage Status](https://coveralls.io/builds/19853184/badge)](https://coveralls.io/builds/19853184)

Coverage decreased (-1.08%) to 98.919% when pulling **f976667194fee3d6f4819e37b19c31f4c860a333 on yhvh:feature/WA-471-add-sleep-summary-to-python-nokia** into **fd4951da6bb51d2e2893339032207b96070c4c79 on orcasgit:master**.

diff --git a/nokia/__init__.py b/nokia/__init__.py
index 007910a..9fcbf45 100644
--- a/nokia/__init__.py
+++ b/nokia/__init__.py
@@ -221,6 +221,10 @@ class NokiaApi(object):
         r = self.request('sleep', 'get', params=kwargs, version='v2')
         return NokiaSleep(r)
 
+    def get_sleep_summary(self, **kwargs):
+        r = self.request('sleep', 'getsummary', params=kwargs, version='v2')
+        return NokiaSleepSummary(r)
+
     def subscribe(self, callback_url, comment, **kwargs):
         params = {'callbackurl': callback_url, 'comment': comment}
         params.update(kwargs)
@@ -319,3 +323,17 @@ class NokiaSleep(NokiaObject):
     def __init__(self, data):
         super(NokiaSleep, self).__init__(data)
         self.series = [NokiaSleepSeries(series) for series in self.series]
+
+
+class NokiaSleepSummarySeries(NokiaObject):
+    def __init__(self, data):
+        _data = data
+        _data.update(_data.pop('data'))
+        super(NokiaSleepSummarySeries, self).__init__(_data)
+        self.timedelta = self.enddate - self.startdate
+
+
+class NokiaSleepSummary(NokiaObject):
+    def __init__(self, data):
+        super(NokiaSleepSummary, self).__init__(data)
+        self.series = [NokiaSleepSummarySeries(series) for series in self.series]

Add sleep summary API
We use this API in work, PR to follow.
diff --git a/tests/__init__.py b/tests/__init__.py
index 9a23d19..7824abd 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -9,6 +9,8 @@ from .test_nokia_measures import TestNokiaMeasures
 from .test_nokia_object import TestNokiaObject
 from .test_nokia_sleep import TestNokiaSleep
 from .test_nokia_sleep_series import TestNokiaSleepSeries
+from .test_nokia_sleep_summary import TestNokiaSleepSummary
+from .test_nokia_sleep_summary_series import TestNokiaSleepSummarySeries
 
 
 def all_tests():
@@ -22,4 +24,6 @@ def all_tests():
     suite.addTest(unittest.makeSuite(TestNokiaObject))
     suite.addTest(unittest.makeSuite(TestNokiaSleep))
     suite.addTest(unittest.makeSuite(TestNokiaSleepSeries))
+    suite.addTest(unittest.makeSuite(TestNokiaSleepSummary))
+    suite.addTest(unittest.makeSuite(TestNokiaSleepSummarySeries))
     return suite
diff --git a/tests/test_nokia_api.py b/tests/test_nokia_api.py
index a5b26f7..85848e4 100644
--- a/tests/test_nokia_api.py
+++ b/tests/test_nokia_api.py
@@ -11,7 +11,9 @@ from nokia import (
     NokiaMeasureGroup,
     NokiaMeasures,
     NokiaSleep,
-    NokiaSleepSeries
+    NokiaSleepSeries,
+    NokiaSleepSummary,
+    NokiaSleepSummarySeries,
 )
 
 try:
@@ -233,6 +235,70 @@ class TestNokiaApi(unittest.TestCase):
                          body['series'][0]['enddate'])
         self.assertEqual(resp.series[1].state, 1)
 
+    def test_get_sleep_summary(self):
+        """
+        Check that get_sleep_summary fetches the appropriate URL, the response looks
+        correct, and the return value is a NokiaSleepSummary object with the
+        correct attributes
+        """
+        body = {
+            'more': False,
+            'series': [
+                {
+                    'data': {
+                        'deepsleepduration': 18660,
+                        'durationtosleep': 0,
+                        'durationtowakeup': 240,
+                        'lightsleepduration': 20220,
+                        'wakeupcount': 1,
+                        'wakeupduration': 720
+                    },
+                    'date': '2018-10-30',
+                    'enddate': 1540897020,
+                    'id': 900363515,
+                    'model': 16,
+                    'modified': 1540897246,
+                    'startdate': 1540857420,
+                    'timezone': 'Europe/London'
+                },
+                {
+                    'data': {
+                        'deepsleepduration': 17040,
+                        'durationtosleep': 360,
+                        'durationtowakeup': 0,
+                        'lightsleepduration': 10860,
+                        'wakeupcount': 1,
+                        'wakeupduration': 540
+                    },
+                    'date': '2018-10-31',
+                    'enddate': 1540973400,
+                    'id': 901269807,
+                    'model': 16,
+                    'modified': 1541020749,
+                    'startdate': 1540944960,
+                    'timezone': 'Europe/London'
+                }
+            ]
+        }
+        self.mock_request(body)
+        resp = self.api.get_sleep_summary()
+        Session.request.assert_called_once_with(
+            'GET',
+            self._req_url('https://wbsapi.withings.net/v2/sleep'),
+            **self._req_kwargs({'action': 'getsummary'})
+        )
+        self.assertEqual(type(resp), NokiaSleepSummary)
+        self.assertEqual(type(resp.series), list)
+        self.assertEqual(len(resp.series), 2)
+        self.assertEqual(type(resp.series[0]), NokiaSleepSummarySeries)
+        self.assertEqual(resp.series[0].model, body['series'][0]['model'])
+        self.assertEqual(resp.series[0].startdate.timestamp,
+                         body['series'][0]['startdate'])
+        self.assertEqual(resp.series[0].enddate.timestamp,
+                         body['series'][0]['enddate'])
+        self.assertEqual(resp.series[0].deepsleepduration,
+                         body['series'][0]['data']['deepsleepduration'])
+
     def test_get_activities(self):
         """
         Check that get_activities fetches the appropriate URL, the response
diff --git a/tests/test_nokia_sleep_summary.py b/tests/test_nokia_sleep_summary.py
new file mode 100644
index 0000000..40ea435
--- /dev/null
+++ b/tests/test_nokia_sleep_summary.py
@@ -0,0 +1,56 @@
+import time
+import unittest
+
+from nokia import NokiaSleepSummary, NokiaSleepSummarySeries
+
+
+class TestNokiaSleepSummary(unittest.TestCase):
+    def test_attributes(self):
+        data = {
+            'more': False,
+            'series': [
+                {
+                    'data': {
+                        'deepsleepduration': 18660,
+                        'durationtosleep': 0,
+                        'durationtowakeup': 240,
+                        'lightsleepduration': 20220,
+                        'wakeupcount': 1,
+                        'wakeupduration': 720
+                    },
+                    'date': '2018-10-30',
+                    'enddate': 1540897020,
+                    'id': 900363515,
+                    'model': 16,
+                    'modified': 1540897246,
+                    'startdate': 1540857420,
+                    'timezone': 'Europe/London'
+                },
+                {
+                    'data': {
+                        'deepsleepduration': 17040,
+                        'durationtosleep': 360,
+                        'durationtowakeup': 0,
+                        'lightsleepduration': 10860,
+                        'wakeupcount': 1,
+                        'wakeupduration': 540
+                    },
+                    'date': '2018-10-31',
+                    'enddate': 1540973400,
+                    'id': 901269807,
+                    'model': 16,
+                    'modified': 1541020749,
+                    'startdate': 1540944960,
+                    'timezone': 'Europe/London'
+                }
+            ]
+        }
+        sleep = NokiaSleepSummary(data)
+        self.assertEqual(sleep.series[0].model, data['series'][0]['model'])
+        self.assertEqual(type(sleep.series), list)
+        self.assertEqual(len(sleep.series), 2)
+        self.assertEqual(type(sleep.series[0]), NokiaSleepSummarySeries)
+        self.assertEqual(sleep.series[0].startdate.timestamp,
+                         data['series'][0]['startdate'])
+        self.assertEqual(sleep.series[0].enddate.timestamp,
+                         data['series'][0]['enddate'])
diff --git a/tests/test_nokia_sleep_summary_series.py b/tests/test_nokia_sleep_summary_series.py
new file mode 100644
index 0000000..83021cc
--- /dev/null
+++ b/tests/test_nokia_sleep_summary_series.py
@@ -0,0 +1,48 @@
+import time
+import unittest
+
+from datetime import timedelta
+from nokia import NokiaSleepSummarySeries
+
+
+class TestNokiaSleepSummarySeries(unittest.TestCase):
+    def test_attributes(self):
+        data = {
+            'data':  {
+                'deepsleepduration': 18660,
+                'durationtosleep': 0,
+                'durationtowakeup': 240,
+                'lightsleepduration': 20220,
+                'wakeupcount': 1,
+                'wakeupduration': 720,
+            },
+            'date': '2018-10-30',
+            'enddate': 1540897020,
+            'id': 900363515,
+            'model': 16,
+            'modified': 1540897246,
+            'startdate': 1540857420,
+            'timezone': 'Europe/London',
+        }
+        flat_data = {
+            'deepsleepduration': 18660,
+            'durationtosleep': 0,
+            'durationtowakeup': 240,
+            'lightsleepduration': 20220,
+            'wakeupcount': 1,
+            'wakeupduration': 720,
+            'date': '2018-10-30',
+            'enddate': 1540897020,
+            'id': 900363515,
+            'model': 16,
+            'modified': 1540897246,
+            'startdate': 1540857420,
+            'timezone': 'Europe/London',
+        }
+
+        series = NokiaSleepSummarySeries(data)
+        self.assertEqual(type(series), NokiaSleepSummarySeries)
+        self.assertEqual(series.startdate.timestamp, flat_data['startdate'])
+        self.assertEqual(series.data, flat_data)
+        self.assertEqual(series.enddate.timestamp, flat_data['enddate'])
+        self.assertEqual(series.timedelta, timedelta(seconds=39600))

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-mock tox
3.6
requirements/base.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
arrow==0.12.1
attrs==22.2.0
certifi==2021.5.30
chardet==3.0.4
cheroot==10.0.1
CherryPy==17.3.0
contextlib2==21.6.0
coverage==6.2
distlib==0.3.9
filelock==3.4.1
idna==2.7
importlib-metadata==4.8.3
importlib-resources==5.4.0
iniconfig==1.1.1
jaraco.functools==3.4.0
more-itertools==8.14.0
-e git+https://github.com/orcasgit/python-nokia.git@fd4951da6bb51d2e2893339032207b96070c4c79#egg=nokia
oauthlib==3.2.2
packaging==21.3
platformdirs==2.4.0
pluggy==1.0.0
portend==3.0.0
py==1.11.0
pyparsing==3.1.4
pytest==7.0.1
pytest-cov==4.0.0
pytest-mock==3.6.1
python-dateutil==2.9.0.post0
pytz==2025.2
requests==2.19.1
requests-oauth==0.4.1
requests-oauthlib==1.0.0
six==1.17.0
tempora==4.1.2
toml==0.10.2
tomli==1.2.3
tox==3.28.0
typing_extensions==4.1.1
urllib3==1.23
virtualenv==20.17.1
zc.lockfile==2.0
zipp==3.6.0

name: python-nokia
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - arrow==0.12.1
      - attrs==22.2.0
      - chardet==3.0.4
      - cheroot==10.0.1
      - cherrypy==17.3.0
      - contextlib2==21.6.0
      - coverage==6.2
      - distlib==0.3.9
      - filelock==3.4.1
      - idna==2.7
      - importlib-metadata==4.8.3
      - importlib-resources==5.4.0
      - iniconfig==1.1.1
      - jaraco-functools==3.4.0
      - more-itertools==8.14.0
      - oauthlib==3.2.2
      - packaging==21.3
      - platformdirs==2.4.0
      - pluggy==1.0.0
      - portend==3.0.0
      - py==1.11.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytest-cov==4.0.0
      - pytest-mock==3.6.1
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - requests==2.19.1
      - requests-oauth==0.4.1
      - requests-oauthlib==1.0.0
      - six==1.17.0
      - tempora==4.1.2
      - toml==0.10.2
      - tomli==1.2.3
      - tox==3.28.0
      - typing-extensions==4.1.1
      - urllib3==1.23
      - virtualenv==20.17.1
      - zc-lockfile==2.0
      - zipp==3.6.0
prefix: /opt/conda/envs/python-nokia

tests/test_nokia_activity.py::TestNokiaActivity::test_attributes tests/test_nokia_api.py::TestNokiaApi::test_attribute_defaults tests/test_nokia_api.py::TestNokiaApi::test_attributes tests/test_nokia_api.py::TestNokiaApi::test_get_activities tests/test_nokia_api.py::TestNokiaApi::test_get_credentials tests/test_nokia_api.py::TestNokiaApi::test_get_measures tests/test_nokia_api.py::TestNokiaApi::test_get_measures_lastupdate_arrow tests/test_nokia_api.py::TestNokiaApi::test_get_measures_lastupdate_date tests/test_nokia_api.py::TestNokiaApi::test_get_measures_lastupdate_datetime tests/test_nokia_api.py::TestNokiaApi::test_get_sleep tests/test_nokia_api.py::TestNokiaApi::test_get_sleep_summary tests/test_nokia_api.py::TestNokiaApi::test_get_user tests/test_nokia_api.py::TestNokiaApi::test_is_subscribed tests/test_nokia_api.py::TestNokiaApi::test_list_subscriptions tests/test_nokia_api.py::TestNokiaApi::test_request tests/test_nokia_api.py::TestNokiaApi::test_request_error tests/test_nokia_api.py::TestNokiaApi::test_request_params tests/test_nokia_api.py::TestNokiaApi::test_set_token tests/test_nokia_api.py::TestNokiaApi::test_set_token_refresh_cb tests/test_nokia_api.py::TestNokiaApi::test_subscribe tests/test_nokia_api.py::TestNokiaApi::test_unsubscribe tests/test_nokia_sleep_summary.py::TestNokiaSleepSummary::test_attributes tests/test_nokia_sleep_summary_series.py::TestNokiaSleepSummarySeries::test_attributes
nokia/__init__.py
nokia/__init__.py