mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Make sure Notion data storage conforms to standards (#57812)
This commit is contained in:
parent
fd49da37b8
commit
b6ed8ca206
@ -39,7 +39,8 @@ CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
|||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up Notion as a config entry."""
|
"""Set up Notion as a config entry."""
|
||||||
hass.data.setdefault(DOMAIN, {DATA_COORDINATOR: {}})
|
hass.data.setdefault(DOMAIN, {})
|
||||||
|
hass.data[DOMAIN][entry.entry_id] = {}
|
||||||
|
|
||||||
if not entry.unique_id:
|
if not entry.unique_id:
|
||||||
hass.config_entries.async_update_entry(
|
hass.config_entries.async_update_entry(
|
||||||
@ -89,9 +90,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
coordinator = hass.data[DOMAIN][DATA_COORDINATOR][
|
coordinator = DataUpdateCoordinator(
|
||||||
entry.entry_id
|
|
||||||
] = DataUpdateCoordinator(
|
|
||||||
hass,
|
hass,
|
||||||
LOGGER,
|
LOGGER,
|
||||||
name=entry.data[CONF_USERNAME],
|
name=entry.data[CONF_USERNAME],
|
||||||
@ -100,6 +99,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
)
|
)
|
||||||
|
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
|
hass.data[DOMAIN][entry.entry_id][DATA_COORDINATOR] = coordinator
|
||||||
|
|
||||||
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
"""Unload a Notion config entry."""
|
"""Unload a Notion config entry."""
|
||||||
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN][DATA_COORDINATOR].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
|
|
||||||
return unload_ok
|
return unload_ok
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ async def async_setup_entry(
|
|||||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Notion sensors based on a config entry."""
|
"""Set up Notion sensors based on a config entry."""
|
||||||
coordinator = hass.data[DOMAIN][DATA_COORDINATOR][entry.entry_id]
|
coordinator = hass.data[DOMAIN][entry.entry_id][DATA_COORDINATOR]
|
||||||
|
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
[
|
[
|
||||||
|
@ -27,7 +27,7 @@ async def async_setup_entry(
|
|||||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Notion sensors based on a config entry."""
|
"""Set up Notion sensors based on a config entry."""
|
||||||
coordinator = hass.data[DOMAIN][DATA_COORDINATOR][entry.entry_id]
|
coordinator = hass.data[DOMAIN][entry.entry_id][DATA_COORDINATOR]
|
||||||
|
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
[
|
[
|
||||||
|
Loading…
x
Reference in New Issue
Block a user