Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.usb Namespace Reference

Namespaces

 const
 
 models
 
 utils
 

Classes

class  USBCallbackMatcher
 
class  USBDiscovery
 
class  UsbServiceInfo
 

Functions

bool _fnmatch_lower (str|None name, str pattern)
 
bool _is_matching (USBDevice device, USBMatcher|USBCallbackMatcher matcher)
 
bool async_is_plugged_in (HomeAssistant hass, USBCallbackMatcher matcher)
 
CALLBACK_TYPE async_register_initial_scan_callback (HomeAssistant hass, CALLBACK_TYPE callback)
 
CALLBACK_TYPE async_register_scan_request_callback (HomeAssistant hass, CALLBACK_TYPE callback)
 
bool async_setup (HomeAssistant hass, ConfigType config)
 
str get_serial_by_id (str dev_path)
 
str human_readable_device_name (str device, str|None serial_number, str|None manufacturer, str|None description, str|None vid, str|None pid)
 
None websocket_usb_scan (HomeAssistant hass, ActiveConnection connection, dict[str, Any] msg)
 

Variables

list __all__
 
 _LOGGER = logging.getLogger(__name__)
 
 CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN)
 
int REQUEST_SCAN_COOLDOWN = 60
 

Detailed Description

The USB Discovery integration.

Function Documentation

◆ _fnmatch_lower()

bool homeassistant.components.usb._fnmatch_lower ( str | None  name,
str  pattern 
)
private
Match a lowercase version of the name.

Definition at line 161 of file __init__.py.

◆ _is_matching()

bool homeassistant.components.usb._is_matching ( USBDevice  device,
USBMatcher | USBCallbackMatcher  matcher 
)
private
Return True if a device matches.

Definition at line 168 of file __init__.py.

◆ async_is_plugged_in()

bool homeassistant.components.usb.async_is_plugged_in ( HomeAssistant  hass,
USBCallbackMatcher  matcher 
)
Return True is a USB device is present.

Definition at line 80 of file __init__.py.

◆ async_register_initial_scan_callback()

CALLBACK_TYPE homeassistant.components.usb.async_register_initial_scan_callback ( HomeAssistant  hass,
CALLBACK_TYPE   callback 
)
Register to receive a callback when the initial USB scan is done.

If the initial scan is already done, the callback is called immediately.

Definition at line 68 of file __init__.py.

◆ async_register_scan_request_callback()

CALLBACK_TYPE homeassistant.components.usb.async_register_scan_request_callback ( HomeAssistant  hass,
CALLBACK_TYPE   callback 
)
Register to receive a callback when a scan should be initiated.

Definition at line 59 of file __init__.py.

◆ async_setup()

bool homeassistant.components.usb.async_setup ( HomeAssistant  hass,
ConfigType  config 
)
Set up the USB Discovery integration.

Definition at line 150 of file __init__.py.

◆ get_serial_by_id()

str homeassistant.components.usb.get_serial_by_id ( str  dev_path)
Return a /dev/serial/by-id match for given device if available.

Definition at line 138 of file __init__.py.

◆ human_readable_device_name()

str homeassistant.components.usb.human_readable_device_name ( str  device,
str | None  serial_number,
str | None  manufacturer,
str | None  description,
str | None  vid,
str | None  pid 
)
Return a human readable name from USBDevice attributes.

Definition at line 119 of file __init__.py.

◆ websocket_usb_scan()

None homeassistant.components.usb.websocket_usb_scan ( HomeAssistant  hass,
ActiveConnection  connection,
dict[str, Any]  msg 
)
Scan for new usb devices.

Definition at line 428 of file __init__.py.

Variable Documentation

◆ __all__

list homeassistant.components.usb.__all__
private
Initial value:
1 = [
2  "async_is_plugged_in",
3  "async_register_scan_request_callback",
4  "USBCallbackMatcher",
5  "UsbServiceInfo",
6 ]

Definition at line 44 of file __init__.py.

◆ _LOGGER

homeassistant.components.usb._LOGGER = logging.getLogger(__name__)
private

Definition at line 40 of file __init__.py.

◆ CONFIG_SCHEMA

homeassistant.components.usb.CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN)

Definition at line 51 of file __init__.py.

◆ REQUEST_SCAN_COOLDOWN

int homeassistant.components.usb.REQUEST_SCAN_COOLDOWN = 60

Definition at line 42 of file __init__.py.