8000 Add configuration_url to isy994 by bdraco · Pull Request #58372 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add configuration_url to isy994 #58372

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

Merged
merged 5 commits into from
Oct 25, 2021
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
11 changes: 10 additions & 1 deletion homeassistant/components/isy994/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,19 @@ def _async_import_options_from_data_if_missing(
hass.config_entries.async_update_entry(entry, options=options)


@callback
def _async_isy_to_configuration_url(isy: ISY) -> str:
"""Extract the configuration url from the isy."""
connection_info = isy.conn.connection_info
proto = "https" if "tls" in connection_info else "http"
return f"{proto}://{connection_info['addr']}:{connection_info['port']}"


async def _async_get_or_create_isy_device_in_registry(
hass: HomeAssistant, entry: config_entries.ConfigEntry, isy
) -> None:
device_registry = await dr.async_get_registry(hass)

url = _async_isy_to_configuration_url(isy)
device_registry.async_get_or_create(
config_entry_id=entry.entry_id,
connections={(dr.CONNECTION_NETWORK_MAC, isy.configuration["uuid"])},
Expand All @@ -264,6 +272,7 @@ async def _async_get_or_create_isy_device_in_registry(
name=isy.configuration["name"],
model=isy.configuration["model"],
sw_version=isy.configuration["firmware"],
configuration_url=url,
)


Expand Down
7 changes: 6 additions & 1 deletion homeassistant/components/isy994/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity import DeviceInfo, Entity

from . import _async_isy_to_configuration_url
from .const import DOMAIN


Expand Down Expand Up @@ -76,8 +77,11 @@ def device_info(self) -> DeviceInfo:
if hasattr(self._node, "protocol") and self._node.protocol == PROTO_GROUP:
# not a device
return None
uuid = self._node.isy.configuration["uuid"]
isy = self._node.isy
uuid = isy.configuration["uuid"]
node = self._node
url = _async_isy_to_configuration_url(isy)

basename = self.name

if hasattr(self._node, "parent_node") and self._node.parent_node is not None:
Expand All @@ -91,6 +95,7 @@ def device_info(self) -> DeviceInfo:
model="Unknown",
name=basename,
via_device=(DOMAIN, uuid),
configuration_url=url,
)

if hasattr(node, "address"):
Expand Down
0