GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - vroy/python-sengled-client: A simple Python client to control Sengled [light] accessories.

BranchesTags
Open more actions menu

Latest commit

 

History

12 Commits
12 Commits

Folders and files

NameName
Last commit message
Last commit date
sengled
sengled
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
setup.py
setup.py
 
 

Repository files navigation

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

pip3 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="[email protected]",
    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

    # Retries login if no server response when True, defaults to False. (Max retry number is 100)
    retry=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:

  • https://github.com/j796160836/homebridge-sengled/
  • https://github.com/mpomery/sengled-element-postman/blob/master/Sengled%20Element%20API.postman_collection.json
  • https://github.com/sroehl/sengled-python
  • https://github.com/AHerridge/BetterSengled/blob/master/device.py
  • https://github.com/NoxPhoenix/noxbot/blob/68281bac10aa6a939f617d1ba148944338566491/clients/sengledClient.js

About

A simple Python client to control Sengled [light] accessories.

Topics

pythonsengledsmartlights

Resources

Readme
MIT license
Activity

Stars

28 stars

Watchers

5 watching

Forks

4 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.