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 38 39 40
|
"""Example for GatewayScanner."""
import asyncio
from xknx import XKNX
from xknx.io import GatewayScanner
async def main() -> None:
"""Search for available KNX/IP devices with GatewayScanner and print out result if a device was found."""
xknx = XKNX()
gatewayscanner = GatewayScanner(xknx)
async for gateway in gatewayscanner.async_scan():
print(f"{gateway.individual_address} {gateway.name}")
print(f" {gateway.ip_addr}:{gateway.port}")
tunnelling = (
"Secure"
if gateway.tunnelling_requires_secure
else "TCP"
if gateway.supports_tunnelling_tcp
else "UDP"
if gateway.supports_tunnelling
else "No"
)
print(f" Tunnelling: {tunnelling}")
routing = (
"Secure"
if gateway.routing_requires_secure
else "Yes"
if gateway.supports_routing
else "No"
)
print(f" Routing: {routing}")
if not gatewayscanner.found_gateways:
print("No Gateways found")
asyncio.run(main())
|