1 """Device tracker support for OPNSense routers."""
3 from __future__
import annotations
9 from .
import CONF_TRACKER_INTERFACE, OPNSENSE_DATA
13 hass: HomeAssistant, config: ConfigType
14 ) -> OPNSenseDeviceScanner:
15 """Configure the OPNSense device_tracker."""
16 interface_client = hass.data[OPNSENSE_DATA][
"interfaces"]
18 interface_client, hass.data[OPNSENSE_DATA][CONF_TRACKER_INTERFACE]
23 """Class which queries a router running OPNsense."""
26 """Initialize the scanner."""
32 """Create dict with mac address keys from list of devices."""
34 for device
in devices:
36 out_devices[device[
"mac"]] = device
40 """Scan for new devices and return a list with found device IDs."""
45 """Return the name of the given device or None if we don't know."""
51 """Ensure the information from the OPNSense router is up to date.
53 Return boolean if scanning successful.
56 devices = self.
clientclient.get_arp()
60 """Return the extra attrs of the given device."""
63 if not (mfg := self.
last_resultslast_results[device].
get(
"manufacturer")):
65 return {
"manufacturer": mfg}
def __init__(self, client, interfaces)
def _get_mac_addrs(self, devices)
def get_extra_attributes(self, device)
def get_device_name(self, device)
web.Response get(self, web.Request request, str config_key)
OPNSenseDeviceScanner async_get_scanner(HomeAssistant hass, ConfigType config)