Skip to main content

Python library for the StreamLabs Developer API

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

StreamLabs Python Library

This is the official python client for the StreamLabs Developer API.

Documentation

See the StreamLabs Developer API docs

Use the package manager pip to install the package

pip3 install streamlabswater-streamlabswater

Usage

The package needs to configured with your accounts API Key available when you login into your http://my.streamlabswater.com account.

from streamlabswater import Stream

stream = Stream('YOUR_STREAMLABSWATER_API_KEY')

Get all Locations

Start by fetching all your locations

locations = stream.get_locations()

Get a Location

A location_id is required to fetch details of a location, water usage and for updating homeAway.

location_id = locations[0]['location_id']

my_home = stream.get_location(location_id)

Update a Location

Currently you can only update the homeAway mode of the location When updating a location the response is always the updated location details

# Set to home
my_home = stream.update_location(location_id, 'home')

# Set to away
my_home = stream.update_location(location_id, 'away')

Subscribe to Location Alerts

If you choose to recieve notifications when alerts become active or end for a location, you need to provide a valid url endpoint where the StreamLabs service will send the notifications. The following methods wrap the corresponding StreamLabs api endpoints as descriped in the Subscribe to Location Alerts section in the docs

Create Subscription

subscription_id = stream.subscribe_to_location_alerts(location_id, 'https://your-endpoint')['subscription_id']

Confirm subscription

Once you recieve the confirmationToken via your endpoint, update the subscription to start recieving alerts.

confirmation_token = 'CONFIRMATION_TOKEN'

subscription = stream.confirm_subscription(subscription_id, confirmation_token)

# subscription['status'] should be 'confirmed'

Get all Location Subscriptions

subscriptions = stream.get_location_subscriptions(location_id)

Get a Subscription

subscription = stream.get_subscription(subscription_id)

Get all Subscriptions

all_subscriptions = stream.get_subscriptions()

Delete a Subscription

stream.delete_subscription(subscription_id)

This method will throw an Exception if the delete fails else returns a None

Get a Location’s Water Usage Summary

water_usage_summary = stream.get_location_water_usage_summary(location_id)

today = water_usage_summary['today']
this_month = water_usage_summary['thisMonth']
this_year = water_usage_summary['thisYear']
units = water_usage_summary['units']

Get a Location’s Water Usage

At the very minimum you need to provide a startTime for the reading you want to retrive.

from datetime import datetime, timezone, timedelta

yesterday = datetime.now(timezone.utc) - timedelta(days=1)
start_time = yesterday.isoformat(timespec='seconds')

usage = stream.get_location_water_usage(location_id, {'startTime': start_time})

Credits

This project was heavily inspired by streamlabswater-python

Project details


Download files

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

Source Distribution

streamlabswater-streamlabswater-0.3.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file streamlabswater-streamlabswater-0.3.2.tar.gz.

File metadata

  • Download URL: streamlabswater-streamlabswater-0.3.2.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.5

File hashes

Hashes for streamlabswater-streamlabswater-0.3.2.tar.gz
Algorithm Hash digest
SHA256 0043ee477ffa88abc27f20626611188c9a906d780fb088a0e788461359b84e32
MD5 8f41bffe564a221181bcd3d5355c4090
BLAKE2b-256 7adab6c768406aa97c53b630ae8b6806b0a0dc309a876dfa3213ff4e1c407206

See more details on using hashes here.

File details

Details for the file streamlabswater_streamlabswater-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: streamlabswater_streamlabswater-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.5

File hashes

Hashes for streamlabswater_streamlabswater-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b977c3be9f104c071b604d5e06dd4f1a8c426e22c165a6c7344d53dd68eb7147
MD5 1ceb0e8df9b5847ae738f3cbee94f633
BLAKE2b-256 24d372c67ab6952e60d6e252cc290338dac7b80391db41bf15108c1acb8b5ca3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page