Skip to main content

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_light(lightNumber, setting, bedId='')
>>> pprint(client.get_light(lightNumber, bedId=''))
>>> client.preset(preset, side, bedId='', slowSpeed=False)
>>> client.set_foundation_position(bedNumber, actuator, position, side, bedId='', slowSpeed=False)
>>> client.set_foundation_massage(bedNumber, footSpeed, headSpeed, side, timer=0, mode=0, bedId='')
>>> client.set_sleepnumber(side, sleepnumber, bedId='')
>>> client.set_favsleepnumber(side, sleepnumber, bedId='')
>>> pprint(client.get_favsleepnumber(bedId=''))
>>> client.stop_motion(bedId='', side)
>>> client.stop_pump(bedId='')
>>> pprint(client.foundation_status(bedId=''))
>>> pprint(client.foundation_system(bedId=''))
>>> pprint(client.foundation_features(bedId=''))

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.

Release files for sleepyq 0.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sleepyq 0.8.1
File Size Uploaded
sleepyq-0.8.1.tar.gz 5.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sleepyq 0.8.1
File Interpreter ABI Platform
sleepyq-0.8.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.5 kB

Release files / sleepyq-0.8.1.tar.gz

Download URL sleepyq-0.8.1.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
fbbce3e3e16d23a500942041802fc17fab5adbc9dd7f871726dcd1f76fcf1fae
BLAKE2b-256 checksum
How to use checksums
8e793bbbfe2906227728ee7c1fc7b89c73b65e2e066b02b2e47867b91accac34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.4.2 requests/2.21.0 setuptools/50.3.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.3

Release files / sleepyq-0.8.1-py3-none-any.whl

Download URL sleepyq-0.8.1-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a5412270ba4e162268297669a59d3c57819e5de14d370c2a90dd9f95ca68dbc7
BLAKE2b-256 checksum
How to use checksums
82f5b9d0f07ebc520efaf6d62291d43e0d15c2dd7666d7a92ab5b3edadda43bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.4.2 requests/2.21.0 setuptools/50.3.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.8.1 This release

2 release files

0.8

2 release files

0.7

1 release file

0.6

1 release file

0.5

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page