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>
This commit is contained in:
parent
796b5ef196
commit
c2cd4d0517
1 changed files with 6 additions and 2 deletions
|
@ -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<param>\w*) = (?P<value>.*);")
|
||||
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.
|
||||
|
|
Loading…
Add table
Reference in a new issue