Exemplo n.º 1
0
    def discover_single(
            host: str,
            protocol: TPLinkSmartHomeProtocol = None) -> Optional[SmartDevice]:
        """Discover a single device by the given IP address.

        :param host: Hostname of device to query
        :param protocol: Protocol implementation to use
        :rtype: SmartDevice
        :return: Object for querying/controlling found device.
        """
        if protocol is None:
            protocol = TPLinkSmartHomeProtocol()

        info = protocol.query(host, Discover.DISCOVERY_QUERY)

        device_class = Discover._get_device_class(info)
        if device_class is not None:
            return device_class(host)

        return None
Exemplo n.º 2
0
    def discover_single(
            host: str,
            protocol: TPLinkSmartHomeProtocol = None) -> SmartDevice:
        """
        Similar to discover(), except only return device object for a single
        host.

        :param host: Hostname of device to query
        :param protocol: Protocol implementation to use
        :rtype: SmartDevice
        :return: Object for querying/controlling found device.
        """
        if protocol is None:
            protocol = TPLinkSmartHomeProtocol()

        info = protocol.query(host, Discover.DISCOVERY_QUERY)

        device_class = Discover._get_device_class(info)
        if device_class is not None:
            return device_class(host)
        else:
            return None
Exemplo n.º 3
0
    def discover_single(host: str,
                        protocol: TPLinkSmartHomeProtocol = None
                        ) -> SmartDevice:
        """
        Similar to discover(), except only return device object for a single
        host.

        :param host: Hostname of device to query
        :param protocol: Protocol implementation to use
        :rtype: SmartDevice
        :return: Object for querying/controlling found device.
        """
        if protocol is None:
            protocol = TPLinkSmartHomeProtocol()

        info = protocol.query(host, Discover.DISCOVERY_QUERY)

        device_class = Discover._get_device_class(info)
        if device_class is not None:
            return device_class(host)
        else:
            return None