Skip to content

Commit

Permalink
Add example for custom flow
Browse files Browse the repository at this point in the history
  • Loading branch information
vrachieru committed Dec 8, 2018
1 parent 8f0ce00 commit 932d91d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

* Query device information
* Change bulb state
* Set RGB color
* Set custom flow

## Install

Expand Down Expand Up @@ -72,6 +74,34 @@ $ python3 toggle.py
Bulb powered on
```

### Set custom flow

The following will transition between the colors `RED`, `GREEN`, `BLUE` at `100%` brightness with a transition duration of `1s` and `1s` delay between transitions.

```python
from yeelight import SmartBulb, Flow, RGBTransition, SleepTransition

RED = [255, 0, 0]
GREEN = [0, 255, 0]
BLUE = [0, 0, 255]

flow = Flow(
10,
Flow.actions.recover,
[
RGBTransition(*RED, 1000, 100),
SleepTransition(1000),
RGBTransition(*GREEN, 1000, 100),
SleepTransition(1000),
RGBTransition(*BLUE, 1000, 100),
SleepTransition(1000)
]
)

bulb = SmartBulb('192.168.xxx.xxxx')
bulb.start_flow(flow)
```

## License

MIT
24 changes: 24 additions & 0 deletions example/flow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import sys
sys.path.append('../')

from yeelight import SmartBulb, Flow, RGBTransition, SleepTransition

RED = [255, 0, 0]
GREEN = [0, 255, 0]
BLUE = [0, 0, 255]

flow = Flow(
10,
Flow.actions.recover,
[
RGBTransition(*RED, 1000, 100),
SleepTransition(1000),
RGBTransition(*GREEN, 1000, 100),
SleepTransition(1000),
RGBTransition(*BLUE, 1000, 100),
SleepTransition(1000)
]
)

bulb = SmartBulb('192.168.1.103')
bulb.start_flow(flow)

0 comments on commit 932d91d

Please sign in to comment.