Use HassKey in azure_event_hub (#127086)
This commit is contained in:
parent
34a4372190
commit
70d4ee93f5
2 changed files with 8 additions and 8 deletions
|
@ -20,11 +20,12 @@ from homeassistant.const import MATCH_ALL
|
|||
from homeassistant.core import Event, HomeAssistant, State
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entityfilter import FILTER_SCHEMA
|
||||
from homeassistant.helpers.entityfilter import FILTER_SCHEMA, EntityFilter
|
||||
from homeassistant.helpers.event import async_call_later
|
||||
from homeassistant.helpers.json import JSONEncoder
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
from homeassistant.util.dt import utcnow
|
||||
from homeassistant.util.hass_dict import HassKey
|
||||
|
||||
from .client import AzureEventHubClient
|
||||
from .const import (
|
||||
|
@ -36,7 +37,6 @@ from .const import (
|
|||
CONF_FILTER,
|
||||
CONF_MAX_DELAY,
|
||||
CONF_SEND_INTERVAL,
|
||||
DATA_FILTER,
|
||||
DEFAULT_MAX_DELAY,
|
||||
DOMAIN,
|
||||
FILTER_STATES,
|
||||
|
@ -63,6 +63,7 @@ CONFIG_SCHEMA = vol.Schema(
|
|||
},
|
||||
extra=vol.ALLOW_EXTRA,
|
||||
)
|
||||
DATA_COMPONENT: HassKey[EntityFilter] = HassKey(DOMAIN)
|
||||
|
||||
|
||||
async def async_setup(hass: HomeAssistant, yaml_config: ConfigType) -> bool:
|
||||
|
@ -73,10 +74,10 @@ async def async_setup(hass: HomeAssistant, yaml_config: ConfigType) -> bool:
|
|||
If config is empty after getting the filter, return, otherwise emit
|
||||
deprecated warning and pass the rest to the config flow.
|
||||
"""
|
||||
hass.data.setdefault(DOMAIN, {DATA_FILTER: FILTER_SCHEMA({})})
|
||||
if DOMAIN not in yaml_config:
|
||||
hass.data[DATA_COMPONENT] = FILTER_SCHEMA({})
|
||||
return True
|
||||
hass.data[DOMAIN][DATA_FILTER] = yaml_config[DOMAIN].pop(CONF_FILTER)
|
||||
hass.data[DATA_COMPONENT] = yaml_config[DOMAIN].pop(CONF_FILTER)
|
||||
|
||||
if not yaml_config[DOMAIN]:
|
||||
return True
|
||||
|
@ -98,11 +99,10 @@ async def async_setup_entry(
|
|||
hass: HomeAssistant, entry: AzureEventHubConfigEntry
|
||||
) -> bool:
|
||||
"""Do the setup based on the config entry and the filter from yaml."""
|
||||
hass.data.setdefault(DOMAIN, {DATA_FILTER: FILTER_SCHEMA({})})
|
||||
hub = AzureEventHub(
|
||||
hass,
|
||||
entry,
|
||||
hass.data[DOMAIN][DATA_FILTER],
|
||||
hass.data[DATA_COMPONENT],
|
||||
)
|
||||
try:
|
||||
await hub.async_test_connection()
|
||||
|
@ -136,7 +136,7 @@ class AzureEventHub:
|
|||
self,
|
||||
hass: HomeAssistant,
|
||||
entry: ConfigEntry,
|
||||
entities_filter: vol.Schema,
|
||||
entities_filter: EntityFilter,
|
||||
) -> None:
|
||||
"""Initialize the listener."""
|
||||
self.hass = hass
|
||||
|
|
|
@ -16,7 +16,7 @@ CONF_EVENT_HUB_SAS_KEY = "event_hub_sas_key"
|
|||
CONF_EVENT_HUB_CON_STRING = "event_hub_connection_string"
|
||||
CONF_SEND_INTERVAL = "send_interval"
|
||||
CONF_MAX_DELAY = "max_delay"
|
||||
CONF_FILTER = DATA_FILTER = "filter"
|
||||
CONF_FILTER = "filter"
|
||||
|
||||
STEP_USER = "user"
|
||||
STEP_SAS = "sas"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue