Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 2657d9f
Author: Mick Vleeshouwer <[email protected]>
Date:   Sun Jan 31 22:23:53 2021 +0100

    Add gateways to Device Registry (#333)

    Co-authored-by: Vincent Le Bourlot <[email protected]>

commit 323ac9d
Author: Mick Vleeshouwer <[email protected]>
Date:   Sun Jan 31 21:55:44 2021 +0100

    Update README to reflect support of other OverKiz hubs (#363)
  • Loading branch information
iMicknl committed Jan 31, 2021
1 parent 6457539 commit ccfc829
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions custom_components/tahoma/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,36 @@ async def handle_get_execution_history(call):
handle_get_execution_history,
)

device_registry = await dr.async_get_registry(hass)

for gateway in gateways:
_LOGGER.debug(
"Added gateway (%s - %s - %s)",
gateway.id,
gateway.type,
gateway.sub_type,
)

gateway_model = (
beautify_name(gateway.sub_type.name)
if isinstance(gateway.sub_type, Enum)
else None
)
gateway_name = (
f"{beautify_name(gateway.type.name)} hub"
if isinstance(gateway.type, Enum)
else None
)

device_registry.async_get_or_create(
config_entry_id=entry.entry_id,
identifiers={(DOMAIN, gateway.id)},
model=gateway_model,
manufacturer="Somfy",
name=gateway_name,
sw_version=gateway.connectivity.protocol_version,
)

return True


Expand Down Expand Up @@ -289,6 +319,11 @@ def print_homekit_setup_code(device: Device):
_LOGGER.info("HomeKit support detected with setup code %s.", homekit.value)


def beautify_name(name: str):
"""Return human readable string."""
return name.replace("_", " ").title()


async def write_execution_history_to_log(client: TahomaClient):
"""Retrieve execution history and write output to log."""
history = await client.get_execution_history()
Expand Down

0 comments on commit ccfc829

Please sign in to comment.