Pass the real config for Discord (#76959)

This commit is contained in:
Robert Hillis 2022-08-17 22:41:59 -04:00 committed by GitHub
parent 280ae91ba1
commit 6ab9652b60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View File

@ -7,12 +7,20 @@ from homeassistant.const import CONF_API_TOKEN, Platform
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
from homeassistant.helpers import discovery from homeassistant.helpers import discovery
from homeassistant.helpers.typing import ConfigType
from .const import DOMAIN from .const import DATA_HASS_CONFIG, DOMAIN
PLATFORMS = [Platform.NOTIFY] PLATFORMS = [Platform.NOTIFY]
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Discord component."""
hass.data[DATA_HASS_CONFIG] = config
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Discord from a config entry.""" """Set up Discord from a config entry."""
nextcord.VoiceClient.warn_nacl = False nextcord.VoiceClient.warn_nacl = False
@ -30,11 +38,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
hass.async_create_task( hass.async_create_task(
discovery.async_load_platform( discovery.async_load_platform(
hass, hass, Platform.NOTIFY, DOMAIN, dict(entry.data), hass.data[DATA_HASS_CONFIG]
Platform.NOTIFY,
DOMAIN,
hass.data[DOMAIN][entry.entry_id],
hass.data[DOMAIN],
) )
) )

View File

@ -8,3 +8,5 @@ DEFAULT_NAME = "Discord"
DOMAIN: Final = "discord" DOMAIN: Final = "discord"
URL_PLACEHOLDER = {CONF_URL: "https://www.home-assistant.io/integrations/discord"} URL_PLACEHOLDER = {CONF_URL: "https://www.home-assistant.io/integrations/discord"}
DATA_HASS_CONFIG = "discord_hass_config"