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.9.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.9.0
File Size Uploaded Provenance Actions
asyncsleepiq-1.9.0.tar.gz 22.1 kB Without provenance Details for asyncsleepiq-1.9.0.tar.gz

Built distribution (wheel)

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

Total release size: 49.3 kB

Release files / asyncsleepiq-1.9.0.tar.gz

Download URL asyncsleepiq-1.9.0.tar.gz
Size 22.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5bf9d471cabb48b831cfc5841653d85c2687cbd17418b8d7abb28db769297b59
BLAKE2b-256 checksum
How to use checksums
9c37bf89a29861269c087919af008c2c636041f17553e379a025c7daab60b422
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.9.0-py3-none-any.whl

Download URL asyncsleepiq-1.9.0-py3-none-any.whl
Size 27.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a5ea613a25363ba8d19a15cdf403e0d9403ea4005d6a5a3cb0008f6502ffc4c
BLAKE2b-256 checksum
How to use checksums
58ae1a0ec351be58907705d3e9fe401f551abfafed273bc9519db288b522791d
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.9.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