Skip to main content

Introduction

This is a Python 3.8+ module aiming to interact with the Snoo Smart Sleeper from happiestbaby.com API.

Homeassistant

Homeassistant has a custom Snoo component leveraging this package. This can be added into HACS as a custom repository.

Getting Started

Installation

pip install pysnoo

Usage

pysnoo starts within an aiohttp ClientSession:

import asyncio

from aiohttp import ClientSession


async def main() -> None:
    """Create the aiohttp session and run."""
    async with ClientSession() as websession:
      # YOUR CODE HERE


asyncio.get_event_loop().run_until_complete(main())

To get all Snoo devices associated with an account:

import asyncio

from aiohttp import ClientSession

import pysnooapi

async def main() -> None:
    """Create the aiohttp session and run."""
    async with ClientSession() as websession:
      snoo = await pysnoo.login('<EMAIL>', '<PASSWORD>', websession)

      # Returns snoo devices
      devices = snoo.devices
      # >>> {"serial_number123": <Device>, "serial_number456": <Device>}


asyncio.get_event_loop().run_until_complete(main())

API Methods

These are coroutines and need to be awaited – see example.py for examples.

  • login: Login method that authenticates user and also updates device information
  • authenticate: Authenticate (or re-authenticate) to Snoo. Call this to re-authenticate immediately after changing username and/or password otherwise new username/password will only be used when token has to be refreshed.
  • get_account: Retrieve account details
  • update_device_info: Retrieve info and status for devices including account, baby, config and session
  • get_session_for_account: Retrieve session details for the account. Oddly, this is not linked to a device.
  • get_configs_for_device: Retrieve config details for the devices
  • get_baby_for_account: Retrieve baby details associated with the account
  • get_session_stats_avg_for_account: Retrieve aggregated session stats for the week
  • get_session_stats_daily_for_account: Retrieve aggregated session stats for the given date

Device Methods

All of the routines on the SnooDevice class are coroutines and need to be awaited – see example.py for examples.

  • update: get the latest device info (state, etc.). Note that this runs api.update_device_info and thus all accounts/devices will be updated

API Properties

  • account: dictionary with the account
  • devices: dictionary with all devices
  • last_state_update: datetime (in UTC) last state update was retrieved
  • password: password used for authentication. Can only be set, not retrieved
  • username: username for authentication.

Account Properties

  • userId: User ID for the account
  • email: Email for the account
  • givenName: Name for the account
  • surname: Last name for the account
  • region: Region for the account

Example

{
    "email": "abc@xyz.com",
    "givenName": "ABC",
    "surname": "XYZ",
    "userId": "afdgjfhdsgsg",
    "region": "US"
}

Session Properties

  • startTime: datetime when the current or last session started
  • endTime: datetime when the last session ended or None if current session is active
  • levels: sequence of levels in current session sorted by time. (Last level is the latest)

Example

{
    "startTime": "2021-02-01T01:02:34.456Z",
    "endTime": "2021-02-01T04:02:34.456Z",
    "levels": [
        {
            "level": "BASELINE"
        },
        {
            "level": "LEVEL1"
        },
        {
            "level": "BASELINE"
        },
        {
            "level": "ONLINE"
        }
    ]
}

Config Properties

Example

{
    "config": "lvl0",
    "premieLock": false,
    "weaning": false,
    "whiteNoiseLevel": "lvl-1",
    "motionLimiter": false,
    "minimalLevel": "baseline",
    "networkStatus": {
        "lastPresence": "2021-01-01T11:02:35.160Z",
        "lastProvisionSuccess": "2021-01-01T23:45:49.752Z",
        "lastSSID": {
            "name": "ABC",
            "updatedAt": "2021-01-01T06:56:18.364Z"
        },
        "isOnline": true
    }
}

Baby Properties

Example

{
    "settings": {
        "responsivenessLevel": "lvl0",
        "minimalLevelVolume": "lvl-1",
        "soothingLevelVolume": "lvl0",
        "minimalLevel": "baseline",
        "motionLimiter": false,
        "weaning": false,
        "carRideMode": true,
        "offlineLock": false,
        "daytimeStart": 8
    },
    "disabledLimiter": false,
    "_id": "asfkhdsgfjsdkhkjdsg",
    "pictures": [
        {
            "id": "sdfsdgkjhihr3r324_dsfh34tjh5kth5k",
            "mime": "image/png",
            "encoded": false,
            "updatedAt": "2020-02-13T01:36:14.717Z"
        }
    ],
    "createdAt": "2020-02-12T01:12:12.123Z",
    "updatedAt": "2020-02-12T01:12:12.123Z",
    "babyName": "Baby",
    "birthDate": "2020-02-12T01:12:12.123Z",
    "sex": "Female",
    "updatedByUserAt": "2020-02-12T01:12:12.123Z"
}

