Coder Social home page Coder Social logo

snoo's Introduction

SNOO

GitHub last commit

An API client to the SNOO Smart Sleeper Bassinet. The SNOO is a bassinet that will rock your baby to sleep. It responds to baby by trying to sooth it with different rocking motions and sounds when it detects crying.

The client only supports getting session and daily aggregated data from the SNOO. It does not allow you to control the SNOO. That API is provided by PubNub and is different from the read-only data API hosted by Happiest Baby.

Disclaimer

The SNOO API is undocumented. Using it might or might not violate Happiest Baby, Inc's Terms of Service. Use at your own risk.

Install

You can grab the latest version with curl. For Linux:

sudo curl -o /usr/local/bin/snoo https://github.com/ksindi/snoo/releases/download/v0.1.0/snoo-linux
sudo chmod +x /usr/local/bin/snoo

Or on MacOS:

sudo curl -o /usr/local/bin/snoo https://github.com/ksindi/snoo/releases/download/v0.1.0/snoo-darwin
sudo chmod +x /usr/local/bin/snoo

Usage

$ snoo -h

NAME:
   snoo - An API client to the SNOO Smart Sleeper Bassinet

USAGE:
   snoo [global options] command [command options] [arguments...]

VERSION:
   0.1.0

COMMANDS:
   sessions   print list of sessions for a date range
   days       print list of daily aggregated sessions for a date range
   help, h    Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --username value  SNOO login username [$SNOO_USERNAME]
   --password value  SNOO login password [$SNOO_PASSWORD]
   --debug           Enable verbose debugging (default: false)
   --help, -h        show help (default: false)
   --version, -v     print the version (default: false)

Export daily aggregated data

To export daily aggregated data, use

$ snoo days --start DATE --end DATE
date,naps,longest_sleep,total_sleep,day_sleep,night_sleep,night_wakings,timezone
2020-08-01 00:00:00 +0000 UTC,4,12997,55829,33950,21879,3,

All durations are given in seconds. How day_sleep and night_sleep are defined is set in your Snoo app.

Export sessions

To export sessions, use

$ snoo sessions --start DATE --end DATE
session_id,start_time,end_time,duration,asleep_duration,soothing_duration
1425693702,2020-08-22 00:00:00,2020-08-22 03:09:10,11350,11350,0
1609190237,2020-08-22 03:35:16,2020-08-22 08:20:54,17138,17138,0
1919690037,2020-08-22 10:12:26,2020-08-22 11:31:37,4751,3357,1394

Again, all durations are given in seconds. How asleep_duration and soothing_duration are defined is set in your Snoo app.

Programmatic usage

package main

import (
  "context"
  "log"
  "net/http"

  "github.com/ksindi/snoo"
)

func main() {
  ctx, cancel := context.WithCancel(context.Background())
  defer cancel()

  client := snoo.NewClient("my_username", "my_password")

  // declare an empty interface
  var result map[string]interface{}
  err := client.MakeRequest(ctx, http.MethodGet, "/ss/v2/sessions/last", nil, nil, &result)

  if err != nil {
  	log.Fatalln(err)
  }
}

Credit

This repo is inspired by https://github.com/maebert/snoo.

snoo's People

Contributors

ksindi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.