Skip to content

Commit

Permalink
Add example for controlling a fan with step mode
Browse files Browse the repository at this point in the history
  • Loading branch information
oldcorvus committed Dec 2, 2023
1 parent b7af950 commit 9d31cc4
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions examples/example_fan_step_mode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Example for Fan device."""
import asyncio
from xknx import XKNX
from xknx.devices import Fan, FanSpeedMode

async def main():
"""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,
)

# Turn on the fan
await fan.turn_on()

# Set fan speed in steps
for step in range(1, fan.max_step + 1):
await fan.set_speed(step)
await asyncio.sleep(1)

# Turn off the fan
await fan.turn_off()

await xknx.stop()

asyncio.run(main())

0 comments on commit 9d31cc4

Please sign in to comment.