Skip to main content

Sengled Python Client

A simple Python client to control Sengled light and plug accessories.

There are other accessories but this was only tested with these three devices:

  • A19 element color plus (E11-N1EA)
  • A19 element classic (E11-G13)
  • Smart plug (E1C-NB6)

Installation

pip install sengled-client

Usage

Create the API client:

import sengled

api = sengled.api(
    # The username/password that you used to create your mobile account in
    # the Sengled Home app.
    username="your-username@example.com",
    password="your-secure-password",

    # Optional path to persist the session across multiple process
    # starts and reduce the number of logins.
    session_path="/tmp/sengled.pickle",

    # Prints details of the api request/responses when True, defaults to false.
    debug=True
)

Alternatively, set SENGLED_* environment variables that match the api arguments.

import sengled

api = sengled.api_from_env()

List all devices

devices = api.get_device_details()

List lamps that support colors

colored = api.filter_colored_lamps()

List lamps that support color temperature

temperature = api.filter_color_temperature_lamps()

The API can be used to modify a list of devices or single devices

api.set_on(devices)

api.set_brightness(devices, 100)

api.set_color(colored, [255, 0, 0])

api.set_color_temperature(temperature, 100)

api.set_off(devices[0])

api.set_on_off(devices, True)

You can search for single devices

api.find_by_id("B0CE18140000EB41") #=> SengledLampDevice

api.find_by_name("Office Bulb 1")  #=> SengledLampDevice

And finally you can operate directly on SengledLampDevices

bulb = api.find_by_name("Office Bulb 1")
bulb.on()
bulb.set_brightness(50)
bulb.set_color_temperature(50)
bulb.toggle()

Or chain the actions:

api.find_by_name("Office Bulb 2") \
   .on() \
   .set_brightness(50) \
   .set_color([0, 0, 255])

Note that all API calls will raise based on status_code via request's raise_for_status() method. Action methods will also raise a RuntimeError if the success field is returned with a value of False.

How this came about?

This was reverse engineered from multiple different repositories found on GitHub as well as Charles.app and some guessing. See also:

Metadata

Release files for sengled-client 0.0.2

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

Source distribution (sdist)

Source distribution for sengled-client 0.0.2
File Size Uploaded
sengled-client-0.0.2.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sengled-client 0.0.2
File Interpreter ABI Platform
sengled_client-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 12.3 kB

Release files / sengled-client-0.0.2.tar.gz

Download URL sengled-client-0.0.2.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6179ff662789c417396592ad622f8ea3e081ae0b6d90b53f5bf00fbde1c089a0
BLAKE2b-256 checksum
How to use checksums
04f1c25ae5974fb57e748e21ef606942c0fe98297768086cd2f6fe51c20e8f14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Release files / sengled_client-0.0.2-py3-none-any.whl

Download URL sengled_client-0.0.2-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0cee111f7693e0fca92f19b6b50dbb0c8d39e03fdcbac03e2c541e1177b0125
BLAKE2b-256 checksum
How to use checksums
fb08d94e892d8e5f017fc4d76ec5deb439a6213eeb293224db4bb36403e3621b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.0.2 This release

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