mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 02:07:09 +00:00
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
@ -75,13 +75,13 @@ class UbusDeviceScanner(DeviceScanner):
|
|||||||
|
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
"""Initialize the scanner."""
|
"""Initialize the scanner."""
|
||||||
host = config[CONF_HOST]
|
self.host = config[CONF_HOST]
|
||||||
self.username = config[CONF_USERNAME]
|
self.username = config[CONF_USERNAME]
|
||||||
self.password = config[CONF_PASSWORD]
|
self.password = config[CONF_PASSWORD]
|
||||||
|
|
||||||
self.parse_api_pattern = re.compile(r"(?P<param>\w*) = (?P<value>.*);")
|
self.parse_api_pattern = re.compile(r"(?P<param>\w*) = (?P<value>.*);")
|
||||||
self.last_results = {}
|
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.ubus = Ubus(self.url, self.username, self.password)
|
||||||
self.hostapd = []
|
self.hostapd = []
|
||||||
@ -108,6 +108,10 @@ class UbusDeviceScanner(DeviceScanner):
|
|||||||
name = self.mac2name.get(device.upper(), None)
|
name = self.mac2name.get(device.upper(), None)
|
||||||
return name
|
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
|
@_refresh_on_access_denied
|
||||||
def _update_info(self):
|
def _update_info(self):
|
||||||
"""Ensure the information from the router is up to date.
|
"""Ensure the information from the router is up to date.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user