Exemple #1
0
    def test_scan_for_apple_tvs(self):
        zeroconf_stub.stub(pyatv, HOMESHARING_SERVICE_1, HOMESHARING_SERVICE_2)

        atvs = yield from pyatv.scan_for_apple_tvs(self.loop, timeout=0)
        self.assertEqual(len(atvs), 2)

        # First device
        dev1 = AppleTVDevice('Apple TV 1', ipaddress.ip_address('10.0.0.1'),
                             'aaaa')
        self.assertIn(dev1, atvs)

        # Second device
        dev2 = AppleTVDevice('Apple TV 2', ipaddress.ip_address('10.0.0.2'),
                             'bbbb')
        self.assertIn(dev2, atvs)
Exemple #2
0
async def _setup_atv(hass, hass_config, atv_config):
    """Set up an Apple TV."""

    name = atv_config.get(CONF_NAME)
    host = atv_config.get(CONF_HOST)
    login_id = atv_config.get(CONF_LOGIN_ID)
    start_off = atv_config.get(CONF_START_OFF)
    credentials = atv_config.get(CONF_CREDENTIALS)

    if host in hass.data[DATA_APPLE_TV]:
        return

    details = AppleTVDevice(name, host, login_id)
    session = async_get_clientsession(hass)
    atv = connect_to_apple_tv(details, hass.loop, session=session)
    if credentials:
        await atv.airplay.load_credentials(credentials)

    power = AppleTVPowerManager(hass, atv, start_off)
    hass.data[DATA_APPLE_TV][host] = {ATTR_ATV: atv, ATTR_POWER: power}

    hass.async_create_task(
        discovery.async_load_platform(hass, "media_player", DOMAIN, atv_config,
                                      hass_config))

    hass.async_create_task(
        discovery.async_load_platform(hass, "remote", DOMAIN, atv_config,
                                      hass_config))
Exemple #3
0
 def get_connected_device(self):
     details = AppleTVDevice('Apple TV', '127.0.0.1', HSGID, self.app.port)
     return connect_to_apple_tv(details, self.loop)
Exemple #4
0
 def get_connected_device(self, identifier):
     details = AppleTVDevice('Apple TV', '127.0.0.1', identifier,
                             self.app.port)
     return connect_to_apple_tv(details, self.loop)
Exemple #5
0
 def setUp(self):
     self.device_details = AppleTVDevice('name', 'address', 'hsgid')
     self.mock_device = asynctest.mock.Mock(MockAppleTV())