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:

Download files

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

Source Distribution

asyncsleepiq-1.7.2.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

asyncsleepiq-1.7.2-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file asyncsleepiq-1.7.2.tar.gz.

File metadata

  • Download URL: asyncsleepiq-1.7.2.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for asyncsleepiq-1.7.2.tar.gz
Algorithm Hash digest
SHA256 9b422ce57e3aa4e193bbb4c104163fb200b718dc542d890e35ee47d6b0809dbd
MD5 3329d717b0d64d2c6686e47179817ab6
BLAKE2b-256 1a3b18546edde8bfdd0938e4e8c6c78dcac720f2a0bd2f57dfe6264afbeba31c

See more details on using hashes here.

File details

Details for the file asyncsleepiq-1.7.2-py3-none-any.whl.

File metadata

  • Download URL: asyncsleepiq-1.7.2-py3-none-any.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for asyncsleepiq-1.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5d85f2b0a791e5808b5a3a035889720431c06751397e2f26498ab398ba93f839
MD5 d8587df2f579fe70853ce6394612ce99
BLAKE2b-256 ea977217f0b252349b5ef2f366c60a1a8bc383585445e496d865362b75d93acf

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.7.2 This release

2 files

1.7.1

2 files

1.7.0

2 files

1.6.1

2 files

1.6.0

2 files

1.5.3

2 files

1.5.2

2 files

1.5.1

2 files

1.5.0

2 files

1.4.2

2 files

1.4.1

2 files

1.4.0

2 files

1.3.7

2 files

1.3.6

2 files

1.3.5

2 files

1.3.4

2 files

1.3.3

2 files

1.3.2

2 files

1.2.3

2 files

1.2.2

2 files

1.2.1

2 files

1.2.0

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.0

2 files

0.9.4

2 files

0.0.0

2 files

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