Device Properties

  • account: Return account associated with device
  • device_id: Return the device ID (serial number)
  • device: Return the device details
  • firmware_version: Return the family in which this device lives
  • name: Return the device name
  • is_online: Return whether the device is online
  • is_on: Return whether the device is on (in motion)
  • state: Return the current state of the device (ONLINE, WEANING_BASELINE, BASELINE, LEVEL1, LEVEL2, LEVEL3 and LEVEL4)
  • baby: Return the baby details
  • session: Return the session details
  • config: Return the config details
  • last_update: Returns datetime when the device was last updated

Device Details

The device details from device properties

Example

{
    "serialNumber": "243545643656",
    "createdAt": "2020-01-02T18:01:42.124Z",
    "updatedAt": "2021-02-01T11:00:12.123Z",
    "baby": "krgh2354543jhg6jh5gj",
    "lastProvisionSuccess": "2020-12-01T01:45:49.752Z",
    "firmwareUpdateDate": "2021-01-01T20:53:49.782Z",
    "firmwareVersion": "v1.14.12",
    "lastSSID": {
        "name": "ABC",
        "updatedAt": "2020-01-03T06:56:18.364Z"
    },
    "timezone": "America/Los_Angeles"
}

Session Stats Properties

Daily Session Aggregates

Example

{
    "levels": [
        {
            "sessionId": "1654751546",
            "type": "asleep",
            "startTime": "2021-01-31 08:00:00.000",
            "stateDuration": 1279,
            "isActive": false
        },
        {
            "sessionId": "1681977280",
            "type": "asleep",
            "startTime": "2021-01-31 08:33:43.084",
            "stateDuration": 63,
            "isActive": false
        },
        ...
    ],
    "detailedLevels": [
        {
            "sessionId": "1654751546",
            "level": "BASELINE",
            "hold": false,
            "settings": {
                "responsivenessLevel": "lvl0",
                "minimalLevelVolume": "lvl-1",
                "soothingLevelVolume": "lvl0",
                "minimalLevel": "baseline",
                "motionLimiter": false,
                "weaning": false,
                "carRideMode": false
            },
            "isActive": false,
            "levelDetails": {
                "start": "2021-01-31 06:57:20.894",
                "duration": 5038
            },
            "sessionDetails": {
                "start": "2021-01-31 06:57:20.894",
                "duration": 5038
            },
            "type": "asleep",
            "startTime": "2021-01-31 08:00:00.000",
            "stateDuration": 1279
        },
        ...
    ],
    "naps": 2,
    "longestSleep": 10032,
    "totalSleep": 18096,
    "daySleep": 3434,
    "nightSleep": 14662,
    "nightWakings": 4,
    "timezone": null
}

Weekly Session Aggregate

Example

{
    "totalSleepAVG": 18670,
    "daySleepAVG": 3268,
    "nightSleepAVG": 16802,
    "longestSleepAVG": 9497,
    "nightWakingsAVG": 6.286,
    "days": {
        "totalSleep": [
            18096,
            19966,
            29070,
            15408,
            18880,
            17171,
            12096
        ],
        "daySleep": [
            3434,
            2012,
            5463,
            2161,
            0,
            0,
            0
        ],
        "nightSleep": [
            14662,
            17954,
            23607,
            13247,
            18880,
            17171,
            12096
        ],
        "longestSleep": [
            10032,
            10932,
            11028,
            9954,
            8717,
            8979,
            6837
        ],
        "nightWakings": [
            4,
            7,
            4,
            7,
            6,
            7,
            9
        ]
    }
}

Acknowledgement

The structure of this project is inspired by pymyq

Disclaimer

The code here is based off of an unsupported API from happiestbaby.com and is subject to change without notice. The authors claim no responsibility for damages to your garage door or property by use of the code within.

Release files for pysnooapi 0.0.3

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

Source distribution (sdist)

Source distribution for pysnooapi 0.0.3
File Size Uploaded
pysnooapi-0.0.3.tar.gz 17.7 kB Details

Built distribution (wheel)

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

Total release size: 33.0 kB

Release files / pysnooapi-0.0.3.tar.gz

Download URL pysnooapi-0.0.3.tar.gz
Size 17.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f1a52f58af9ae658fb614b2b767ad0bc93fa518d093a256615a6abaa87d426e6
BLAKE2b-256 checksum
How to use checksums
6f4bb7a8422eda3df906553a91d41c2da235ef549e1086619a18ea52f206f239
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / pysnooapi-0.0.3-py3-none-any.whl

Download URL pysnooapi-0.0.3-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78c61bb0a97236cff420e22c5bae8015c4b64ea4912a382b395e2cbe3e71107c
BLAKE2b-256 checksum
How to use checksums
02a52077ae368ecada5d3136a518fe2b88803d56953f5b5e5af4d11a6562c820
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release 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