A library to interface with Magichue(or Magichome)
Project description
python-magichue
Magichue(as known as Magichome) is a cheap smart led bulb that you can controll hue/saturation/brightnes and power over WiFi. They are available at Amazon or other online web shop.
I tested this library with this bulb.
Installation
$ pip install python-magichue
Usage
import magichue.
import magichue
light = magichue.Light('192.168.0.20')
Power State
Getting power status.
print(light.on) # => True if light is on else False
Setting light on/off.
light.on = True
light.on = False
Getting color
This shows a tuple of current RGB.
print(light.rgb)
or access individually.
print(light.r)
print(light.g)
print(light.b)
Warm White bulb
Magichue has a two types of leds. One is rgb led and the other is warm white led. To use warm white led, do as following.
light.is_white = True
# light.is_white = False # This disables warm white led.
If warm white is enabled, you can't set color to bulb.
Setting color
By rgb
light.rgb = (128, 0, 32)
or
light.r = 200
By hsb
light.hue = 0.3
light.saturation = 0.6
light.brightness = 255
hue, saturation are float value from 0 to 1. brightness is a integer value from 0 to 255. These variables are also readable.
Changing mode
Magichue blub has a built-in flash patterns.
To check current mode, just
print(light.mode)
and changing modes,
light.mode = magichue.RAINBOW_CROSSFADE
These are built-in modes.
RAINBOW_CROSSFADE
RED_GRADUALLY
GREEN_GRADUALLY
BLUE_GRADUALLY
YELLOW_GRADUALLY
BLUE_GREEN_GRADUALLY
PURPLE_GRADUALLY
WHITE_GRADUALLY
RED_GREEN_CROSSFADE
RED_BLUE_CROSSFADE
GREEN_BLUE_CROSSFADE
RAINBOW_STROBE
GREEN_STROBE
BLUE_STROBE
YELLOW_STROBE
BLUE_GREEN_STROBE
PURPLE_STROBE
WHITE_STROBE
RAINBOW_FLASH
NORMAL
Example
Rainbow cross-fade.
import time
import magichue
light = magichue.Light('192.168.0.20') # change address
if not light.on:
light.on = True
if light.is_white:
light.is_white = False
light.rgb = (255, 255, 255)
for hue in range(1000):
light.hue = hue / 1000
time.sleep(0.05)
Other features are in development.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for python_magichue-0.2.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89395301a2e16a560d1a3d914761fa48d3dc427f46509e41b6a3bc7dee8c7299 |
|
MD5 | b7c4610bffb6a674088ecf4357b770a3 |
|
BLAKE2b-256 | f70c15614487d9e4e0b9c22eed9e133893915e45a6f99ad2f016d89cd9a91097 |