Home Assistant Unofficial Reference 2024.12.1
homeassistant.util.network Namespace Reference

Functions

bool is_host_valid (str host)
 
bool is_invalid (IPv4Address|IPv6Address address)
 
bool is_ip_address (str address)
 
bool is_ipv4_address (str address)
 
bool is_ipv6_address (str address)
 
bool is_link_local (IPv4Address|IPv6Address address)
 
bool is_local (IPv4Address|IPv6Address address)
 
bool is_loopback (IPv4Address|IPv6Address address)
 
bool is_private (IPv4Address|IPv6Address address)
 
str normalize_url (str address)
 

Variables

 IPV6_IPV4_LOOPBACK = ip_network("::ffff:127.0.0.0/104")
 
tuple LINK_LOCAL_NETWORKS
 
tuple LOOPBACK_NETWORKS
 
tuple PRIVATE_NETWORKS
 

Detailed Description

Network utilities.

Function Documentation

◆ is_host_valid()

bool homeassistant.util.network.is_host_valid ( str  host)
Check if a given string is an IP address or valid hostname.

Definition at line 93 of file network.py.

◆ is_invalid()

bool homeassistant.util.network.is_invalid ( IPv4Address | IPv6Address  address)
Check if an address is invalid.

Definition at line 58 of file network.py.

◆ is_ip_address()

bool homeassistant.util.network.is_ip_address ( str  address)
Check if a given string is an IP address.

Definition at line 63 of file network.py.

◆ is_ipv4_address()

bool homeassistant.util.network.is_ipv4_address ( str  address)
Check if a given string is an IPv4 address.

Definition at line 73 of file network.py.

◆ is_ipv6_address()

bool homeassistant.util.network.is_ipv6_address ( str  address)
Check if a given string is an IPv6 address.

Definition at line 83 of file network.py.

◆ is_link_local()

bool homeassistant.util.network.is_link_local ( IPv4Address | IPv6Address  address)
Check if an address is link-local (local but not necessarily unique).

Definition at line 48 of file network.py.

◆ is_local()

bool homeassistant.util.network.is_local ( IPv4Address | IPv6Address  address)
Check if an address is on a local network.

Definition at line 53 of file network.py.

◆ is_loopback()

bool homeassistant.util.network.is_loopback ( IPv4Address | IPv6Address  address)
Check if an address is a loopback address.

Definition at line 38 of file network.py.

◆ is_private()

bool homeassistant.util.network.is_private ( IPv4Address | IPv6Address  address)
Check if an address is a unique local non-loopback address.

Definition at line 43 of file network.py.

◆ normalize_url()

str homeassistant.util.network.normalize_url ( str  address)
Normalize a given URL.

Definition at line 107 of file network.py.

Variable Documentation

◆ IPV6_IPV4_LOOPBACK

homeassistant.util.network.IPV6_IPV4_LOOPBACK = ip_network("::ffff:127.0.0.0/104")

Definition at line 11 of file network.py.

◆ LINK_LOCAL_NETWORKS

tuple homeassistant.util.network.LINK_LOCAL_NETWORKS
Initial value:
1 = (
2  ip_network("169.254.0.0/16"),
3  ip_network("fe80::/10"),
4  ip_network("::ffff:169.254.0.0/112"),
5 )

Definition at line 31 of file network.py.

◆ LOOPBACK_NETWORKS

tuple homeassistant.util.network.LOOPBACK_NETWORKS
Initial value:
1 = (
2  ip_network("127.0.0.0/8"),
3  ip_network("::1/128"),
4  IPV6_IPV4_LOOPBACK,
5 )

Definition at line 13 of file network.py.

◆ PRIVATE_NETWORKS

tuple homeassistant.util.network.PRIVATE_NETWORKS
Initial value:
1 = (
2  ip_network("10.0.0.0/8"),
3  ip_network("172.16.0.0/12"),
4  ip_network("192.168.0.0/16"),
5  ip_network("fd00::/8"),
6  ip_network("::ffff:10.0.0.0/104"),
7  ip_network("::ffff:172.16.0.0/108"),
8  ip_network("::ffff:192.168.0.0/112"),
9 )

Definition at line 20 of file network.py.