pynetgear/__init__.py
def get_attached_devices(self):
        """
        Return list of connected devices to the router.

        Returns None if error occurred.
        """
        _LOGGER.info("Get attached devices")

        success, response = self._make_request(SERVICE_DEVICE_INFO,
                                               "GetAttachDevice")

        if not success:
            _LOGGER.error("Get attached devices failed")
            return None

        success, node = _find_node(
            response.text,
            ".//GetAttachDeviceResponse/NewAttachDevice")
        if not success:
            return None

        devices = []

        # Netgear inserts a double-encoded value for "unknown" devices
        decoded = node.text.strip().replace(UNKNOWN_DEVICE_ENCODED,
                                            UNKNOWN_DEVICE_DECODED)

        if not decoded or decoded == "0":
            _LOGGER.error("Can't parse attached devices string")
            _LOGGER.debug(node.text.strip())
            return devices

        entries = decoded.split("@")

        # First element is the total device count
        entry_count = None
        if len(entries) > 1:
            entry_count = _convert(entries.pop(0), int)

        if entry_count is not None and entry_count != len(entries):
            _LOGGER.info(
                """Number of devices should \
                 be: %d but is: %d""", entry_count, len(entries))

        for entry in entries:
            info = entry.split(";")

            if len(info) == 0:
                continue

            # Not all routers will report those
            signal = None
            link_type = None
            link_rate = None
            allow_or_block = None

            if len(info) >= 8:
                allow_or_block = info[7]
            if len(info) >= 7:
                link_type = info[4]
                link_rate = _convert(info[5], int)
                signal = _convert(info[6], int)

            if len(info) < 4:
                _LOGGER.warning("Unexpected entry: %s", info)
                continue

            ipv4, name, mac = info[1:4]

            devices.append(Device(name, ipv4, mac,
                                  link_type, signal, link_rate, allow_or_block,
                                  None, None, None, None))

        return devices
def get_attached_devices(self):
        """
        Return list of connected devices to the router.

        Returns None if error occurred.
        """
        _LOGGER.info("Get attached devices")

        success, response = self._make_request(SERVICE_DEVICE_INFO,
                                               "GetAttachDevice")

        if not success:
            _LOGGER.error("Get attached devices failed")
            return None

        success, node = _find_node(
            response.text,
            ".//GetAttachDeviceResponse/NewAttachDevice")
        if not success:
            return None

        devices = []

        # Netgear inserts a double-encoded value for "unknown" devices
        decoded = node.text.strip().replace(UNKNOWN_DEVICE_ENCODED,
                                            UNKNOWN_DEVICE_DECODED)

        if not decoded or decoded == "0":
            _LOGGER.error("Can't parse attached devices string")
            _LOGGER.debug(node.text.strip())
            return devices

        entries = decoded.split("@")

        # First element is the total device count
        entry_count = None
        if len(entries) > 1:
            entry_count = _convert(entries.pop(0), int)

        if entry_count is not None and entry_count != len(entries):
            _LOGGER.info(
                """Number of devices should \
                 be: %d but is: %d""", entry_count, len(entries))

        for entry in entries:
            info = entry.split(";")

            if len(info) == 0:
                continue

            # Not all routers will report those
            signal = None
            link_type = None
            link_rate = None
            allow_or_block = None

            if len(info) >= 8:
                allow_or_block = info[7]
            if len(info) >= 7:
                link_type = info[4]
                link_rate = _convert(info[5], int)
                signal = _convert(info[6], int)

            if len(info) < 4:
                _LOGGER.warning("Unexpected entry: %s", info)
                continue

            ipv4, name, mac = info[1:4]

            devices.append(Device(name, ipv4, mac,
                                  link_type, signal, link_rate, allow_or_block,
                                  None, None, None, None))

        return devices
def get_attached_devices ( self ) : _LOGGER . info ( "Get attached devices" ) success , response = self . _make_request ( SERVICE_DEVICE_INFO , "GetAttachDevice" ) if not success : _LOGGER . error ( "Get attached devices failed" ) return None success , node = _find_node ( response . text , ".//GetAttachDeviceResponse/NewAttachDevice" ) if not success : return None devices = [ ] # Netgear inserts a double-encoded value for "unknown" devices decoded = node . text . strip ( ) . replace ( UNKNOWN_DEVICE_ENCODED , UNKNOWN_DEVICE_DECODED ) if not decoded or decoded == "0" : _LOGGER . error ( "Can't parse attached devices string" ) _LOGGER . debug ( node . text . strip ( ) ) return devices entries = decoded . split ( "@" ) # First element is the total device count entry_count = None if len ( entries ) > 1 : entry_count = _convert ( entries . pop ( 0 ) , int ) if entry_count is not None and entry_count != len ( entries ) : _LOGGER . info ( """Number of devices should \
                 be: %d but is: %d""" , entry_count , len ( entries ) ) for entry in entries : info = entry . split ( ";" ) if len ( info ) == 0 : continue # Not all routers will report those signal = None link_type = None link_rate = None allow_or_block = None if len ( info ) >= 8 : allow_or_block = info [ 7 ] if len ( info ) >= 7 : link_type = info [ 4 ] link_rate = _convert ( info [ 5 ] , int ) signal = _convert ( info [ 6 ] , int ) if len ( info ) < 4 : _LOGGER . warning ( "Unexpected entry: %s" , info ) continue ipv4 , name , mac = info [ 1 : 4 ] devices . append ( Device ( name , ipv4 , mac , link_type , signal , link_rate , allow_or_block , None , None , None , None ) ) return devices
Return list of connected devices to the router.

        Returns None if error occurred.
Return list of connected devices to the router .