Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions homeassistant/components/iqvia/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,16 @@

CONFIG_SCHEMA = vol.Schema(
{
DOMAIN: vol.Schema(
{
vol.Required(CONF_ZIP_CODE): str,
vol.Required(CONF_MONITORED_CONDITIONS, default=list(SENSORS)): vol.All(
Comment thread
bachya marked this conversation as resolved.
cv.ensure_list, [vol.In(SENSORS)]
),
}
DOMAIN: vol.All(
cv.deprecated(CONF_MONITORED_CONDITIONS, invalidation_version="0.114.0"),
vol.Schema(
{
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,
Expand Down Expand Up @@ -100,10 +103,7 @@ async def async_setup_entry(hass, config_entry):
websession = aiohttp_client.async_get_clientsession(hass)

try:
iqvia = IQVIAData(
Client(config_entry.data[CONF_ZIP_CODE], websession),
config_entry.data.get(CONF_MONITORED_CONDITIONS, list(SENSORS)),
)
iqvia = IQVIAData(Client(config_entry.data[CONF_ZIP_CODE], websession))
await iqvia.async_update()
except InvalidZipError:
_LOGGER.error("Invalid ZIP code provided: %s", config_entry.data[CONF_ZIP_CODE])
Expand Down Expand Up @@ -143,11 +143,10 @@ async def async_unload_entry(hass, config_entry):
class IQVIAData:
"""Define a data object to retrieve info from IQVIA."""

def __init__(self, client, sensor_types):
def __init__(self, client):
"""Initialize."""
self._client = client
self.data = {}
self.sensor_types = sensor_types
self.zip_code = client.zip_code

self.fetchers = Registry()
Expand All @@ -164,7 +163,7 @@ async def async_update(self):
tasks = {}

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

for fetcher_type in fetcher_types:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/iqvia/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
}

sensors = []
for sensor_type in iqvia.sensor_types:
for sensor_type in SENSORS:
klass = sensor_class_mapping[sensor_type]
name, icon = SENSORS[sensor_type]
sensors.append(klass(iqvia, sensor_type, name, icon, iqvia.zip_code))
Expand Down