Skip to main content

AsyncSleepIQ

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

Installation

pip install asyncsleepiq

Usage

The library is structured with classes SleepIQBed, SleepIQSleeper, and SleepIQFoundation that get updated with data fetched through the API.

After creating an intsance of AsyncSleepIQ() the login function should be called, followed by the init_beds() function to initialize the data structures and fetch the static data from the API. Following that, the fetch_bed_statuses() function can be called to get updated bed occupancy and sleep number values.

There are two authentication methods available: The older API with key parameter and the newer cookie-based Authentication header. As of Feb-2022 both work equally well.

The login() function should only be called once when the program is started, the fetch_bed_statuses() can be called more frequently to get the bed state. When implementing, do not poll the API by calling login each time, instead keep the same AsyncSleepIQ object and fetch data as needed. The library will re-authenticate automtically if the original authentication expires.

Here is a full example:

import asyncio
from asyncsleepiq import AsyncSleepIQ, LOGIN_KEY, LOGIN_COOKIE

email = "user@example.com"
password = "passw0rd"

async def main():
    api = AsyncSleepIQ(login_method=LOGIN_COOKIE)

    print(f"Logging in as {email}...")
    await api.login(email, password)

    print("Initializing bed data...")
    await api.init_beds()
    await api.fetch_bed_statuses()
    print("Beds:")
    for bed in api.beds.values():
        print(bed)

    bed = list(api.beds.values())[0]
    await bed.fetch_pause_mode()
    print (f"Pause mode: {bed.paused}")
    await bed.set_pause_mode(not bed.paused)
    await bed.fetch_pause_mode()
    print (f"New Pause mode: {bed.paused}")

    print("Calibrating...")
    await bed.calibrate()
    print("Stopping pump...")
    await bed.stop_pump()

    return api

if __name__ == "__main__":
    loop_ = asyncio.get_event_loop()
    api_ = loop_.run_until_complete(main())
    loop_.run_until_complete(api_.close_session())
    loop_.close()

Future Development

Without documentation for the API, development requires obvserving how other interfaces interact with it. Given the hardware dependencies are fairly high, any future development requires someone with the appropriate bed to be able to obvserve and test against.

Special Thanks

Thanks to all the other people that have tried to dig into this API, especially the projects:

Metadata

Release files for asyncsleepiq 1.8.0

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

Source distribution (sdist)

Source distribution for asyncsleepiq 1.8.0
File Size Uploaded Provenance Actions
asyncsleepiq-1.8.0.tar.gz 19.2 kB Without provenance Details for asyncsleepiq-1.8.0.tar.gz

Built distribution (wheel)

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

Total release size: 45.4 kB

Release files / asyncsleepiq-1.8.0.tar.gz

Download URL asyncsleepiq-1.8.0.tar.gz
Size 19.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e52d106190ae2d6c549c68c6d3cc681e492d14be79124675af602b8bf447d3c1
BLAKE2b-256 checksum
How to use checksums
84614e99068c0b0eb6cc98fab07ccf05ae6a3ef8f5a53a37b83801700b021b20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.17

Release files / asyncsleepiq-1.8.0-py3-none-any.whl

Download URL asyncsleepiq-1.8.0-py3-none-any.whl
Size 26.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f9939b85e089b0ed05c0c425c0b831de7f1fa84f6c24b0a8ad35bbb6ca34b76
BLAKE2b-256 checksum
How to use checksums
55e3495093548750695457a4acdca888796d37379de56a2147e549a0e25ee107
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.17

Security for asyncsleepiq 1.8.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

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