| 1 | [![Python package][python-package-shield]][python-package] |
| 2 | [![codecov][code-cover-shield]][code-coverage] \ |
| 3 | [![Python Versions][python-ver-shield]][python-ver] |
| 4 | [![PyPi Project][pypi-shield]][pypi]\ |
| 5 | [![GitHub Activity][commits-shield]][commits] |
| 6 | [![License][license-shield]](LICENSE)\ |
| 7 | [![GitHub Top Language][language-shield]][language] |
| 8 | |
| 9 | ### Magic Home / Surp Life / flux_led |
| 10 | |
| 11 | This is a utility for controlling stand-alone [Magic Home](http://www.zengge.com/appkzd) and [Surp Life](http://www.zengge.com/newbrand) devices manufactured by [Zengge](http://www.zengge.com/sy). |
| 12 | The protocol was reverse-engineered by studying packet captures between a |
| 13 | bulb and the controlling "Magic Home" mobile app. The code here dealing |
| 14 | with the network protocol is littered with magic numbers, and ain't so pretty. |
| 15 | But it does seem to work! |
| 16 | |
| 17 | So far most of the functionality of the apps is available here via the CLI |
| 18 | and/or programmatically. |
| 19 | |
| 20 | The classes in this project could very easily be used as an API, and incorporated into a GUI app written |
| 21 | in PyQt, Kivy, or some other framework. |
| 22 | |
| 23 | #### Minimum python version |
| 24 | |
| 25 | 3.9 |
| 26 | |
| 27 | ##### Available: |
| 28 | |
| 29 | - Discovering bulbs on LAN |
| 30 | - Turning on/off bulb |
| 31 | - Get state information |
| 32 | - Setting "warm white" mode |
| 33 | - Setting single color mode |
| 34 | - Setting preset pattern mode |
| 35 | - Setting custom pattern mode |
| 36 | - Reading timers |
| 37 | - Setting timers |
| 38 | - Sync clock |
| 39 | - Music Mode for devices with a built-in microphone (asyncio version only) |
| 40 | - Remote access administration (asyncio version only) |
| 41 | - Device configuration including wiring order, ic type, pixels, etc (asyncio version only) |
| 42 | |
| 43 | ##### Some missing pieces: |
| 44 | |
| 45 | - Initial administration to set up WiFi SSID and passphrase/key. |
| 46 | |
| 47 | ##### Cool feature: |
| 48 | |
| 49 | - Specify colors with names or web hex values. Requires that python "webcolors" |
| 50 | package is installed. (Easily done via pip, easy_install, or apt-get, etc.) Use --listcolors to show valid color names. |
| 51 | |
| 52 | ##### Installation: |
| 53 | |
| 54 | - Flux_led package available at https://pypi.python.org/pypi/flux-led/ |
| 55 | |
| 56 | ``` |
| 57 | pip install flux_led |
| 58 | ``` |
| 59 | |
| 60 | ##### Examples: |
| 61 | |
| 62 | ``` |
| 63 | Scan network: |
| 64 | flux_led -s |
| 65 | |
| 66 | Scan network and show info about all: |
| 67 | flux_led -sSti |
| 68 | |
| 69 | Turn on: |
| 70 | flux_led 192.168.1.100 --on |
| 71 | flux_led 192.168.1.100 -192.168.1.101 -1 |
| 72 | |
| 73 | Turn on all bulbs on LAN: |
| 74 | flux_led -sS --on |
| 75 | |
| 76 | Turn off: |
| 77 | flux_led 192.168.1.100 --off |
| 78 | flux_led 192.168.1.100 --0 |
| 79 | flux_led -sS --off |
| 80 | |
| 81 | Set warm white, 75% |
| 82 | flux_led 192.168.1.100 -w 75 -1 |
| 83 | |
| 84 | Set fixed color red : |
| 85 | flux_led 192.168.1.100 -c Red |
| 86 | flux_led 192.168.1.100 -c 255,0,0 |
| 87 | flux_led 192.168.1.100 -c "#FF0000" |
| 88 | |
| 89 | Set preset pattern #35 with 40% speed: |
| 90 | flux_led 192.168.1.100 -p 35 40 |
| 91 | |
| 92 | Set custom pattern 25% speed, red/green/blue, gradual change: |
| 93 | flux_led 192.168.1.100 -C gradual 25 "red green (0,0,255)" |
| 94 | |
| 95 | Sync all bulb's clocks with this computer's: |
| 96 | flux_led -sS --setclock |
| 97 | |
| 98 | Set timer #1 to turn on red at 5:30pm on weekdays: |
| 99 | flux_led 192.168.1.100 -T 1 color "time:1730;repeat:12345;color:red" |
| 100 | |
| 101 | Deactivate timer #4: |
| 102 | flux_led 192.168.1.100 -T 4 inactive "" |
| 103 | |
| 104 | Use --timerhelp for more details on setting timers |
| 105 | ``` |
| 106 | |
| 107 | ##### Show help: |
| 108 | |
| 109 | ``` |
| 110 | $ flux_led -h |
| 111 | Usage: usage: __main__.py [-sS10cwpCiltThe] [addr1 [addr2 [addr3] ...]. |
| 112 | |
| 113 | A utility to control Flux WiFi LED Bulbs. |
| 114 | |
| 115 | Options: |
| 116 | -h, --help show this help message and exit |
| 117 | -s, --scan Search for bulbs on local network |
| 118 | -S, --scanresults Operate on scan results instead of arg list |
| 119 | -i, --info Info about bulb(s) state |
| 120 | --getclock Get clock |
| 121 | --setclock Set clock to same as current time on this computer |
| 122 | -t, --timers Show timers |
| 123 | -T NUM MODE SETTINGS, --settimer=NUM MODE SETTINGS |
| 124 | Set timer. NUM: number of the timer (1-6). MODE: |
| 125 | inactive, poweroff, default, color, preset, or |
| 126 | warmwhite. SETTINGS: a string of settings including |
| 127 | time, repeatdays or date, and other mode specific |
| 128 | settings. Use --timerhelp for more details. |
| 129 | |
| 130 | Program help and information option: |
| 131 | -e, --examples Show usage examples |
| 132 | --timerhelp Show detailed help for setting timers |
| 133 | -l, --listpresets List preset codes |
| 134 | --listcolors List color names |
| 135 | |
| 136 | Power options (mutually exclusive): |
| 137 | -1, --on Turn on specified bulb(s) |
| 138 | -0, --off Turn off specified bulb(s) |
| 139 | |
| 140 | Mode options (mutually exclusive): |
| 141 | -c COLOR, --color=COLOR |
| 142 | Set single color mode. Can be either color name, web |
| 143 | hex, or comma-separated RGB triple |
| 144 | -w LEVEL, --warmwhite=LEVEL |
| 145 | Set warm white mode (LEVEL is percent) |
| 146 | -p CODE SPEED, --preset=CODE SPEED |
| 147 | Set preset pattern mode (SPEED is percent) |
| 148 | -C TYPE SPEED COLORLIST, --custom=TYPE SPEED COLORLIST |
| 149 | Set custom pattern mode. TYPE should be jump, gradual, |
| 150 | or strobe. SPEED is percent. COLORLIST is a space- |
| 151 | separated list of color names, web hex values, or |
| 152 | comma-separated RGB triples |
| 153 | |
| 154 | |
| 155 | ``` |
| 156 | |
| 157 | ### Supported Models |
| 158 | |
| 159 | The following models have been tested with library. |
| 160 | |
| 161 | | Model | Description | Microphone | Notes | |
| 162 | | ----- | ----------------------- | ---------- | ----------------------------------------------------------------------------------------------------- | |
| 163 | | 0x01 | Legacy RGB Controller | no | Original protocol | |
| 164 | | 0x03 | Legacy CCT Controller | no | Original protocol | |
| 165 | | 0x04 | UFO Controller RGBW | no | | |
| 166 | | 0x06 | Controller RGBW | no | | |
| 167 | | 0x07 | Controller RGBCW | no | | |
| 168 | | 0x08 | Controller RGB with MIC | yes | | |
| 169 | | 0x09 | Ceiling Light CCT | no | | |
| 170 | | 0x0E | Floor Lamp RGBCW | no | | |
| 171 | | 0x10 | Christmas Light | no | | |
| 172 | | 0x16 | Magnetic Light CCT | no | | |
| 173 | | 0x17 | Magnetic Light Dimmable | no | | |
| 174 | | 0x1A | Christmas Light | no | | |
| 175 | | 0x1C | Table Light CCT | no | | |
| 176 | | 0x1E | Ceiling Light RGBCW | no | | |
| 177 | | 0x21 | Bulb Dimmable | no | | |
| 178 | | 0x25 | Controller RGB/WW/CW | no | Supports RGB, RGBW, RGBWW, CW, DIM | |
| 179 | | 0x33 | Controller RGB | no | | |
| 180 | | 0x35 | Bulb RGBCW | no | | |
| 181 | | 0x41 | Controller Dimmable | no | | |
| 182 | | 0x44 | Bulb RGBW | no | | |
| 183 | | 0x52 | Bulb CCT | no | | |
| 184 | | 0x54 | Downlight RGBW | no | | |
| 185 | | 0x62 | Controller CCT | no | | |
| 186 | | 0x93 | Switch 1 Channel | no | | |
| 187 | | 0x97 | Socket | no | | |
| 188 | | 0xA1 | Addressable v1 | no | Supports UCS1903, SM16703, WS2811, WS2812B, SK6812, INK1003, WS2801, LB1914 | |
| 189 | | 0xA2 | Addressable v2 | yes | Supports UCS1903, SM16703, WS2811, WS2811B, SK6812, INK1003, WS2801, WS2815, APA102, TM1914, UCS2904B | |
| 190 | | 0xA3 | Addressable v3 | yes | Supports WS2812B, SM16703, SM16704, WS2811, UCS1903, SK6812, SK6812RGBW (WS2814), INK1003, UCS2904B | |
| 191 | | 0xA4 | Addressable v4 | no | Supports WS2812B, SM16703, SM16704, WS2811, UCS1903, SK6812, SK6812RGBW (WS2814), INK1003, UCS2904B | |
| 192 | | 0xA6 | Addressable v6 | yes | Supports WS2812B, SM16703, SM16704, WS2811, UCS1903, SK6812, SK6812RGBW (WS2814), INK1003, UCS2904B | |
| 193 | | 0xA7 | Addressable v7 | yes | Supports WS2812B, SM16703, SM16704, WS2811, UCS1903, SK6812, SK6812RGBW (WS2814), INK1003, UCS2904B | |
| 194 | | 0xE1 | Ceiling Light CCT | no | | |
| 195 | | 0xE2 | Ceiling Light Assist | no | Auxiliary Switch not supported | |
| 196 | |
| 197 | ### Untested Models |
| 198 | |
| 199 | The following models have not been tested with the library but may work. |
| 200 | |
| 201 | | Model | Description | Microphone | Notes | |
| 202 | | ----- | -------------------------- | ---------- | ------------------------------- | |
| 203 | | 0x02 | Legacy Dimmable Controller | no | Original protocol, discontinued | |
| 204 | |
| 205 | ### Unsupported Models |
| 206 | |
| 207 | The following models are confirmed to be unsupported. |
| 208 | |
| 209 | | Model | Description | Microphone | Notes | |
| 210 | | ----- | -------------------- | ---------- | ----- | |
| 211 | | 0x18 | Plant Grow Light | no | | |
| 212 | | 0x19 | Socket with 2 USB | no | | |
| 213 | | 0x1B | Aroma Fragrance Lamp | no | | |
| 214 | | 0x1D | Fill Light | no | | |
| 215 | | 0x94 | Switch 1c Watt | no | | |
| 216 | | 0x95 | Switch 2 Channel | no | | |
| 217 | | 0x96 | Switch 4 Channel | no | | |
| 218 | | 0xD1 | Digital Time Lamp | no | | |
| 219 | |
| 220 | ### Known Vendors |
| 221 | |
| 222 | - Aislan |
| 223 | - [Allkeys](http://allkeystech.com/) |
| 224 | - Apobob |
| 225 | - [Arilux](https://www.ariluxworldwide.com/) |
| 226 | - Aubric |
| 227 | - BERENNIS |
| 228 | - BHGY |
| 229 | - [Brizled](https://www.brizled.com/) |
| 230 | - Bunpeon |
| 231 | - [Chichin](https://chichinlighting.com/) |
| 232 | - Comoyda |
| 233 | - dalattin |
| 234 | - [DALS RGBW / Armacost Lighting / MyLED](https://www.armacostlighting.com/) |
| 235 | - DARKPROOF |
| 236 | - [Daybetter](https://www.daybetter.com/) |
| 237 | - deerdance |
| 238 | - DIAMOND |
| 239 | - [Diode Dynamics](https://www.diodedynamics.com/) |
| 240 | - [Flux LED](https://www.fluxsmartlighting.com/) |
| 241 | - [FVTLED](https://fvtled.com/) |
| 242 | - [GEV LIG](https://www.gev.de/) |
| 243 | - GEYUEYA Home |
| 244 | - GIDEALED |
| 245 | - [GIDERWEL](https://giderwel.com/) |
| 246 | - GMK |
| 247 | - Goldwin |
| 248 | - Hakkatronics |
| 249 | - [HaoDeng](http://www.zengge.com/appkzd) |
| 250 | - [Heissner](https://www.heissner.de/) |
| 251 | - HDDFL |
| 252 | - [illume RGBW](https://dals.com/illume/) |
| 253 | - [Illumination FX](https://www.illumination-fx.com/) |
| 254 | - INDARUN |
| 255 | - iNextStation |
| 256 | - [Koopower](https://www.koopower.com/) |
| 257 | - [Lallumer](https://www.lapuretes.cn/) |
| 258 | - LEDENET |
| 259 | - [LiteWRX](https://litewrx.com/) |
| 260 | - Lytworx |
| 261 | - Magic Ambient |
| 262 | - [Magic Home](http://www.zengge.com/appkzd) |
| 263 | - [Magic Hue](http://www.magichue.com/) |
| 264 | - [Magic Light](https://www.magiclightbulbs.com/) |
| 265 | - Miheal |
| 266 | - Mowelai |
| 267 | - Nexlux |
| 268 | - OBSESS |
| 269 | - [Offdarks](http://offdarks.net) |
| 270 | - PH LED |
| 271 | - PHOPOLLO |
| 272 | - [Pin Stadium Pinball Lights](https://pinstadium.com/) |
| 273 | - POV Lamp |
| 274 | - [PROTEAM Europe Pool Lights](https://proteam-me.com/) |
| 275 | - [Rimikon](https://www.rimikon.com/) |
| 276 | - SMFX |
| 277 | - [Sumaote](https://fvtled.com/) |
| 278 | - [Superhome](https://superhome.com.cy/) |
| 279 | - [SurpLife](http://www.zengge.com/newbrand) |
| 280 | - [SuperlightingLED](https://www.superlightingled.com/) |
| 281 | - Svipear |
| 282 | - Tommox |
| 283 | - Vanance |
| 284 | - Yetaida |
| 285 | - YHW |
| 286 | - [Zengge](http://www.zengge.com/sy) |
| 287 | - Zombber |
| 288 | |
| 289 | ### File Structure |
| 290 | |
| 291 | device.py -> contains code to manipulate device as well as get any information from device that's needed.\ |
| 292 | fluxled.py -> command line code for flux_led.\ |
| 293 | pattern.py -> contains code to identify pattern as well as set patterns.\ |
| 294 | protocol.py -> contains communication protocol to communicate with differnt devices.\ |
| 295 | scanner.py -> contins scanner to scan network and identify devices on network.\ |
| 296 | sock.py -> contains code to communicate on network.\ |
| 297 | timer.py -> contains code to support setting timers on devices and getting timer information from devices.\ |
| 298 | utils.py -> contains helpers to calculate differnt parameters such as color, cct, brightness etc. |
| 299 | |
| 300 | [code-coverage]: https://codecov.io/gh/Danielhiversen/flux_led |
| 301 | [code-cover-shield]: https://codecov.io/gh/Danielhiversen/flux_led/branch/master/graph/badge.svg |
| 302 | [commits-shield]: https://img.shields.io/github/commit-activity/y/Danielhiversen/flux_led.svg |
| 303 | [commits]: https://github.com/Danielhiversen/flux_led/commits/main |
| 304 | [language]: https://github.com/Danielhiversen/flux_led/search?l=python |
| 305 | [language-shield]: https://img.shields.io/github/languages/top/Danielhiversen/flux_led |
| 306 | [license-shield]: https://img.shields.io/github/license/Danielhiversen/flux_led.svg |
| 307 | [pypi]: https://pypi.org/project/flux_led/ |
| 308 | [pypi-shield]: https://img.shields.io/pypi/v/flux_led |
| 309 | [python-package]: https://github.com/Danielhiversen/flux_led/actions/workflows/python-package.yml |
| 310 | [python-package-shield]: https://github.com/Danielhiversen/flux_led/actions/workflows/python-package.yml/badge.svg?branch=master |
| 311 | [python-ver]: https://pypi.python.org/pypi/flux_led/ |
| 312 | [python-ver-shield]: https://img.shields.io/pypi/pyversions/flux_led.svg |