Skip to content

Commit

Permalink
Refactor entity registration
Browse files Browse the repository at this point in the history
  • Loading branch information
iMicknl committed Jun 7, 2020
1 parent 74dd1b4 commit fef2a54
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions custom_components/tahoma/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,20 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
_LOGGER.exception("Error when getting devices from the Tahoma API")
return False

hass.data[DOMAIN][entry.entry_id] = {"controller": controller, "devices": [], "scenes": []}
hass.data[DOMAIN][entry.entry_id] = {
"controller": controller,
"devices": [],
"scenes": [],
}

# List devices
for device in devices:
_device = controller.get_device(device)

if _device.uiclass in TAHOMA_TYPES:
if TAHOMA_TYPES[_device.uiclass] in PLATFORMS:
component = TAHOMA_TYPES[_device.uiclass]

hass.data[DOMAIN][entry.entry_id]["devices"].append(_device)

hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component)
)
else:
_LOGGER.warning(
"Unsupported Tahoma device (%s - %s - %s)",
Expand All @@ -94,6 +93,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
_device.widget,
)

for component in PLATFORMS:
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component)
)

for scene in scenes:
hass.data[DOMAIN][entry.entry_id]["scenes"].append(scene)

Expand Down

0 comments on commit fef2a54

Please sign in to comment.