Skip to content

Commit

Permalink
Add configuration_url to device_info
Browse files Browse the repository at this point in the history
  • Loading branch information
LennP committed Nov 29, 2023
1 parent cb172aa commit 51d477a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ async def async_step_init(
self.config_entry,
data=updated_data,
)
scene_select.rs485_device.set_key(user_input[CONF_KEY])
scene_select.set_key(user_input[CONF_KEY])
return self.async_create_entry(title="", data=user_input)

return self.async_show_form(
Expand Down
18 changes: 18 additions & 0 deletions select.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.event import async_call_later
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers import device_registry as dr

from .motionblinds_rs485.device import MotionBlindsRS485Device

Expand Down Expand Up @@ -102,8 +103,25 @@ def __init__(self, entry: ConfigEntry) -> None:
identifiers={(DOMAIN, self.hostname)},
manufacturer=MANUFACTURER,
name=self._attr_name,
configuration_url=f"http://{self.hostname}.local"
+ (
f"/?key={self.config_entry.data[CONF_KEY]}"
if self.config_entry.data[CONF_KEY] != ""
else ""
),
)

def set_key(self, key: str) -> None:
self.rs485_device.set_key(key)
device_registry = dr.async_get(self.hass)
device = device_registry.async_get_device(identifiers={(DOMAIN, self.hostname)})
if device:
device_registry.async_update_device(
device.id,
configuration_url=f"http://{self.hostname}.local"
+ (f"/?key={key}" if key != "" else ""),
)

async def async_added_to_hass(self) -> None:
"""Run when entity about to be added."""
self.rs485_device = MotionBlindsRS485Device(
Expand Down

0 comments on commit 51d477a

Please sign in to comment.