File: aio.py

package info (click to toggle)
flux-led 1.0.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 832 kB
  • sloc: python: 13,359; makefile: 9; sh: 5
file content (30 lines) | stat: -rw-r--r-- 712 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import asyncio
import logging
import pprint

from flux_led.aio import AIOWifiLedBulb

logging.basicConfig(level=logging.DEBUG)


async def go():
    bulb = AIOWifiLedBulb("192.168.107.91")

    def _async_updated():
        pprint.pprint(["State Changed!", bulb.raw_state])

    await bulb.async_setup(_async_updated)
    while True:
        await bulb.async_turn_on()
        await asyncio.sleep(2)
        await bulb.async_update()
        await asyncio.sleep(2)
        await bulb.async_set_levels(255, 0, 0)
        await asyncio.sleep(2)
        await bulb.async_set_white_temp(2700, 255)
        await asyncio.sleep(2)
        await bulb.async_turn_off()
        await asyncio.sleep(2)


asyncio.run(go())