File: example_fan_percent_mode.py

package info (click to toggle)
python-xknx 3.10.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,044 kB
  • sloc: python: 40,087; javascript: 8,556; makefile: 32; sh: 12
file content (37 lines) | stat: -rw-r--r-- 715 bytes parent folder | download | duplicates (2)
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
"""Example for Fan device."""

import asyncio

from xknx import XKNX
from xknx.devices import Fan


async def main() -> None:
    """Connect to KNX/IP bus, control a fan, and turn it off afterwards."""
    xknx = XKNX()
    await xknx.start()

    fan = Fan(
        xknx,
        name="TestFan",
        group_address_switch="1/0/12",
        group_address_speed="1/0/14",
        max_step=3,
    )
    xknx.devices.async_add(fan)

    # Turn on the fan
    await fan.turn_on()

    # Set fan speed to different levels
    for speed in [0, 33, 66, 100]:
        await fan.set_speed(speed)
        await asyncio.sleep(1)

    # Turn off the fan
    await fan.turn_off()

    await xknx.stop()


asyncio.run(main())