From c2cd4d0517d96cdb2d27329fb19ae9982273f91b Mon Sep 17 00:00:00 2001 From: Christopher Johnson Date: Wed, 28 Jun 2023 12:27:47 +0100 Subject: [PATCH] Expose host in ubus device tracker (#80621) * Expose host in ubus device tracker * Update homeassistant/components/ubus/device_tracker.py Co-authored-by: epenet <6771947+epenet@users.noreply.github.com> --------- Co-authored-by: epenet <6771947+epenet@users.noreply.github.com> --- homeassistant/components/ubus/device_tracker.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/ubus/device_tracker.py b/homeassistant/components/ubus/device_tracker.py index 48d5b4bd6f6..f49a06be9dd 100644 --- a/homeassistant/components/ubus/device_tracker.py +++ b/homeassistant/components/ubus/device_tracker.py @@ -75,13 +75,13 @@ class UbusDeviceScanner(DeviceScanner): def __init__(self, config): """Initialize the scanner.""" - host = config[CONF_HOST] + self.host = config[CONF_HOST] self.username = config[CONF_USERNAME] self.password = config[CONF_PASSWORD] self.parse_api_pattern = re.compile(r"(?P\w*) = (?P.*);") self.last_results = {} - self.url = f"http://{host}/ubus" + self.url = f"http://{self.host}/ubus" self.ubus = Ubus(self.url, self.username, self.password) self.hostapd = [] @@ -108,6 +108,10 @@ class UbusDeviceScanner(DeviceScanner): name = self.mac2name.get(device.upper(), None) return name + async def async_get_extra_attributes(self, device: str) -> dict[str, str]: + """Return the host to distinguish between multiple routers.""" + return {"host": self.host} + @_refresh_on_access_denied def _update_info(self): """Ensure the information from the router is up to date.