• Stars
    star
    158
  • Rank 237,131 (Top 5 %)
  • Language
    Python
  • License
    GNU Lesser Genera...
  • Created over 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A utility for controlling Flux WiFi Smart LED Light Bulbs

Python package codecov
Python Versions PyPi Project
GitHub Activity License
GitHub Top Language

Magic Home / Surp Life / flux_led

This is a utility for controlling stand-alone Magic Home and Surp Life devices manufactured by Zengge. The protocol was reverse-engineered by studying packet captures between a bulb and the controlling "Magic Home" mobile app. The code here dealing with the network protocol is littered with magic numbers, and ain't so pretty. But it does seem to work!

So far most of the functionality of the apps is available here via the CLI and/or programmatically.

The classes in this project could very easily be used as an API, and incorporated into a GUI app written in PyQt, Kivy, or some other framework.

Minimum python version

3.7

Available:
  • Discovering bulbs on LAN
  • Turning on/off bulb
  • Get state information
  • Setting "warm white" mode
  • Setting single color mode
  • Setting preset pattern mode
  • Setting custom pattern mode
  • Reading timers
  • Setting timers
  • Sync clock
  • Music Mode for devices with a built-in microphone (asyncio version only)
  • Remote access administration (asyncio version only)
  • Device configuration including wiring order, ic type, pixels, etc (asyncio version only)
Some missing pieces:
  • Initial administration to set up WiFi SSID and passphrase/key.
Cool feature:
  • Specify colors with names or web hex values. Requires that python "webcolors" package is installed. (Easily done via pip, easy_install, or apt-get, etc.) Use --listcolors to show valid color names.
Installation:
pip install flux_led
Examples:
Scan network:
	flux_led -s

Scan network and show info about all:
	flux_led -sSti

Turn on:
	flux_led 192.168.1.100 --on
	flux_led 192.168.1.100 -192.168.1.101 -1

Turn on all bulbs on LAN:
	flux_led -sS --on

Turn off:
	flux_led 192.168.1.100 --off
	flux_led 192.168.1.100 --0
	flux_led -sS --off
	
Set warm white, 75%
	flux_led 192.168.1.100 -w 75 -1

Set fixed color red :
	flux_led 192.168.1.100 -c Red
	flux_led 192.168.1.100 -c 255,0,0
	flux_led 192.168.1.100 -c "#FF0000"
	
Set preset pattern #35 with 40% speed:	
	flux_led 192.168.1.100 -p 35 40
	
Set custom pattern 25% speed, red/green/blue, gradual change:
	flux_led 192.168.1.100 -C gradual 25 "red green (0,0,255)"

Sync all bulb's clocks with this computer's:
	flux_led -sS --setclock
		
Set timer #1 to turn on red at 5:30pm on weekdays:
	flux_led 192.168.1.100 -T 1 color "time:1730;repeat:12345;color:red"
	
Deactivate timer #4:
	flux_led 192.168.1.100 -T 4 inactive ""

