File: example_light_rgbw.py

package info (click to toggle)
python-xknx 3.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,012 kB
  • sloc: python: 39,710; javascript: 8,556; makefile: 27; sh: 12
file content (50 lines) | stat: -rw-r--r-- 1,312 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""Example for setting different colors on a RGBW remote value."""

import asyncio

from xknx import XKNX
from xknx.dpt import RGBWColor
from xknx.remote_value import RemoteValueColorRGBW


async def main() -> None:
    """Connect to KNX/IP bus and set different colors."""
    xknx = XKNX()
    await xknx.start()

    rgbw = RemoteValueColorRGBW(
        xknx,
        group_address="1/1/40",
        group_address_state="1/1/41",
        device_name="RGBWLight",
    )

    rgbw.set(RGBWColor(255, 255, 255, 0))  # cold-white
    await asyncio.sleep(1)
    rgbw.set(RGBWColor(0, 0, 0, 255))  # warm-white
    await asyncio.sleep(1)
    rgbw.set(RGBWColor(0, 0, 0, 0))  # off
    await asyncio.sleep(1)

    rgbw.set(RGBWColor(255, 0, 0, 0))  # red
    await asyncio.sleep(1)
    rgbw.set(RGBWColor(0, 255, 0, 0))  # green
    await asyncio.sleep(1)
    rgbw.set(RGBWColor(0, 0, 255, 0))  # blue
    await asyncio.sleep(1)
    rgbw.set(RGBWColor(0, 0, 0, 0))  # off
    await asyncio.sleep(1)

    rgbw.set(RGBWColor(255, 255, 0, 0))
    await asyncio.sleep(1)
    rgbw.set(RGBWColor(0, 255, 255, 0))
    await asyncio.sleep(1)
    rgbw.set(RGBWColor(255, 0, 255, 0))
    await asyncio.sleep(1)
    rgbw.set(RGBWColor(0, 0, 0, 0))  # off
    await asyncio.sleep(1)

    await xknx.stop()


asyncio.run(main())