Skip to main content

SleepIQ API for Python

Project description

Sleepyq is an library for accessing the SleepIQ API from Python. SleepIQ is an addon for SleepNumber beds.

To install:

python3 -m pip install sleepyq

To get started using the library, here’s the full usage:

>>> from sleepyq import Sleepyq
>>> from pprint import pprint
>>>
>>> client = Sleepyq('your-login', 'your-password')
>>> client.login()
>>> pprint(client.sleepers())
>>> pprint(client.beds())
>>> pprint(client.bed_family_status())
>>> client.set_lights(bedNumber, lightNumber, setting)
>>> pprint(client.get_lights(bedNumber, lightNumber))
>>> client.preset(bedNumber, preset, side, slowSpeed=False)
>>> client.set_sleepnumber(bedNumber, side, sleepnumber)
>>> client.set_favsleepnumber(bedNumber, side, sleepnumber)
>>> pprint(client.get_favsleepnumber(bedNumber))
>>> client.stop_motion(bedNumber, side)
>>> client.stop_pump(bedNumber)
>>> pprint(client.foundation_status(bedNumber))
>>> pprint(client.foundation_system(bedNumber))
>>> pprint(client.foundation_features(bedNumber))

The API is undocumented, so this library does not make much attempt to structure the data from the API into objects.

Development Notes

The SleepIQ API was announced at CES 2016 but there has yet to be any public documentation.

https://sleepiq.sleepnumber.com appears to use the SleepIQ API internally, and methods here were written based on observing use of the site with Chrome Developer Tools and by running the Android app through a proxy. There was also prior art at https://github.com/erichelgeson/sleepiq (the API has changed since then) and https://github.com/natecj/sleepiq-php

The first request to happen is to login. This returns a key (_k) that needs to be used on subsequent requests as a parameter. Subsequent requests also need to be part of the same ‘session’, since those calls expect some cookies to be set.

Todo

  • Error check response for non-200 code, or errors returned as JSON

  • Explore API more. There are a few more API calls out there, like updating profile, modifying sleep for previous night, but they seem less immediately useful for automation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sleepyq-0.7.tar.gz (4.4 kB view details)

Uploaded Source

File details

Details for the file sleepyq-0.7.tar.gz.

File metadata

  • Download URL: sleepyq-0.7.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.8.1 pkginfo/1.2.1 requests/2.12.4 setuptools/33.1.1 requests-toolbelt/0.7.0 clint/0.5.1 CPython/3.5.3 Linux/4.4.0-17134-Microsoft

File hashes

Hashes for sleepyq-0.7.tar.gz
Algorithm Hash digest
SHA256 6bf70b35369dbe15c8b0369598064e74caf9f9424fa713b6c20cb4f56667779e
MD5 c30b9b30aa720cf72012137708adc8bc
BLAKE2b-256 1863993923df89a763dcf2478d932d4d835a7d15da935471f6fc8bf873198836

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page