File: example_restart.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 (25 lines) | stat: -rw-r--r-- 556 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
"""Example on how to connect to restart a KNX device."""

import asyncio
import sys

from xknx import XKNX
from xknx.management.procedures import dm_restart
from xknx.telegram import IndividualAddress


async def main(argv: list[str]) -> int:
    """Restart a KNX device."""
    if len(argv) != 2:
        print(f"{argv[0]}: missing target address.")
        return 1

    address = IndividualAddress(argv[1])

    async with XKNX() as xknx:
        await dm_restart(xknx, address)
    return 0


if __name__ == "__main__":
    asyncio.run(main(sys.argv))