How to use the pyatv.const.Protocol.DMAP function in pyatv

To help you get started, we’ve selected a few pyatv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github postlund / pyatv / tests / common_functional_tests.py View on Github external
async def test_pair_missing_service(self):
        conf = AppleTV('1.2.3.4', 'Apple TV')

        with self.assertRaises(exceptions.NoServiceError):
            await pyatv.pair(conf, Protocol.DMAP, self.loop)
github postlund / pyatv / tests / dmap / test_dmap_pair.py View on Github external
async def initiate_pairing(self,
                               name=REMOTE_NAME,
                               pairing_guid=PAIRING_GUID):
        self.usecase.pairing_response(REMOTE_NAME, PAIRINGCODE)

        options = {
            'zeroconf': self.zeroconf,
            'name': name,
            'pairing_guid': pairing_guid,
        }

        self.pairing = await pyatv.pair(
            self.conf, Protocol.DMAP, self.loop, **options)
github postlund / hass-atv-beta / tests / apple_tv / test_config_flow.py View on Github external
(await flow().step_pair_with_pin(pin=1111)).gives_form_pair_no_pin(
        description_placeholders={"protocol": "DMAP", "pin": 1111}
    )

    (await flow().step_pair_no_pin()).gives_form_pair_with_pin(
        description_placeholders={"protocol": "AirPlay"}
    )

    (await flow().step_pair_with_pin(pin=1234)).gives_create_entry(
        {
            "address": "127.0.0.1",
            "protocol": Protocol.MRP.value,
            "name": "MRP Device",
            "credentials": {
                Protocol.MRP.value: "mrp_creds",
                Protocol.DMAP.value: "dmap_creds",
                Protocol.AirPlay.value: "airplay_creds",
            },
        },
        unique_id="mrp_id",
    )
github postlund / hass-atv-beta / tests / apple_tv / test_config_flow.py View on Github external
async def test_user_adds_device_with_credentials(flow, dmap_device_with_credentials):
    """Test adding DMAP device with existing credentials (home sharing)."""
    (await flow().step_user(identifier="DMAP Device")).gives_form_confirm(
        description_placeholders={"name": "DMAP Device"}
    )

    (await flow().step_confirm()).gives_create_entry(
        {
            "address": "127.0.0.1",
            "protocol": Protocol.DMAP.value,
            "name": "DMAP Device",
            "credentials": {Protocol.DMAP.value: "dummy_creds"},
        },
        unique_id="dmap_id",
    )
github postlund / pyatv / pyatv / dmap / pairing.py View on Github external
def __init__(self, config, session, loop, **kwargs):
        """Initialize a new instance."""
        super().__init__(session, config.get_service(Protocol.DMAP))
        self._loop = loop
        self._zeroconf = kwargs.get(
            'zeroconf', Zeroconf(loop, address_family=[netifaces.AF_INET]))
        self._name = kwargs.get('name', 'pyatv')
        self._web_server = None
        self._server = None
        self._pin_code = None
        self._has_paired = False
        self._pairing_guid = (kwargs.get(
            'pairing_guid', None) or _generate_random_guid())[2:].upper()
github postlund / hass-atv-beta / custom_components / apple_tv / config_flow.py View on Github external
from .const import DOMAIN  # pylint: disable=unused-import

_LOGGER = logging.getLogger(__name__)

INPUT_PIN_SCHEMA = vol.Schema({vol.Required(CONF_PIN, default=None): int})

DEFAULT_START_OFF = False
PROTOCOL_PRIORITY = [const.Protocol.MRP, const.Protocol.DMAP, const.Protocol.AirPlay]

SCAN_TIMEOUT = 5
UNICAST_SCAN_TIMEOUT = 30

# Mapping between config entry format and pyatv
CREDENTIAL_MAPPING = {
    CONF_CREDENTIALS_MRP: const.Protocol.MRP.value,
    CONF_CREDENTIALS_DMAP: const.Protocol.DMAP.value,
    CONF_CREDENTIALS_AIRPLAY: const.Protocol.AirPlay.value,
}


async def device_scan(identifier, loop, cache=None):
    """Scan for a specific device using identifier as filter."""

    def _filter_device(dev):
        if identifier is None:
            return True
        if identifier == str(dev.address):
            return True
        if identifier == dev.name:
            return True
        return any([service.identifier == identifier for service in dev.services])
github postlund / pyatv / pyatv / conf.py View on Github external
def __init__(self, identifier, credentials, port=None):
        """Initialize a new DmapService."""
        super().__init__(identifier, Protocol.DMAP, port or 3689)
        self.credentials = credentials
github postlund / hass-atv-beta / custom_components / apple_tv / config_flow.py View on Github external
from .const import (
    CONF_CREDENTIALS,
    CONF_CREDENTIALS_AIRPLAY,
    CONF_CREDENTIALS_DMAP,
    CONF_CREDENTIALS_MRP,
    CONF_IDENTIFIER,
    CONF_START_OFF,
)
from .const import DOMAIN  # pylint: disable=unused-import

_LOGGER = logging.getLogger(__name__)

INPUT_PIN_SCHEMA = vol.Schema({vol.Required(CONF_PIN, default=None): int})

DEFAULT_START_OFF = False
PROTOCOL_PRIORITY = [const.Protocol.MRP, const.Protocol.DMAP, const.Protocol.AirPlay]

SCAN_TIMEOUT = 5
UNICAST_SCAN_TIMEOUT = 30

# Mapping between config entry format and pyatv
CREDENTIAL_MAPPING = {
    CONF_CREDENTIALS_MRP: const.Protocol.MRP.value,
    CONF_CREDENTIALS_DMAP: const.Protocol.DMAP.value,
    CONF_CREDENTIALS_AIRPLAY: const.Protocol.AirPlay.value,
}


async def device_scan(identifier, loop, cache=None):
    """Scan for a specific device using identifier as filter."""

    def _filter_device(dev):