mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Remove ability to configure monitored conditions in IQVIA (#32223)
* Remove ability to configure monitored conditions in IQVIA * Deprecate instead of removing (until 0.108.0) * Simplify imports * Update version
This commit is contained in:
parent
5bdf450f78
commit
9329bc4ca0
@ -59,13 +59,16 @@ FETCHER_MAPPING = {
|
|||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema(
|
CONFIG_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
DOMAIN: vol.Schema(
|
DOMAIN: vol.All(
|
||||||
{
|
cv.deprecated(CONF_MONITORED_CONDITIONS, invalidation_version="0.114.0"),
|
||||||
vol.Required(CONF_ZIP_CODE): str,
|
vol.Schema(
|
||||||
vol.Required(CONF_MONITORED_CONDITIONS, default=list(SENSORS)): vol.All(
|
{
|
||||||
cv.ensure_list, [vol.In(SENSORS)]
|
vol.Required(CONF_ZIP_CODE): str,
|
||||||
),
|
vol.Optional(
|
||||||
}
|
CONF_MONITORED_CONDITIONS, default=list(SENSORS)
|
||||||
|
): vol.All(cv.ensure_list, [vol.In(SENSORS)]),
|
||||||
|
}
|
||||||
|
),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
extra=vol.ALLOW_EXTRA,
|
extra=vol.ALLOW_EXTRA,
|
||||||
@ -100,10 +103,7 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
websession = aiohttp_client.async_get_clientsession(hass)
|
websession = aiohttp_client.async_get_clientsession(hass)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
iqvia = IQVIAData(
|
iqvia = IQVIAData(Client(config_entry.data[CONF_ZIP_CODE], websession))
|
||||||
Client(config_entry.data[CONF_ZIP_CODE], websession),
|
|
||||||
config_entry.data.get(CONF_MONITORED_CONDITIONS, list(SENSORS)),
|
|
||||||
)
|
|
||||||
await iqvia.async_update()
|
await iqvia.async_update()
|
||||||
except InvalidZipError:
|
except InvalidZipError:
|
||||||
_LOGGER.error("Invalid ZIP code provided: %s", config_entry.data[CONF_ZIP_CODE])
|
_LOGGER.error("Invalid ZIP code provided: %s", config_entry.data[CONF_ZIP_CODE])
|
||||||
@ -143,11 +143,10 @@ async def async_unload_entry(hass, config_entry):
|
|||||||
class IQVIAData:
|
class IQVIAData:
|
||||||
"""Define a data object to retrieve info from IQVIA."""
|
"""Define a data object to retrieve info from IQVIA."""
|
||||||
|
|
||||||
def __init__(self, client, sensor_types):
|
def __init__(self, client):
|
||||||
"""Initialize."""
|
"""Initialize."""
|
||||||
self._client = client
|
self._client = client
|
||||||
self.data = {}
|
self.data = {}
|
||||||
self.sensor_types = sensor_types
|
|
||||||
self.zip_code = client.zip_code
|
self.zip_code = client.zip_code
|
||||||
|
|
||||||
self.fetchers = Registry()
|
self.fetchers = Registry()
|
||||||
@ -164,7 +163,7 @@ class IQVIAData:
|
|||||||
tasks = {}
|
tasks = {}
|
||||||
|
|
||||||
for conditions, fetcher_types in FETCHER_MAPPING.items():
|
for conditions, fetcher_types in FETCHER_MAPPING.items():
|
||||||
if not any(c in self.sensor_types for c in conditions):
|
if not any(c in SENSORS for c in conditions):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for fetcher_type in fetcher_types:
|
for fetcher_type in fetcher_types:
|
||||||
|
@ -66,7 +66,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
|
|||||||
}
|
}
|
||||||
|
|
||||||
sensors = []
|
sensors = []
|
||||||
for sensor_type in iqvia.sensor_types:
|
for sensor_type in SENSORS:
|
||||||
klass = sensor_class_mapping[sensor_type]
|
klass = sensor_class_mapping[sensor_type]
|
||||||
name, icon = SENSORS[sensor_type]
|
name, icon = SENSORS[sensor_type]
|
||||||
sensors.append(klass(iqvia, sensor_type, name, icon, iqvia.zip_code))
|
sensors.append(klass(iqvia, sensor_type, name, icon, iqvia.zip_code))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user