File: example_send_telegrams.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 (23 lines) | stat: -rw-r--r-- 669 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
"""Example for sending generic telegrams to the KNX bus."""

import asyncio
import logging

from xknx import XKNX
from xknx.tools import group_value_response, group_value_write

logging.basicConfig(level=logging.INFO)
logging.getLogger("xknx.log").level = logging.DEBUG
logging.getLogger("xknx.tools").level = logging.DEBUG


async def main() -> None:
    """Connect to KNX bus and send telegrams."""
    async with XKNX() as xknx:
        # send a DPT 9.001 temperature value
        group_value_write(xknx, "5/1/20", 21.7, value_type="temperature")
        # send a response DPT 1 binary value
        group_value_response(xknx, "5/1/20", True)


asyncio.run(main())