示例#1
0
    def __init__(self, host, username, password, port):
        """Initialize the scanner."""
        import pynetgear

        self.last_results = []
        self.lock = threading.Lock()

        if host is None:
            self._api = pynetgear.Netgear()
        elif username is None:
            self._api = pynetgear.Netgear(password, host)
        elif port is None:
            self._api = pynetgear.Netgear(password, host, username)
        else:
            self._api = pynetgear.Netgear(password, host, username, port)

        _LOGGER.info("Logging in")

        results = self._api.get_attached_devices()

        self.success_init = results is not None

        if self.success_init:
            self.last_results = results
        else:
            _LOGGER.error("Failed to Login")
示例#2
0
    def __init__(
        self,
        host,
        ssl,
        username,
        password,
        port,
        devices,
        excluded_devices,
        accesspoints,
    ):
        """Initialize the scanner."""
        import pynetgear

        self.tracked_devices = devices
        self.excluded_devices = excluded_devices
        self.tracked_accesspoints = accesspoints

        self.last_results = []
        self._api = pynetgear.Netgear(password, host, username, port, ssl)

        _LOGGER.info("Logging in")

        results = self.get_attached_devices()

        self.success_init = results is not None

        if self.success_init:
            self.last_results = results
        else:
            _LOGGER.error("Failed to Login")
示例#3
0
def amihome():
    netg = pynetgear.Netgear()
    netg.password='******'
    homemacs=['AA:BB:CC:11:22:33','DD:EE:FF:44:55:66']
    macs = []
    for device in netg.get_attached_devices():
        macs.append(device.mac)
    if [i for i in homemacs if i in macs]:
        return("true")
    else:
        return("false")
示例#4
0
    def __init__(self, host, username, password):
        import pynetgear

        self.last_results = []

        self._api = pynetgear.Netgear(host, username, password)
        self.lock = threading.Lock()

        _LOGGER.info("Logging in")

        self.success_init = self._api.login()

        if self.success_init:
            self._update_info()
        else:
            _LOGGER.error("Failed to Login")
示例#5
0
def get_connected_devices(mode):
    netgear = pynetgear.Netgear(password, host, user, port)
    if not netgear.logged_in:
        # Log in
        if not netgear.login():
            print(
                'Could not login to router. Please check host, user, password and port'
            )
            sys.exit(1)

    devices = netgear.get_attached_devices()

    if mode == mode_signal_strength:
        # Exclude wired devices
        devices = [d for d in devices if d.type == 'wireless']

    return devices
示例#6
0
def get_router_data():
    password = get_passwords()["router"]["password"]
    netgear = pynetgear.Netgear(password=password)
    return netgear.get_attached_devices()