Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loop through device configurations #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
21 changes: 11 additions & 10 deletions custom_components/toyota_na/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,22 @@ async def async_service_handle(service_call: ServiceCall) -> None:

# There is currently not a case with this integration where
# the device will have more or less than one config entry
if len(device.config_entries) != 1:
if len(device.config_entries) == 0:
_LOGGER.warning("Device missing config entry")
return

entry_id = list(device.config_entries)[0]
for entry_id in device.config_entries:
if entry_id not in hass.data[DOMAIN]:
_LOGGER.warning("Config entry not found")
continue

if entry_id not in hass.data[DOMAIN]:
_LOGGER.warning("Config entry not found")
return

if "coordinator" not in hass.data[DOMAIN][entry_id]:
_LOGGER.warning("Coordinator not found")
return
if "coordinator" not in hass.data[DOMAIN][entry_id]:
_LOGGER.warning("Coordinator not found")
continue

coordinator = hass.data[DOMAIN][entry_id]["coordinator"]
coordinator = hass.data[DOMAIN][entry_id]["coordinator"]
if coordinator.data is None:
_LOGGER.warning("No coordinator data")

if coordinator.data is None:
_LOGGER.warning("No coordinator data")
Expand Down