mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
Use setdefault()
in scaffold script for setting hass.data
(#103338)
This commit is contained in:
parent
bb8375da72
commit
5cd27a877e
@ -11,7 +11,7 @@ from .const import DOMAIN
|
|||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up NEW_NAME from a config entry."""
|
"""Set up NEW_NAME from a config entry."""
|
||||||
# TODO Optionally store an object for your platforms to access
|
# TODO Optionally store an object for your platforms to access
|
||||||
# hass.data[DOMAIN][entry.entry_id] = ...
|
# hass.data.setdefault(DOMAIN, {})[entry.entry_id] = ...
|
||||||
|
|
||||||
# TODO Optionally validate config entry options before setting up platform
|
# TODO Optionally validate config entry options before setting up platform
|
||||||
|
|
||||||
|
@ -25,10 +25,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation)
|
session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation)
|
||||||
|
|
||||||
# If using a requests-based API lib
|
# If using a requests-based API lib
|
||||||
hass.data[DOMAIN][entry.entry_id] = api.ConfigEntryAuth(hass, session)
|
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = api.ConfigEntryAuth(
|
||||||
|
hass, session
|
||||||
|
)
|
||||||
|
|
||||||
# If using an aiohttp-based API lib
|
# If using an aiohttp-based API lib
|
||||||
hass.data[DOMAIN][entry.entry_id] = api.AsyncConfigEntryAuth(
|
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = api.AsyncConfigEntryAuth(
|
||||||
aiohttp_client.async_get_clientsession(hass), session
|
aiohttp_client.async_get_clientsession(hass), session
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user