Use --timerhelp for more details on setting timers
Show help:
$ flux_led -h
Usage: usage: __main__.py [-sS10cwpCiltThe] [addr1 [addr2 [addr3] ...].

A utility to control Flux WiFi LED Bulbs.

Options:
  -h, --help            show this help message and exit
  -s, --scan            Search for bulbs on local network
  -S, --scanresults     Operate on scan results instead of arg list
  -i, --info            Info about bulb(s) state
  --getclock            Get clock
  --setclock            Set clock to same as current time on this computer
  -t, --timers          Show timers
  -T NUM MODE SETTINGS, --settimer=NUM MODE SETTINGS
                        Set timer. NUM: number of the timer (1-6). MODE:
                        inactive, poweroff, default, color, preset, or
                        warmwhite. SETTINGS: a string of settings including
                        time, repeatdays or date, and other mode specific
                        settings.   Use --timerhelp for more details.

  Program help and information option:
    -e, --examples      Show usage examples
    --timerhelp         Show detailed help for setting timers
    -l, --listpresets   List preset codes
    --listcolors        List color names

  Power options (mutually exclusive):
    -1, --on            Turn on specified bulb(s)
    -0, --off           Turn off specified bulb(s)

  Mode options (mutually exclusive):
    -c COLOR, --color=COLOR
                        Set single color mode.  Can be either color name, web
                        hex, or comma-separated RGB triple
    -w LEVEL, --warmwhite=LEVEL
                        Set warm white mode (LEVEL is percent)
    -p CODE SPEED, --preset=CODE SPEED
                        Set preset pattern mode (SPEED is percent)
    -C TYPE SPEED COLORLIST, --custom=TYPE SPEED COLORLIST
                        Set custom pattern mode. TYPE should be jump, gradual,
                        or strobe. SPEED is percent. COLORLIST is a space-
                        separated list of color names, web hex values, or
                        comma-separated RGB triples


Supported Models

The following models have been tested with library.

Model Description Microphone Notes
0x01 Legacy RGB Controller no Original protocol
0x03 Legacy CCT Controller no Original protocol
0x04 UFO Controller RGBW no
0x06 Controller RGBW no
0x07 Controller RGBCW no
0x08 Controller RGB with MIC yes
0x09 Ceiling Light CCT no
0x0E Floor Lamp RGBCW no
0x10 Christmas Light no
0x16 Magnetic Light CCT no
0x17 Magnetic Light Dimmable no
0x1A Christmas Light no
0x1C Table Light CCT no
0x1E Ceiling Light RGBCW no
0x21 Bulb Dimmable no
0x25 Controller RGB/WW/CW no Supports RGB, RGBW, RGBWW, CW, DIM
0x33 Controller RGB no
0x35 Bulb RGBCW no
0x41 Controller Dimmable no
0x44 Bulb RGBW no
0x52 Bulb CCT no
0x54 Downlight RGBW no
0x62 Controller CCT no
0x93 Switch 1 Channel no
0x97 Socket no
0xA1 Addressable v1 no Supports UCS1903, SM16703, WS2811, WS2812B, SK6812, INK1003, WS2801, LB1914
0xA2 Addressable v2 yes Supports UCS1903, SM16703, WS2811, WS2811B, SK6812, INK1003, WS2801, WS2815, APA102, TM1914, UCS2904B
0xA3 Addressable v3 yes Supports WS2812B, SM16703, SM16704, WS2811, UCS1903, SK6812, SK6812RGBW (WS2814), INK1003, UCS2904B
0xA4 Addressable v4 no Supports WS2812B, SM16703, SM16704, WS2811, UCS1903, SK6812, SK6812RGBW (WS2814), INK1003, UCS2904B
0xA6 Addressable v6 yes Supports WS2812B, SM16703, SM16704, WS2811, UCS1903, SK6812, SK6812RGBW (WS2814), INK1003, UCS2904B
0xA7 Addressable v7 yes Supports WS2812B, SM16703, SM16704, WS2811, UCS1903, SK6812, SK6812RGBW (WS2814), INK1003, UCS2904B
0xE1 Ceiling Light CCT no
0xE2 Ceiling Light Assist no Auxiliary Switch not supported

Untested Models

The following models have not been tested with the library but may work.

Model Description Microphone Notes
0x02 Legacy Dimmable Controller no Original protocol, discontinued

Unsupported Models

The following models are confirmed to be unsupported.

Model Description Microphone Notes
0x18 Plant Grow Light no
0x19 Socket with 2 USB no
0x1B Aroma Fragrance Lamp no
0x1D Fill Light no
0x94 Switch 1c Watt no
0x95 Switch 2 Channel no
0x96 Switch 4 Channel no
0xD1 Digital Time Lamp no

Known Vendors

File Structure

device.py -> contains code to manipulate device as well as get any information from device that's needed.
fluxled.py -> command line code for flux_led.
pattern.py -> contains code to identify pattern as well as set patterns.
protocol.py -> contains communication protocol to communicate with differnt devices.
scanner.py -> contins scanner to scan network and identify devices on network.
sock.py -> contains code to communicate on network.
timer.py -> contains code to support setting timers on devices and getting timer information from devices.
utils.py -> contains helpers to calculate differnt parameters such as color, cct, brightness etc.

More Repositories

1

PyXiaomiGateway

PyXiaomiGateway
Python
147
star
2

home-assistant_config

Example Home Assistant Configs
Python
109
star
3

pyTibber

Async Python 3 library for Tibber
Python
67
star
4

pySwitchbot

Library to control Switchbot
Python
66
star
5

home_assistant_tibber_custom

Display Tibber prices and energy consumption as a graph. Tibber is available in Germany, Norway and Sweden Tibber has helped tens of thousands of new customers each month in Sweden, Norway & Germany to lower their energy bill and consumption. Tibber is using digital technology to make electricity consumption smarter. If you use this link to signup for Tibber, you get 50 euro to buy smart home products in the Tibber store: https://invite.tibber.com/6fd7a447
Python
59
star
6

home_assistant_tractive

Custom component for Tractive
Python
33
star
7

home_assistant_airthings_cloud

Airthings cloud
Python
32
star
8

home_assistant_weather_data

Weather sensor (Replaces the old yr.no sensor)
Python
28
star
9

home_assistant_adax

Integration for Adax heaters
Python
26
star
10

home_assistant_tibber_data

Display Tibber data sensors.
Python
25
star
11

home_assistant_min_renovasjon

Min renovasjon
Python
25
star
12

pymill

Python library for Mill heater
Python
20
star
13

NeuroImageRegistration

Registration of medical MR brain images to a common mr brain
Python
10
star
14

home-assistant_custom_components

Custom components for Home Assistant
Python
9
star
15

pyIGTLink

Python implementation of OpenIGTLink
Python
9
star
16

pyMetno

Python library to talk to the met.no api
Python
8
star
17

AMSreader

AMS reader
Python
7
star
18

pyAdaxLocal

Adax local
Python
6
star
19

home_assistant_adax_local

Local Integration for Adax heaters
Python
6
star
20

pyAirthings

Python Airthings
Python
5
star
21

home_assistant_glitre

Glitre grid prices
Python
4
star
22

pySwitchmate

Library to control Switchmate
Python
4
star
23

pyAdax

Python library for Adax heater
Python
3
star
24

home_assistant_petcare

Petcare integration for Home Assistant
Python
3
star
25

deeplearning

Python
2
star
26

pyCustusX

python code to interact with CustusX data
Python
2
star
27

pyMillLocal

Mill local access
Python
2
star
28

Kaggle-planet-understanding-the-amazon-from-space

https://www.kaggle.com/anokas/planet-understanding-the-amazon-from-space/
Python
2
star
29

electricity_disaggregation

1
star
30

pyTemplate

Python
1
star
31

home_assistant_peak_control

Peak control
Python
1
star
32

Danielhiversen

1
star