Skip to main content

Python library for Gemstone Lights permanent-Christmas-lights controllers (AWS-backed cloud API)

Project description

pygemstone

PyPI Python License

Standalone Python library for Gemstone Lights permanent-Christmas-light controllers.

Gemstone's mobile app talks to an AWS Amplify backend (Cognito + API Gateway + AppSync) in us-west-2, so this library is essentially:

  • a Cognito SRP login wrapper (delegated to pycognito)
  • an aiohttp REST client for the public endpoints that control the lights (/deviceControl/onState, /deviceControl/play/pattern, etc.)

Status: alpha — under active reverse-engineering of the iOS com.gemstone.lights app. APIs will change.

Features

  • Async login / token refresh (via Cognito User Pool SRP)
  • Account & home group:
    • account_profile() — your user profile
    • homegroups() / homegroup_users(hg)
    • invitations(status="pending") — pending invites (raw dict; schema unknown)
  • Devices:
    • devices(hg) — list controllers
    • device_state(id) / set_on_state(id, on) / play_pattern(id, p)
    • device_groups(hg) — multi-device zones (raw dict; schema unknown)
  • Pattern catalogue:
    • folders() / folder_patterns(page=N) / save_folder(id, body)
    • swatches() — colour palettes
    • downloadable_folders(page=N) / downloadable_patterns(page=N) — Gemstone-curated catalogue
  • Autopilot / scheduling:
    • events_settings(hg) — daily on/off window + enabled categories
    • subscribed_events(hg, page=N) — date-bound holiday/event subscriptions
    • events_categories() — full catalogue of holiday / sport / event categories
  • Timers:
    • timers_by_homegroup(hg) — scheduled on/off timers with optional pattern
  • Misc:
    • announcements() — in-app announcements

A note on AppSync (real-time)

The library ships an AppSync GraphQL HTTP + WebSocket transport (pygemstone.appsync.AppSyncClient), but two iOS-app captures show the official app never opens a GraphQL connection — only unauthenticated /ping healthchecks. State updates propagate via REST polling of /deviceControl/currentlyPlaying. The AppSync auth scheme is therefore unknown and the transport is currently un-runnable against the real backend; it's kept as scaffolding for if Gemstone ever flips real-time on.

Planned

  • Cognito global sign-out (currently only clears local tokens)
  • Schedule/event subscribe + unsubscribe mutations
  • Timer create / update / delete (only list is currently captured)

Installation

pip install pygemstone

Usage

import asyncio
from pygemstone import GemstoneClient

async def main():
    async with GemstoneClient("you@example.com", "...") as gc:
        await gc.login()
        for group in await gc.homegroups():
            print(group.name)
            for device in await gc.devices(group.id):
                state = await device.refresh()
                print(" ", device.name, "on" if state.on_state else "off")
                if not state.on_state:
                    await device.turn_on()

asyncio.run(main())

CLI

A small CLI is provided for manual testing:

python -m pygemstone login
python -m pygemstone list
python -m pygemstone state <DEVICE_ID>
python -m pygemstone on <DEVICE_ID>
python -m pygemstone off <DEVICE_ID>

Credentials are read from GEMSTONE_EMAIL / GEMSTONE_PASSWORD env vars, or a .env file in the working directory.

Security note

Like the other Amplify-based IoT services, Gemstone's Cognito user pool id and app client id are public values that any decompiled IPA / packet capture exposes — they're shipped in const.py as defaults. Do not commit credential files, JWT tokens, or mitmproxy .flows files.

Reverse-engineering notes

The endpoint catalogue was derived from a mitmproxy --mode wireguard capture of the official iOS app. Notes are kept private (the capture contains a live Cognito session); the public endpoint shape is in const.py.

License

MIT — see LICENSE.

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

pygemstone-0.0.3.tar.gz (34.6 kB view details)

Uploaded Source

Built Distribution

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

pygemstone-0.0.3-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

Details for the file pygemstone-0.0.3.tar.gz.

File metadata

  • Download URL: pygemstone-0.0.3.tar.gz
  • Upload date:
  • Size: 34.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pygemstone-0.0.3.tar.gz
Algorithm Hash digest
SHA256 3ec7245d3d0bd8e72d43d729bbc1a62e40296aa8b98f2cc8d10873a4e3200145
MD5 9925c0755c1bafb66b200ba597113c2e
BLAKE2b-256 149f68d22d1739dbb2f485904574285523a6af9a3f20c713373496310eac494d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygemstone-0.0.3.tar.gz:

Publisher: release.yml on sslivins/pygemstone

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pygemstone-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pygemstone-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 25.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pygemstone-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 df09829edb168b5f9a9a36bbf32f86b371cf1dc784194d2f31940cd71b6b390e
MD5 caef0366a41ab8e43f49c6559a193975
BLAKE2b-256 efbad5924ba027815757c872188017b317e1fae8be70b14de3359b129fcca93f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygemstone-0.0.3-py3-none-any.whl:

Publisher: release.yml on sslivins/pygemstone

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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