Home Assistant Unofficial Reference 2024.12.1
__init__.py
Go to the documentation of this file.
1 """The Internet Printing Protocol (IPP) integration."""
2 
3 from __future__ import annotations
4 
5 from homeassistant.config_entries import ConfigEntry
6 from homeassistant.const import (
7  CONF_HOST,
8  CONF_PORT,
9  CONF_SSL,
10  CONF_VERIFY_SSL,
11  Platform,
12 )
13 from homeassistant.core import HomeAssistant
14 
15 from .const import CONF_BASE_PATH
16 from .coordinator import IPPDataUpdateCoordinator
17 
18 PLATFORMS = [Platform.SENSOR]
19 
20 type IPPConfigEntry = ConfigEntry[IPPDataUpdateCoordinator]
21 
22 
23 async def async_setup_entry(hass: HomeAssistant, entry: IPPConfigEntry) -> bool:
24  """Set up IPP from a config entry."""
25  # config flow sets this to either UUID, serial number or None
26  if (device_id := entry.unique_id) is None:
27  device_id = entry.entry_id
28 
29  coordinator = IPPDataUpdateCoordinator(
30  hass,
31  host=entry.data[CONF_HOST],
32  port=entry.data[CONF_PORT],
33  base_path=entry.data[CONF_BASE_PATH],
34  tls=entry.data[CONF_SSL],
35  verify_ssl=entry.data[CONF_VERIFY_SSL],
36  device_id=device_id,
37  )
38  await coordinator.async_config_entry_first_refresh()
39 
40  entry.runtime_data = coordinator
41 
42  await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
43 
44  return True
45 
46 
47 async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
48  """Unload a config entry."""
49  return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool async_setup_entry(HomeAssistant hass, IPPConfigEntry entry)
Definition: __init__.py:23
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:47