File: example_light_state.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 (26 lines) | stat: -rw-r--r-- 684 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
"""Example for reading the state from the KNX bus."""

import asyncio

from xknx import XKNX
from xknx.devices import Light


async def main() -> None:
    """Connect to KNX/IP bus and read the state of a Light device."""
    async with XKNX() as xknx:
        light = Light(
            xknx,
            name="TestLight2",
            group_address_switch="1/0/12",
            group_address_brightness="1/0/14",
        )
        xknx.devices.async_add(light)

        await light.set_brightness(80)
        # Will do a GroupValueRead for both addresses and block until a result is received
        await light.sync(wait_for_result=True)
        print(light)


asyncio.run(main())