Home Assistant Unofficial Reference 2024.12.1
__init__.py
Go to the documentation of this file.
1 """The Eight Sleep integration."""
2 
3 from __future__ import annotations
4 
5 from homeassistant.config_entries import ConfigEntry, ConfigEntryState
6 from homeassistant.core import HomeAssistant
7 from homeassistant.helpers import issue_registry as ir
8 
9 DOMAIN = "eight_sleep"
10 
11 
12 async def async_setup_entry(hass: HomeAssistant, _: ConfigEntry) -> bool:
13  """Set up Eight Sleep from a config entry."""
14  ir.async_create_issue(
15  hass,
16  DOMAIN,
17  DOMAIN,
18  is_fixable=False,
19  severity=ir.IssueSeverity.ERROR,
20  translation_key="integration_removed",
21  translation_placeholders={
22  "entries": "/config/integrations/integration/eight_sleep"
23  },
24  )
25 
26  return True
27 
28 
29 async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
30  """Unload a config entry."""
31  if all(
32  config_entry.state is ConfigEntryState.NOT_LOADED
33  for config_entry in hass.config_entries.async_entries(DOMAIN)
34  if config_entry.entry_id != entry.entry_id
35  ):
36  ir.async_delete_issue(hass, DOMAIN, DOMAIN)
37 
38  return True
bool async_setup_entry(HomeAssistant hass, ConfigEntry _)
Definition: __init__.py:12
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:29