GithubHelp home page GithubHelp logo

sleepyq's Introduction

Sleepyq

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.

sleepyq's People

Contributors

tagno25 avatar technicalpickles avatar tmcarr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.